Awesome version control visualization with gource

NOTE: This technical article was published long time ago. It may be not up to date. Please check for the newest versions of mentioned software. Also I am not able to provide technical support anymore. Thank you for your understanding.

After a big project it is often cool to release “making of” video, presenting collaborative effort of people who contributed to the success. In case of designers, filmmakers or other “artistic” types it is quite easy to present their work in progress. But what about developers? They always sit at their desks and type on their keyboards, it looks the same at the beginning and at the end of the project – nothing spectacular.

A year ago, when we finished new version of www.k2.pl website I wanted to show – in light and comprehensive way – the vast amount of awesome work performed by my team. This is where gource came to the rescue. Gource is an awesome tool to visualize work on the codebase in form of colorful video. It takes information about the code structure, contributors and timing from logs of revision control tools (Git, Mercurial, SVN and Bazaar are supported). Code is presented as branches and leaves, being worked on by developer icons flying around. As the tool is highly parameterizable, it is easy to add colors, logos, backgrounds, etc., show or hide specific information.

You may easily play with the tool by yourself, so as a quick tutorial, here are the commands to generate simple video. You need gource itself and the FFmpeg library. These commands are Windows specific (as my Windows box is more powerful), but they’re easy to port to Linux. Try to play with the parameters by yourself.

First, of course, clone your repository to specific location. Then, run this command to create PPM file with the video (PPM file is a series of bitmap images, so expect this file to be huge):

"c:\program files (x86)\gource\gource.exe" -s 0.5 --hide filenames -1280x720 -o gource.ppm

Then, you need to convert the PPM file to compressed video:

C:\ffmpeg\bin\ffmpeg -y -r 60 -f image2pipe -vcodec ppm -i gource.ppm -vcodec libx264 -preset ultrafast -crf 1 -threads 0 -bf 0 gource.x264.avi

And voila, you have a nice video:

Good luck with preparing your own awesome visualizations 🙂

Monitoring your services with Papertrail and Heroku

NOTE: This technical article was published long time ago. It may be not up to date. Please check for the newest versions of mentioned software. Also I am not able to provide technical support anymore. Thank you for your understanding.

Recently I have noticed some problems with my Internet connection, sometimes it was completely unavailable. I concluded that I need some precise information about the outages, so I can talk to my ISP. As at the same time I learned about the Paper Trail service, I decided to use it in my setup. Other thing, that I wanted to learn was Heroku, so I gave it a try. Both services have some free tier, which is perfectly sufficient for my needs.

The architecture of my solution is as follows: I have local server running on Raspberry Pi (as mentioned in one of the previous posts about the online radio streaming). On this server, I have a Python script, running as a cron job every 10 minutes. This script sends simple log message to my Papertrail account. Then, I have another Python script, that runs every 10 minutes as a scheduled job on Heroku. This script checks, if there are recent “heartbeat” logs on Papertrail and if not – sends an e-mail message. You can download the source code of both scripts from the github repository.

Continue…

Sleep better by making your display adapt to the time of the day

NOTE: This technical article was published long time ago. It may be not up to date. Please check for the newest versions of mentioned software. Also I am not able to provide technical support anymore. Thank you for your understanding.

Some research show, that sleep problems are often caused by usage of computers or other electronic devices before going to sleep [1]. I am one of these people, who like (or have to) work late in night. About a year ago I found piece of software called f.lux, which runs in the background and makes your display to adapt to the time of the day. It takes your location and current date and calculates the time of the sunset. It then gradually adjusts your display colors’ temperature to be warmer – thus helping you get better sleep or not being blinded when you turn on your display at night.

The f.lux software is available for free for Windows, Linux, Mac and jaibroken iOS devices from it’s website: http://stereopsis.com/flux/.

[1] http://stereopsis.com/flux/research.html

f.lux configuration dialog

f.lux configuration dialog

How to force Gmail to check your POP3 account as often as possible

NOTE: This technical article was published long time ago. It may be not up to date. Please check for the newest versions of mentioned software. Also I am not able to provide technical support anymore. Thank you for your understanding.

One, of the killer features of Gmail (in my opinion) is ability to collect e-mails from external POP3 accounts and send messages via external SMTP servers. This way, one can use Gmail as slick, web based e-mail client to virtually any account in any domain, with the benefit of IMAP access, labels, autoresponders, spam filtering, etc.

Unfortunately, Gmail uses “intelligent” algorithm to figure out, how often it should collect e-mail messages from your POP3 server. It is based on the amount of mail you get – if you receive merely few messages per day, Gmail will check the server twice every hour. In extreme situation it means 29-minute delay in delivering the message that you are waiting for – not very convenient lag, hard to accept in the 21st century. If you get your e-mails often, Gmail is going to check your account every five minutes or so.

So, how to get your account checked every few minutes (= almost no delay in delivery of your important messages)? Lure Gmail into thinking, that you get maaany important emails every few minutes. You can accomplish it by simple Python script, that you should run on your server (i.e. Raspberry Pi with Raspbian, that you can run in your home). (Click “Continue…”)

Continue…

Multitail – monitor multiple log files with tail on steroids

NOTE: This technical article was published long time ago. It may be not up to date. Please check for the newest versions of mentioned software. Also I am not able to provide technical support anymore. Thank you for your understanding.

Every developer is familiar with tail – tool used to display the last lines – or tail – of the file. Of course most popular usage of this command is:

tail -f /var/log/uwsgi.log

…which displays continuously updates to the file. Every time new line is appended (i.e. to the log file), it is also printed to the screen. It is useful, when one wants to monitor log files in the real time to see the progress of some action or to look for errors in the application.

Recently, I had to monitor four application servers at once. At every one of them there was the same application. To monitor logs, I had to open four ssh sessions and then run four tail commands. I had to switch to such log monitoring once every few hours, so it started to be tiring. After short search, I found the most useful tool since tail – multitail. It allows you to tail multiple files at once – in many different configurations. Multitail not only is capable of displaying the log files, but also filtering them, adding some lines, etc. Just look at the list of the features.

So with multitail, monitoring four logfiles on remote machines is as easy as:

krzysztofr_dev@devel8:~$ multitail -s 2 \
 -l "ssh pr_app1 tail -f /var/log/uwsgi.log" \
 -l "ssh pr_app2 tail -f /var/log/uwsgi.log" \
 -l "ssh pr_app3 tail -f /var/log/uwsgi.log" \
 -l "ssh pr_app4 tail -f /var/log/uwsgi.log"

(where pr_app[1-4] are different hosts, defined in my .ssh/config file and “\” denotes line break, for easier reading).

Result is very similar to this:

Multitail example.

How to make your own automatic radio player with Raspberry Pi

NOTE: This technical article was published long time ago. It may be not up to date. Please check for the newest versions of mentioned software. Also I am not able to provide technical support anymore. Thank you for your understanding.

In this article I will share my experience with turning the Raspberry Pi and a pair of cheap speakers into an automatic radio player. I provide some tips on configuring the software, as well as code that you will need.

Continue…

Securing online competitions

NOTE: This technical article was published long time ago. It may be not up to date. Please check for the newest versions of mentioned software. Also I am not able to provide technical support anymore. Thank you for your understanding.

In summer 2011 issue of the 2600: The Hacker Quarterly magazine I published the article titled “Securing online competitons”. It is based on my experience and features the case study of one of the interesting cases.

Click “Continue…” for the full text of the article.

Continue…

Getting started with PHP templating

NOTE: This technical article was published long time ago. It may be not up to date. Please check for the newest versions of mentioned software. Also I am not able to provide technical support anymore. Thank you for your understanding.

Recently in Smashing Magazine I published the article about templating in the PHP:

In this article, we’ll cover how to separate the view of your PHP application from its other components. We’ll look at why using such an architecture is useful and what tools we can use to accomplish this. Here’s what we’ll cover:

  1. Learn some basic MVC concepts,
  2. Review some popular templating libraries,
  3. Play around with a small custom-made view class.
  4. Explore the basics of using the Twig library.

Click here to read the article.

Sample code for the article is available as a mercurial repository.