Skip to main content

Posts

Debugging with gdb

Debugging a program is a real tedious job which can consume time more than you took to write the program. And if you are not on the right track of debugging then you are probably gonna end up writing the whole program again. If you have red my previous article on debugging ( The Art of Debugging ) then you already have an idea of the debugging process and what are some basic methods to do it. We also talked about how are those basic techniques not gonna help us with larger and trickier programs. To make our job easy with those programs, there is a debugging tool : GNU Debugger or simply gdb. GDB is a powerful debugging tool with all the features you require while debugging your program. There are some basic set of features which are available in every debugging tool so if you want to use some other debugger then you'll find it easy to use after you get to know about gdb. There is some great stuff we'll be studying today so sit tight. Let's have a look at the index we'l...

The Art of Debugging

Writing unorganised code for something to work is an easy task, just put anything anywhere and see if the result is coming or not. If the result comes out in first attempt then you are really lucky but normal people like me are not. Then what we should do to check where the problem is occuring, we put some print statements (or console.log) to check the result in various places and observe where the output is deviating from its path. Well, it itself is a good practise of debugging the code but it does not work always especially not with large projects. So what should we do then ? According to me, we should give debugger a chance to find the bugs in our program. Debugging is an important part of writing programs because it teaches you to write unit tests for the parts of the program where it can fail. To perform debugging, we need a debugger and thankfully we have one, gdb (GNU debugger). In this article we will start by seeing some basic debugging techniques which involves logging the...

Understanding Python Decorators

If you have ever wondered what those @something mean above a python function or method then you are going to have your answers now. This @something line of code is actually called a decorator. I have red from various articles about them but some of them were not able to clarify the concept of a decorator and what we can achieve with them. So in this post we'll learn a lot about python decorators. Here is a list of topics we'll be covering. What is python decorator Understanding the concept Multiple decorators on same function class method decorator Where can we use decorators What is python decorator A python decorator is nothing but a function which accepts your given function as a parameter and returns a replacement function. So its like something this def decorator(your_func): def replacement(your_func_args): #do some other work return replacement @decorator your_func(your_func_args): #your_func code Now when your_func gets called then...

See More of C

Why more of c ? Function Pointers Search and Sort Multi-Threaded Programming Time Functions Random Numbers String Conversion Process Creation and System commands execution DataBase Handling CGI Scripting More Links Why digging more of C ? Being a high level language and the features C support there is not a need to ask why should we learn more about C. C programs are relatively faster than most of other high level languages like python or java. That may be because C programs are compiled first or may be because C libraries and fucntions are more hardware oriented. But whatever is the reason, C programs are way better. I can show you an example of it to you. There is a program which corrects the spelling of a mis-spelled word like it changes "somethinh" to "something". Now here is the comparison between the programs written in C and than that written in python Property Program i...

Learn Git & Github - 4

Lesson 1 Lesson 2 Lesson 3 Lesson 4 Git Tree Navigation And Management: Lesson-4 Topics How to change remote repository Commit navigation in git How to jump to a specific commit How to create a branch from a speicific commit How to edit a specific commit How to merge commits How to delete commits How to pick/move commits from one branch to other Changing Remote Repository In the previous lesson , we learned how to make commits. If totally followed the lesson then i am sure you world have made some commits also. Now change your working directory to your project directory. Check you are on master and Use git pull origin master to update your master. Since Now, we were syncing our local repository with our forked repository. But what we need is to keep updated with the original project repository. So we need to add the url of original project as our main remote repository. We can do so by typing git remote add main https:...

Learn Git & Github - 3

Lesson 1 Lesson 2 Lesson 3 Lesson 4 Git Commands: Lesson-3 Topics What we learned in previous lesson Git Terminology Git Commands for project development What we learned in Previous Lesson In the previous lesson , we learned about github and how can we use it along with git to create an open source project(A project which is free to use and distribute). We set up our project on github and cloned it in our machine to modify it locally(On our machine only). Now either you have cloned fork of an existing project or your own project, the development process is nearly the same. I'll point out the difference wherever applicable. Git Terminology In first lesson, we talked about 3 most occuring terms of git which are branch, commit and head. Now Lets talk about some more terms which are associated with git Index : Index is the current state of the project for git. If you have changed some files then you will have to add them to git index so that git can tr...

Learn Git & Github - 2

Lesson 1 Lesson 2 Lesson 3 Lesson 4 Learn Github: Lesson-2 Topics Difference between Git and Github Geting started with github Work on existing github project Creating a new project on github Difference between git and github In the first lesson we learned how git works, Now we will see what is github. People often get confused between git and github. These two are entirely different things providing the same functionality. The major difference between git and github is that git works on your machine and github is a cloud service. You can see github as a cloud version of github where an entire team can work on a project. So there is not a point of choosing either one of them. You use git only if you have a project on which you are working alone and then you use github along with git if you are handling a team project. Its not mandatory to have a team to use github. If you want to share your code to people then you can push/upload it to gi...