If you have worked on a large code base before, you would have seen ifdef and ifndef statements a lot of times. In fact, it is a good practice to have them wherever necessary. It just adds more robustness to your code and if you are working in a team, it helps you avoid weird compiler issues. The preprocessor directive #ifdef is used to define conditional groups of code at the preprocessor level. Based on a condition, a piece of code may or may not be included in the program. The body of this directive is usually termed controlled text. Continue reading “ifdef and ifndef”
CMake vs Make
Programmers have been using CMake and Make for a long time now. When you join a big company or start working on a project with a large codebase, there are all these builds that you need to take care of. You must have seen those “CMakeLists.txt” files floating around. You are supposed to run “cmake” and “make” commands on the terminal. A lot of people just follow the instructions blindly, not really caring about why we need to do things in a certain way. What is this whole build process and why is it structured this way? What are the differences between CMake and Make? Does it matter? Are they interchangeable? Continue reading “CMake vs Make”
How To Take A Screenshot On Mac OS X
One of the many good things about Mac OS X is the built in support for taking screenshots. But then again, in this day and age, what operating system doesn’t? Well, this is where it differs a little. I am sure most of you know how to capture a screenshot on OS X, but there might be situations where your requirements change a bit. There are many different ways to capture the content being displayed on your screen. Each one of those methods has something different and unique to offer. These methods are very handy at times! I have described a few different methods here. Let’s see what they are. Continue reading “How To Take A Screenshot On Mac OS X”
1 + 2 + 3 + 4 + 5 + …. = -1/12
Wait a minute, what? That looks very very wrong. You must be wondering if the title is some horrendous typo, right? Well, let me assure you that it’s absolutely not! The sum of all natural numbers is equal to -1/12. This blog post is not just about mathematical trickery either. The equation in the title is actually a very important result used in theoretical physics, particularly in string theory. Now how can that be possible? Are physicists really that bad at mathematics? That can’t be it! What is the proof behind this? Do we ever encounter it in real life? Continue reading “1 + 2 + 3 + 4 + 5 + …. = -1/12”
Generating UIButton Programmatically
When you are working on an iOS app, you invariably end up creating buttons on your view controllers. For some of the apps, you know exactly where everything goes and you place everything beforehand in your storyboard file. But if your app is more complex, you may want to create the buttons dynamically. This means is that creating a button might be interactive and can depend on the actions of the user. How do we create buttons programmatically? Once they are created, how do we associate actions with them? Continue reading “Generating UIButton Programmatically”
Why Would We Ever Use Blind Search?
Over the last few decades, we have seen a lot of technologies come by and make a significant impact. Most of these technologies, if you have noticed, revolve around intelligent actions. Let’s say you are in the middle of a street and you want a cab. We can solve this problem in a couple of different ways depending on the level of intelligence we put into our solution. How can we design something that can make use of all the data and provide the best possible solution to the person in the middle of the street? We can say that intelligent action involves search in some way. Searching is needed in a variety of situations, so developing mathematically and computationally strong algorithms is an absolute must. In most of the real life situations, we don’t really know where to look or how a particular search is going to pan out. How do we formulate this? Continue reading “Why Would We Ever Use Blind Search?”
Plus vs Minus In Objective-C
Whenever you are working with an iOS app, you would have seen those functions and how they have a plus or a minus sign at the beginning. Ever wondered what they are? Objective-C requires that the interface and implementation of a class be in separate code blocks. That’s the reason you will see a .h and a .m file as a pair. Interface is the same as class definition in other languages. By convention, we place the interface in a header file and the implementation in a code file. In the header file, we declare functions with these ‘+’ and ‘-‘ signs. Do they make any real difference or do we have them just as part of the Objective-C language protocol? Well, they exist for a reason and there is a real difference between the signs. Continue reading “Plus vs Minus In Objective-C”
What Is Fuzzy Matching?
This is a continuation of the previous blog post on fuzzy search. We use fuzzy matching algorithms in fuzzy search to come up with the search results. The strength of a fuzzy search algorithm heavily depends on the strength of the fuzzy matching algorithm that is being used. The concept of matching refers to an input being matched to a set of entries, or records, in your database to come up with the best possible match. We encounter this scenario very frequently in our everyday lives. Whenever you are looking up a word in the dictionary or when somebody is looking up your account during a customer service call, some form of matching is being used to get the answers. So how exactly does fuzzy matching work? What’s the big deal here? Continue reading “What Is Fuzzy Matching?”
What Is Fuzzy Search?
The word “fuzzy” means something that is indistinct or vague, something that cannot be explained precisely. We all know what “search” means. That should give you a hint of what this blog post is about. Whenever you type something into the Google search engine, you will see that it always returns good results, even when you type the wrong spelling. How does it know what you meant? There are many different ways to misspell a word. How does it know exactly what word you have in mind? Continue reading “What Is Fuzzy Search?”
Reading JPEG Into A Byte Array
Let’s say you are work
ing with images for your project. A lot of times, when you have to work across multiple platforms, the encoding doesn’t remain the same. In these scenarios, you cannot process images directly by treating them like 2D matrices. One of the most common image formats you will comes across is JPEG. If you are working on the same platform using a library like OpenCV, you can directly read JPEG files into 2D data structures. If not, you will have to read it into a byte array, process it and then encode it back. How do we do that? Continue reading “Reading JPEG Into A Byte Array”