geek is sexy (?)

sexy geeks are just good looking guys with glasses

0 notes

egrep in all revisions with mercurial

I am new to Mercurial and today I had to search a string through all my older revisions of the code. I checked out if this was possible on bitbucket but apparently they don’t offer the option to search through code yet. They let you browse any given revision though, which is very useful.

So this is what I quickly came up with. I ran a simple shell loop on my terminal that checks out all the revisions and runs an egrep into each one, then logs the results to a file.

Here is the bash code:

hg log | grep changeset | awk -F'   ' '{print $2}' | awk -F':' '{print $1}' | while read rev ; do 
   echo "Revision: " $rev 
   hg update --rev $rev 
   egrep -r "yourstring" . 
done >> /tmp/rev.log

To restore the latest revision just run “hg up”.

I am sure there was a better way to do it but this worked out just fine for me and I wanted to share. Please feel free to comment!

1 note

Git Time Lapse

I am a big fan of time lapse photography so one day I wondered whether it could be used in web development.

I do a lot of prototyping and I thought it would be nice to have a video that would show the evolution of the product I am working on. I could show the video to my clients and I think it could also give me insights regarding how and why I made some decisions.

It could be simple script that would look into a git repo commit history and take screenshots of a given URL for example.

A couple of days ago I decided to write something in python using selenium for the screenshots and the gitpython library to access the git repo.

The code is on my github profile: https://github.com/johnlucas/gittimelapse

I ran the script on one of my web projects then I used all the generated sreenshots to make the slideshow video below with iPhoto on mac.

The ultimate idea is to generate the video automatically, perhaps using the opencv library.  I would also like to overlay the video with a timeline showing git comments and dates.

I’ve tried the script with a few rails apps. It works well if there are not too many significant changes to the code base structure or db structure. It should work with any web apps though, as long as the browser reloads the repo automatically.

Please feel free to try and fork the code and please please let me know any comments or suggestions!

Filed under development git python prototyping

0 notes

What makes you sexy: removing a file from a terminal…

A few weeks ago I had to pass my girlfriend a couple of pictures I had stored onto my iMac. She gave me her cute Hippo 1GB pen drive and said: “You can delete everything”. I tried to do so but there was one file that Finder wouldn’t be able to delete. “This file is in use” it said.

She saw the error on the screen: “I hate that file, there is no way I can delete it!”.

I gave her a Chuck Norris look: “There is always a way…”.

I opened the terminal and ran an rm <filename>. It failed. I ran a sudo rm <filename>. Success. With nonchalance I told her: “It’s gone now. ;-)”

She looked at me like I was a rock star that just played a crazy solo and sang cute at the same time.

Fifteen seconds on the terminal and she was my groupie.

All the real geeks that are reading this will know how easy it is to run those two simple commands but you need to understand that she saw the terminal like the matrix code.

I wrote this article to encourage other geek fellows to do the same, impress your girlfriends/potential girlfriends with some simple geeky tricks, they will look at you with different eyes.

Be brief though, and do something they will understand (i.e. removing a file). Don’t show the unlucky lady sorting algorithms, like I did once, that girl thought I was crazy, and nerd.

I can imagine one can use simple geeky tricks for other purposes than picking up girls but, to be honest, I can’t think of any. It is not my fault: I am italian! :-)

Good luck my geeky friends!