Pristine – ZSH Theme

A while back I posted about Amuse my prompt theme for ZSH targeting oh-my-zsh. Since this was a much appreciated theme, I would like to share another theme, Pristine, that I have created.

However, I recently switched to using Prezto. This is because it felt like a more minimalistic configuration framework for ZSH. I also wanted to get faster load times. I must say my experience has been quite good and I really like it. Obviously there are pros and cons but I digress.

Needless to say Pristine targets Prezto. It is influenced by and has a lot of similarities with Amuse. However, there are subtle changes that I feel make it more cleaner and simpler. These are the highlights of Pristine :

  1. It tells you which branch you are on if the current working directory is a git repository.
  2. It indicates the git status of the repository to highlight whether there are any changes by using a green tick (✔) for no changes or a red cross (✗) for uncommitted changes.
  3. It keeps the prompt where you type on a new line with a preceding $ sign, to make more space for typing commands.
  4. It displays both ruby & node versions in use currently on the right. I find this very useful since I often work with both.
  5. It also modifies the spell correction prompt offered by ZSH to highlight the spelling error more prominently.

Read More →

VN:F [1.9.22_1171]
Rating: 1.0/5 (1 vote cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Google open sources it’s machine learning system

I am a huge proponent of open source technologies and having worked predominantly in various web technologies in the course of my career, I mostly work exclusively with open source stacks.

In the recent past I have been very keen to try and wrap my head around Artificial Intelligence and more specifically Machine Learning, although I am still barely even scratching the surface of the nitty-gritty’s of the field, especially the mathematical underpinnings, this is still a huge deal!

Google open sourced it’s second generation machine learning system TensorFlow!

It is a production ready library which has support for running numerical computations using data flow graphs on multiple CPUs, GPUs or mobile devices! Data Flow graphs as explained here represent mathematical computations described using directed graphs where each node corresponds to a certain numerical computation whereas the edges connecting the nodes represent the data communicated between them.

The documentation looks really impressive, with lots of examples. I am really keen on trying something out with this in the near future.

Considering that this is open source, I strongly believe this will give rise to a lot of innovative & creative applications and from the looks of it bring down the entry barrier drastically of solving real-life problems where this can be applied and made use of to make intelligent systems!

The fact that it also provides portability to work on mobile devices sounds like a game changer that should definitely drive a lot of adoption within the machine learning community & we should see a lot of interesting applications leveraging mobile devices which are packed with loads of sensors collecting all kinds of data from our day to day life!

Source: TensorFlow

VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Grow your brain!

Learning is key in brain development. Of course what aspects and how much of brain function improve as a result depends on the mode / type / content & method of learning. But I am not here to talk about that. Now, this knowledge isn’t new information, we all know this already, and have seen it in good effect in children and hence we all know and understand the importance of education & sport for children.

However, I have long held a strong belief that this applies also to adults, perhaps in a slightly diminished capacity, but significant nevertheless. I recently came across this brilliant TED talk that talks about neurogenesis, i.e. a process in which the brain literally grows new neurons, which occurs in all of us! The talk goes into details of how this neurogenesis is responsible not only for improved brain function, but also has a connection to our moods, hence how we feel overall. This, obviously also establishes a connection to diseases such as depression and other similar ailments we suffer from in our day to day lives.

Now, the best part about this TED talk isn’t just that, but the fact that there are in fact ways in which we can improve neurogenesis and hence improve both our mood and brain function. And there are several things we can do which have an effect towards this, including our diet, excercise, sleep, etc. Watch the video for more details :

The take away for me from this video is that there is a strong connection between our moods & our overall mental health, i.e. neurogenesis. Hence, I believe, besides what is mentioned in the video, everything that has an impact towards our mood, both positive or negative, should have an equal impact on our overall mental well being.

Happiness literally means a better, healthier & smarter life.

VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Find huge files in linux

Switching to SSD’s for better performance and compromising on disk space can be a tough decision to make. Though nowadays with the prices of SSD’s going down, it is something that a lot of people are consciously doing.

However when you switch from a 500GB (or 1TB) hard disk to an, albeit super fast, 128GB SSD, you will inevitable (having spoilt by past experiences of having ample disk space) run into situations where you need to clean out large files taking space on your disk. Something I had run into myself about a year back when I made the switch myself on my macbook. Oddly enough this problem turned out to be significant enough that I had to seek out a way to quickly find out which were the top biggest files on my file system so I could get rid of them / move to an external hard disk.

Most linux systems ship with a nifty little utility du which displays disk usage statistics. It’s actually very good and fast, however by itself it didn’t quite meet my requirements where I really wanted to see the top few biggest files. So I fiddled with it in conjunction with a few other common linux utilities and I came up with this little shell script I call findhuge which, as the name suggests, helps me find huge files:

This script allows me to search the top _COUNT results (defaults to 10) of _TYPE (defaults to ‘f’, for files) in the _DIR (defaults to the current directory). Which gives me exactly what I need.

The shell script uses find to find files recursively in a directory and then passes that through du to get their sizes in a human readable format, then through sort to sort the results by size in reverse order and head to show only the top results from that list. Neat!

VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Google Code Jam 2014 Qualifiers

Google Code Jam has always been a competition I have cherished, simply because the problems they post are brilliant and the closest to reality as compared to problems of other competitions. They’re always fun to read, disect & solve, more often than not, the solutions are reasonably trivial (especially for the qualifiers) yet extremely subtle & deceptive.

Today I want to share the solutions of 3 problems I was able to solve, the code should pretty much speak for itself because none of it is very complex.

  1. Magic Trick

    This one was the easiest of all, more of a warmup I suppose. Here’s the solution :

  2. Cookie Clicker Alpha

    Based on Cookie Clicker game developed by Orteil, this one was slightly trickier, and required a little bit of math. I solved it with a recursive algorithm first, then optimized it into an iterative one to pass for the large input. Here’s my solution with both recursive and iterative parts :

  3. Deceitful War

    This one was really subtle, easy enough to understand but hard to implement. It took me a while to put my understanding of how much being deceitful at the game called War translated to my points. Here too I solved both the normal game War and Deceitful War recursively first (it’s just easier to think recursively thanks to Lisp), then translated those to their iterative counterparts. Here is my solution with both recursive & iterative parts :

  4. VN:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VN:F [1.9.22_1171]
    Rating: 0 (from 0 votes)

VIM Custom TabLine

Hi guys,

VIM allows has an option ‘tabline’ that one can use to configure how the tab line would look like. Back when I used to use gvim, I could very easily manipulate how the text on the tab looked like by setting the ‘guitablabel’ setting, however ‘tabline’ is not all that easy to configure.

Here is what I use now :

This is what it looks like : vim tabline

VN:F [1.9.22_1171]
Rating: 5.0/5 (2 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Creating Custom Scratch Buffers in VIM

The other day I wanted to open a scratch buffer to write some temporary code and the pass it on to a repl to test it out, the idea was that I could modify it as needed and resend it back to the repl and see the changes, helps to debug easily.

So I just wrote out this simple code here that allows me to launch a scratch buffer in different ways, but the difference is I can set various options for it while creating it. First lets have a look at the code :

Now this allows me to open a scratch buffer with various options, like I could call :Sedit ft=javascript and that would open a scratch buffer with filetype javascript (and hence show the right syntax highlighting). The cool part is all these options are set local to the buffer and can just be space separated to the command. The buffer will not be listed in :ls and after you :q it will be wiped out completely from vim. Couldn’t be any simpler!

VN:F [1.9.22_1171]
Rating: 5.0/5 (1 vote cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

VIM – Filter Quickfix List

If you are used to using the quickfix list in VIM there are times when you want to filter certain things out of the quickfix list to narrow it down to relevant results that you need. Rather than firing the quickfix command all over again with a refined expression, it is easier & often faster to simply remove items from the list. I wrote this simple vimscript to do just that.

Using the above now allows you to filter the quickfix list by calling :QFilter pattern. By default it filters the list to keep results matching the pattern but if you call it :QFilter! pattern. it will remove results that match the pattern.

VN:F [1.9.22_1171]
Rating: 5.0/5 (1 vote cast)
VN:F [1.9.22_1171]
Rating: +1 (from 1 vote)

VIM – Toggle Ruby Hash Syntax

Ruby 1.9 introduced a new json style ruby hash syntax. Although we can use this to define static hash objects and puts a limitation on the key we can use, it’s a fairly neat syntax nevertheless. However I work on several projects, both new and old and hence the new syntax is not always readily available.

To demonstrate the sheer power of regular expressions & VIM, here’s a tiny snippet that allows you to quickly toggle a ruby hash syntax from one form to other.

VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

VIM for Multiple Projects in separate Tmux windows

My development environment setup consists of several tools, however the 2 most used and essential tools that have a great impact on my workflow are tmux & vim. Since I often work on several projects, I find it best to work on different vim sessions in separate tmux windows.

However tmux by default only shows the name of the currently running process in the title and that can often lead to confusion as to which tmux window is which project. To solve this issue I came up with a very simple vim script that utilizes tmux’s powerful API to automatically rename the tmux window appropriately and hence make it incredibly easy for me to know which tmux window is for which project.

Here is the vimscript, that you can put anywhere within your ~/.vimrc :

Here’s a screenshot of the same :
VIM for multiple projects within tmux

VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)