Vinit Kumar

Blog about Web & Programming

Instagram

© 2014. Vinit Kumar All rights reserved.

Clean Up Your Mac From Other Files

screenshot

Sometimes, your mac is filled up with files and you can't seem to understand what really is taking much space. Here is how you can find out.

  • First of all find disk usage and save it to a log file. Also, find all big files that are there. Grepping using 'G' would find all files that are in GB.

Also, save the second list to another file so that we are only doing it once.

du -h > ~/space.log
cat ~/space.log | awk '{print $1}' | grep 'G' >  ~/highspace.log

Next, open a split window and do

cat ~/highspace.log

And Now, start finding the ones which are big one by one.

Let's say one of the entry was 5.6G, Let's find which one was it.

du -h | grep '5.6G'
#which outputs
5.6 ./Document/Movie.avi

Now, if you feel the file is not needed and you want to delete it. Do the following:

sudo rm -rf Documents/Movie.avi

Voila! Repeat this process and remove all files and directories that you no longer need.

Disclaimer:

Do it very patiently and backup everything that's important. This guide is for very advanced users and you should only do it if you know what you are doing. I am not responsible for any data loss. Do it at your own risk.

GPS Tracking on Android

Like everybody else, I have an Android phone too. If you are a developer you must have noticed a file called as GPS.LOG. It is the one file which has all your GPS logs in it. This weekend I spend couple of hours hacking with it. He is the outcome.

How you get tracked

First of all, connect your Android device to your computer and copy the gps.log file into your desktop:

cp /Volumes/NO\ NAME/GPS.LOG ~/projects/gps.log

Now, we need to find the good data that contain gps coordinates: sh cat ~/projects/gps.log | grep 'position' > ~/cleangps.log

The cleangps.log file contains only data that has coordinates on it.

Now, create a log file that only contains coordinates:

cat ~/cleangps.log | awk '{print $3, $4}' > ~/gpscord.log
# notice the new file is nothing but values seperated by commas, hence write them as csv
cat ~/gpscord.log > ~/gps.csv

This csv file is the basis we use to find that location the GPS log was taken.

Prepare virtualenv and install googlemaps:

mkvirtualenv maps
pip install -U googlemaps

Also, follow the clear instructions at https://github.com/googlemaps/google-maps-services-python#api-keys to find your API key.

Here is the python file track.py that would find what these coordinate means and how they related to your daily life and place you are frequent to.

#! /usr/bin/python
import googlemaps
import csv

gmaps_client = googlemaps.Client(key='<Your Server Key Here>')

with open('~/gps.csv') as csvfile:
    gps = csv.reader(csvfile, delimiter=',')
    for row in gps:
        lat = float(row[0])
        longit = float(row[1])
        reverse_geocode_result = gmaps_client.reverse_geocode((lat, longit))
        formatted_address = reverse_geocode_result[0]['formatted_address']
        print row[0], row[1], formatted_address
        print "=" * 150

Run this file in your terminal by and check out the output, you will get freaked out for some moment.

python track.py

How it went?

Hello People!

It has indeed been very long since I last wrote a blog post. It sure feels good to start it again. Firstly, if you enjoy my writing, I am sorry for this big gap. I was very busy in writing code at my work.

Here are some important updates about what happened:

  • I got married! Yay :) I got married in December with my lovely girlfriend. It has been pretty amazing last three months with her.
  • I wrote various features for my product and there are more than 20k users using those features right now and the feedback has been quite good actually.
  • I write less code these days and spend more time thinking. I think it is better this way. I felt burnout with my previous lifestyle. Now, I wait to write code every morning.
  • I feel less annoyed with stupidity around me and have a better coping mechanism.

I have decided to be more consistent with my reading habits. I hope to be more sincere this time. That's it for now. Will write another post soon.

Better Time Management At Work

Time management is a key quality of any successful person. I have been working pretty hard these days to improve me efficiency. Today, I have decided to follow this pattern while at work.

Here is the breakdown. Let's assume the net hour spent at work is 8.

  • 50% Time (4 hrs) - Writing Code.
  • 5% Time (24 min) - Documentation of the Code I wrote.
  • 5% time (24 min) - Writing test on the Code I wrote.
  • 10% time (48 min) - QA and testing the work I produced.
  • 20% time (96 min) - Planning and Studying about the topic I need to work on.
  • 5% Time (24 mins) - Working with colleagues and helping out in case they need any assistance.

I felt the need to this timetable because it is really necessary to control the time when you are on tight deadlines. I like giving my all to the work and definitely have very limited time to execute that. So only if my planning and time management is solid I would be able to produce quality work on time.

I will produce a analysis of how this goes and how much success I achieve using this methodology. Also, today I have completed my 41 day streak at GitHub.

On Writing Good Code

Whether you are working for a big software company or a small sized startup, writing good code is pretty much critical to your success. But the catch is it is not very easy to achieve without proper motivation from your side.

I have been coding professionally for almost 4 years now. First two years were as a freelancer and I mostly followed Get Things Done mode during that time. It was okay then because it was mostly a one time gig and once done you didn't had to do anything with it. Though I never wrote really bad code even at that time but the amount of maturity and knowledge required to write code that is maintainable, DRY and has some documentation was clearly not there.

While I joined my first company back in 2013, I really struggled against my bad habits. I was able to solve tough technical problems as problem solving is always close to my heart but there were serious issues with my code quality. Sometimes there was some indentation issue and something there were some code repetition. I was lucky to have my Mentor "Ruben" to closely look at my code and review it sharply and give his most honest feedback. Upon pondering about the review I realized most of the issues were coming because a certain amount of thinking and carefulness that was missing from my workflow. I didn't had my editor configured properly. Mix of tabs and spaces will obviously come back to bite you and code will look ugly on browser even though it looked fine on your editor. (Sublime Text, I am looking at you).

Now, after almost an year later I am a improved and mature programmer than what I was at this point of time last year. So what changed?

Here is a short summary of things I did in order to get better at writing code:

  • I started reading classic books on programming. Understanding programming and computer science is pretty much vital to your growth as a software developer. Dreaming about making big in this field without having solid basics is a fools errand.
  • Read a lot of good code. Discuss about it, blog about it and finally incorporate those into your own code. This is pretty much most important to improve the code you are writing. I started reading a lot of good code, on an average of 1 hour daily. With loads of Open Source projects available on Github and bitbucket it is pretty easy to do so.
  • Follow strict mode in almost every language your code on. Use Pep-8, JSHINT, CSSLint, Grunt. This might be painful at beginning but it would cover a lot of ground that you might not know as you are not an experienced developer.
  • Learn and use Travis CI and Jenkins system that would automate a lot of these things in your code.
  • Write a lot of code and open source it. Also, contribute to a good number of OSS projects. I have done a lot of this in the past year and believe me it has really helped in improving.
  • Read the f**king documentation - This is kind of most important if you want to really use the power the language or the framework provides. Otherwise, you will keep writing shitty code because you were never aware better way exists.

  • Use version control- Version control gives you an opportunity to look at your code before committing. Use this powerful feature. Always review your code before your commit. Always review a pull request and merge.