Posts

Showing posts with the label programming

How to geek: Learn to code like a pro

Image
Warning! Philosophical text ahead. Skip to the next section to avoid it. A lot of people come up with a lot of brilliant ideas. But not all of them are able to execute their ideas due to lack of programming knowledge. Lack of programming knowledge is something that can only be solved by sitting your ass down and doing a course patiently without giving any excuses. It is important to assess yourself thoroughly. If you don’t know something, you need to accept it. You can’t call yourself a web developer after editing a few HTML templates. If you want to be a web developer, stop editing templates and start building one from scratch. Speed is not more important than fundamentals. If you go after speed, you will end up becoming like season one flash. Another thing I’ve noticed in people is, they are not able to stay motivated for more than a day. They start a course online, binge watch a few videos and then forget about it the next day. An online course is not the same as a TV sh...

The magic of recursion

Image
I first encountered the concept of recursion in 11 th grade, in an object-oriented programming class. At the time, I never really bothered about it that much. But now that I really understand the concept, I realized how magical it is. I was very fascinated to see how elegantly it worked. Sometimes I still wonder how it works. Last year, I was doing a course on python on edX. And in the course, I again encountered the concept of recursive functions. The professor explained the concept using the example of ‘towers of Hanoi’, which made it all the more interesting. The best part was, the solution for a classic problem like ‘towers of Hanoi’ could be derived using just seven lines of code. For those of you who don’t know, recursive functions are function that invoke themselves. It works like a loop. The function keeps calling itself until a certain condition is met. All recursive functions can be broadly divided into 2 parts. A condition and a recursive call. A recursive call...

HOW TO DEPLOY A PYTHON SCRIPT OR PROJECT ON HEROKU

Image
Cloud computing has been one of the biggest revolutions of our time. This has given birth to a lot of cloud services that help, developers and even common people, solve day to day problems. For example, google drive, dropbox etc. are cloud services that give us space to store our data on the cloud (server). Cloud computing has nothing to do with the actual clouds (if you don’t already know). A cloud is a reference to a remote server that we are given temporary access to for a particular kind of usage. Heroku is on such service which allows users to use their server for hosting applications.  This is, provide a platform for running the source code of the project. This service is free, however, there is also a paid account with more privileges. It also allows users to host databases on it. It supports several languages. And it provides a log of all the activities of the project. So let get to the part where we have to deploy python projects or scripts on heroku. Since python is also...

How to use a text file as a database while programming

Image
Welcome back to another post of Teckguide. It has been really long since I have written a post, I am really sorry about that. But I am back with a useful and informative post for all of you. In this post we will see how to use a simple text file as a database. Not a lot of people realize this but normal text file can be a simple alternative for a database like SQL, mongo etc. Although a database is simple to use, beginners find it difficult to use them in their program. So this post if for you if you belong to that category. But before that, What is a database? A database is a collection of data that is stored in the form of tables or relations to easily access any element and all its aspects in one place. These databases have a special column for a ‘primary key’ where a value, that uniquely differentiates all the element, is stored. So it can be imagined like a table with multiple rows and columns. A database can multiple tables. For example, a company can have a da...

HOW TO EXTRACT ALL THE LINKS of A GIVEN WEBPAGE (with python)

Image
Websites are made of web pages. Every webpage is made of html tags. And every webpage has a unique address called URL which stands for Uniform Resource Locator. Using which we can request the webpage html code from the server. Once we send the request, the server will give us the html file for the webpage and our browser translates the code into readable English. This is the process that takes place every time we browse the internet. In today’s post, we will see how to do that without the browser and rather through python. And also we will see how to grab all the links present on a website. A link is another URL. There can be many uses of doing this. For example, a web crawler does this all the time. It goes through the html code of a website and copies the links. And it visits those individual links and looks for other links in that page too. This is how the Google indexes pages. It crawls the whole of the internet every day. Python is very easy, as is this process. So let’s get star...

Basic algorithms 101 : Checking for email address validity (without regular expressions)

Image
Hello! Welcome back to “Basic algorithms 101”. Last time we discussed about a coin toss algorithm. It was a fairly easy one. This time we are taking up a slightly more complicated one. It is, checking for the validity of an email address. Basically it’s an algorithm to check if the given email address is a valid one or not. If you are a pro coder, I suggest you don’t read this because we are not going to using regular expressions but taking a simpler but slightly longer route. If you are a beginner and not comfortable with regular expressions, do not worry, there are other ways too. If you are among the people who have no idea what regular expressions are, I strongly recommend you look it up.

Basic algorithms 101 : Coin toss (unbiased and biased)

Image
Welcome to the first post of the new series “simple algorithms”. In this series we will be dealing with simple to understand programming algorithms. If you are a beginner at programming or aspiring to be a programmer, this series is meant for you.  For convenience we will be taking python as an example for the code. In this first post, will be dealing with a very simple algorithm which is “The Coin Toss algorithm”. In case you don’t know a coin has two sides, a head and a tail. When you flip it, the outcome is either a head or a tail.  As you can see, there are only two cases. So that makes it very easy.  Some people might want to know the algorithm for a biased coin. So we will be looking at that too. The biased one is slightly trickier than the unbiased one. First, let’s look at the unbiased and then get to the biased coin.  So without any further ado, let’s just get right into it.

Bitcoin : Is this the future of currency?

Image
A while ago we made a post about Bitcoin. That was way back in 2013 when Bitcoin wasn't very popular. In the mid of 2013, about exactly a year ago the value of 1 Bitcoin was around a $120. As of today, while you are reading this post, the value of 1 Bitcoin is close to a $600!! So whats changed, that has caused this currency to become 5 times it's value in a year? Well, let's find out.

HOW TO SIMULATE A BOUNCING BALL USING C++

HEllo!! Bouncing ball simulation is really interesting in C++. It uses the header file <graphics.h> for drawing the ball, and here we also use the delay function for displaying the ball in different places. The header files used : < graphics.h> , <stdio.h> , <conio.h> , <iostream.h> , <dos.h> , <stdlib.h> the source code is not that hard to understand if you know how to use graphics in C++. Otherwise it's a little complicated, again 'copy-paste'. here is the source code: That's it, there is nothing you can do in this simulator, other than watching it bounce. Thank you cheers !! keep coding..

A cool application of the delay function in c++

The delay function can be used very creatively this is one of them. In this post ill show u how to print a sentence with a delay after every letter!! there is a slightly complicated code for doing that. Again just copy paste  :-P the code: int i,j,k; char str[] = {" insert your sentence here "}; int ben = strlen(str); for(i=0;i<ben;i++) { putchar(str[i]); delay(90); } Thats it. Copy this and paste it in turbo c++. If you don't know how to then refer to my previous post on " how to copy text to turbo c++. "  Thank you  cheers!!!!

HOW TO USE THE DELAY FUNCTION IN C++

Image
Hello programmers!! Have you ever wondered how people use that effect, in C++ console applications, in which they make characters appear after a certain time. Like they say "loading..." and the cots appear one by one at a particular time interval. This effect looks very cool and makes the applications look very professional.Also see : Basic Algorithms 101 : Checking the validity of an email address (simple beginner approach) Also see : Basic Algorithms 101 : Checking the validity of an email address (simple beginner approach)  This 'effect' is called delay. Delay is a more professional term used for some thing that happens a little later than it is expected to happen. This is used in c++ intentionally to either create an 'effect' or to easy the procedures of the application for the user.  Like there are many uses of the delay function. Usually in C++ the output appears in the console as soon as it is executed. This might make it look like the applicat...

HOW TO COPY ANY TEXT TO TURBO C++

Image
Hello!! Are you one of those people who is in the middle of a C++ program and you know what to do, but you don't know the syntax? So you google and find out the syntax. But in turbo c++ you cannot use ctrl+v. That might be a little pissing off. So the easiest solution would be to get rid of Turbo C++ and get a modern day compiler. But anyway, here is a post on how one can copy text from an external source into the turbo C++ environment. C++ is a very powerful language, but the Turbo C++ compiler is bloody ancient and very conservative. The Unix environment it has can be a pain in the neck sometimes. With the modern day compilers like C++ builder, eclipse, and stuff, programming in C++ has become so much easier. Unix environment is not really necessary to build an application. And these new compilers also have a lot of predefined functions for graphics, user interface etc. Sometimes we want to write little complex programs or make console games using C++ . But we are not qua...

HOW TO MAKE A CONSOLE GAME IN C++ : Blackjack

Image
(updated : 27/02/2015) Blackjack, also known as twenty-one, is the most widely played casino banking game in the world. Blackjack is a comparing card game between a player and dealer, meaning that players compete against the dealer but not against any other players. It is played with one or more decks of 52 cards. The object of the game is to beat the dealer, which can be done in a number of ways: Get 21 points on the player's first two cards (called a blackjack), without a dealer blackjack; Reach a final score higher than the dealer without exceeding 21; or Let the dealer draw additional cards until his or her hand exceeds 21. (source : wikipedia) This post is about how to make a console version of this game using C++. Console version means, it is played in command prompt like window. It is not very hi-tech complex graphic based version, so dont have too much expectation. You can say that this is the programmers version of the game. Its not that console games are...