Machine Learning - Baby Steps
· β˜• 4 min read · πŸ€– Naresh Mehta

Machine learning (ML) is the “FUTURE”. I have been reading about it for quite some time now and I am pretty convinced by the statement. We are all talking about BigData, predictive analytics, etc. but really, when a system dude like me tries to foray into the field of ML, everything seems so overwhelming. The discussion starts with having millions of records (if you are lucky). Otherwise, it is 4TB of unstructured data as a start. Your systems brain tries to grasp the big picture and gets lost in trying to figure out the details. But well, after reading around, grappling, experimenting and reading a bit more, I think that learning ML is doable for us system dudes. You do not have to be a math genius (well, it helps if you are). But I will start with this blog of mine documenting the baby steps needed. I will use it as my reference and you can use it as yours if you find it useful.


Print a singly linked list in reverse!
· β˜• 2 min read · πŸ€– Naresh Mehta

Today’s topic is pretty simple. Let’s print a linked list in reverse. And it is a singly linked list meaning you can only traverse in one direction and not come back. You are only given a pointer to the head. So without further ado, below is the c++ code. Only the important parts are shown. Rest is left as an exercise for the reader to create a fully working program.


Backward Compatibility!
· β˜• 4 min read · πŸ€– Naresh Mehta

Backward Compatibility

The internet is littered with articles on backward compatibility and why it is important and rants of people who work/use 1970s systems on the same. Well the last sentence there was a pun but people do rant on not being able to use the PS2 games on PS4 and or not being able to use Lint with the new c++11 or c++14 features or sticking to an outdated kernel (2.6.36) and not being able to use the new virtual environment enhancements, etc. Finally, all of these rants boil down to, “Everything should be backward compatible and should not break existing systems”.


Basic use of Tuples C++11
· β˜• 2 min read · πŸ€– Naresh Mehta

Basic use of Tuples in C++11

Tuples are an amazing feature in C++. Tuples are specified inΒ C++11 standard (ISO/IEC 14882:2011), i.e. they are a new introduction in c++11. So if you are more used to traditionalΒ c++, tuples will come as a surprise for you. It happened to me as well and I am not that old (quite yet)! They are a great addition to generic programming and brings C++ to a whole new level of usability. Of course we have had ways to do exactly the same things that tuples does but now that it is a part of the standard language, it makes sense to use this feature instead of cooking something of our own. I see tuples as an important feature like dictionary in python (more or less). Tuples are amazing and you can feel the power when you start using them. Auto types and tuples make a great combination for very nice cool features previously rarely thought of (multiple return values from a function anyone). Anyways, I don’t see people really appreciating the flexibility being provided by our beloved language. Stefan Lavavej (@StefanTLavavej) maintaining the STL implementation, working at @microsoft, has a very nice talk in CPPCon 2016 that I recommend you watch. Check it out below. This is the one that got me interested in tuples.


Ranged Switch Case C++
· β˜• 2 min read · πŸ€– Naresh Mehta

Ranges in C++ Switch Case block

Today, we will do something really stupid! Yes, I am talking about the ranged switch case support that is available in C++. In all the commercial/hobby source code that I have seen, implemented and used, rarely have I come across the ranged switch case use. Most of the code when in need of ranges inside a switch case start using multiple case cascading or (the more niche programmers) resorting to nested if..else blocks!
So much so that when I told one of my co-workers that we can use ranges in C++ switch case, he started laughing (hysterically if I may add). Taken aback, I wanted to see if I have learned stuff wrong. So here it is, just to brush up your basic cpp knowledge and fall in love with it again! Below is the code in ideone ready for you to take for a spin.


Simple Downloader!
· β˜• 2 min read · πŸ€– Naresh Mehta

I come across this very nice siteΒ http://www.dwarkadheeshvastu.com/Β which has a collection of excellent MP3s (Devotional Music). I congratulate the maintainer of that site for the excellent collection of texts/mp3s in multiple languages. So the site is more or less static with mp3s arranged inside folders starting from 000.mp3 to the <lastsection>.mp3. And you want to download them all.

Layman way is to keep right clicking on each link and do save as. But we are lazy programmers. We will just give our job to the computer to increment the URL and download the file for us. This can very simply be done in a bash script. Below is a snippet. I will not go into explaining all the details, just that the script takes in 3 parameters (start of the count, end of count and the absolute URL of the folder). Run the script and get all the mp3s that you need. One can extend the script to pass in the kind of file we are interested in (like mp3, pdf, etc.). But that is left as a user exercise. The folder path can be got by looking at the HTML code (in case you are wondering how I got it).


Forgot your EXCEL Password?
· β˜• 2 min read · πŸ€– Naresh Mehta

Okay. It is a bit sneaky and I will not explain everything but if by any chance you are using Excel and are password protecting the sheets and if you forget what your password was, β€œYou are dead… ;)”. NOT REALLY! Use the following VBA script to recover the password. No need to download any softwares. Just press Alt+F11, put in the code and run it. It will soon pop up a box with the actual password which you can use to unlock.


SSHFS on Linux & Windows
· β˜• 2 min read · πŸ€– Naresh Mehta

SSHFS does come into play when connecting to a remote client and/or working on a remote server. I am pretty sure most of you are aware of how to do this. But if not, the below can help a lot with your development using your favorite tools. The problem is that on the remote servers is either not having root access, or updated and latest software and/or most of our new age tools might not work as expected (eg: try to run atom on it or sublimeText). Also using NX is pain… You can of course run Linux or X-Server on windows and get native X-forwarding but losing the SSH session will invalidate your window and you might have data loss. Worst of all, such X-sessions are not restored (on windows).