Anacron like jobs at arbitrary intervals using dcron

A little while ago, I had to set up a backup script using cron. dcron is my favourite cron implementation.

I have been using dcron since a few years, and it has served me well. But this time, my requirement was a bit complicated.

What I wanted to do was: Run the backup script every two days.

Now, this may sound simple to achieve using any cron implementation. Fair enough, it can be done by specifying something like the following in a crontab:

0 8 */2 * *

The above syntax will execute the given script at 8 AM, every 2 days.

So, what's the catch?

Well, the catch is that this method has a huge limitation — which is — that it requires the computer to be running at the time specified, or the job will be missed.

I need to run the script on my personal computer, which isn't powered on all the time. So, this syntax was ruled out.

Continue Reading...

Aria2 and GNU Paste: The perfect team

I have been having internet speed problems lately (as always :P), which kept me from updating my Arch Linux system. Today I decided to go ahead and update the system anyway, only to find that the download speeds were excruciatingly slow. As always, whenever I need to update my system with a bad internet connection, I fall back to aria2.

Downloading from multiple servers with aria2

Somehow, I was getting decent speeds with concurrent outbound connections, so I decided to use multiple mirrors to download the packages. aria2 supports downloading a file from multiple sources (and protocols!) at the same time.

So, I decided to generate three download lists using three of my favourite mirrors. I first did:

# pacman -Su --print > mirror1.list

And, after editing pacman's mirror file: /etc/pacman.d/mirrorlist, I generated mirror2.list and mirror3.list in the same fashion.

The problem at hand

Now came the real problem. When using an input file with aria2 (as I was about to), aria2 expects all the sources for a file to be specified on the same line and separated using a <Tab> character.

So, I had three input files containing urls, and they needed to be merged linewise in the above mentioned fashion.

Continue Reading...

Get total number of commits for a repository using the GitHub API

I was trying to get the total number of commits for a repository using the GitHub API. After scouring over the documentation, I was unable to find a way to do that. Searching the web revealed nothing, as well.

So, I came up with the following *hackish* solution.

Note: I'll be using the following repository for illustration:

Obtaining hashes for the commits

We need the hashes of the first commit and the latest commit to get the total number of commits.

Hash of the first commit

Obtaining the hash of the first (initial) commit is tricky, as I couldn't find a way to do that through the API.

So, to do that you'll either have to visit the web interface of that repository on GitHub or clone that repository and find it through git log. The good thing is that under normal circumstances, the hash is unlikely to change, so you can save it and be done with it.

In our case, the hash of the first commit is:


Note: If you need to get the hash of the first commit regularly, then this post is of no use to you. As you can simply clone the repository everytime, and find the number of commits locally.

Continue Reading...

cmus - Get file size of currently playing song

This is a simple Bash script to show the file size of the song being currently played by cmus.

#!/usr/bin/env bash

# show size and filename
size=$(cmus-remote -Q | awk '/file/ {print $2}' | xargs du -h | awk '{print $1}')
name=$(cmus-remote -Q | awk '/file/ {print $2}' | xargs basename)

# zenity dialog
zenity --title=cmus-filesize --timeout=5 --info --text="[${size}] - ${name}"

Note: The script requires Zenity.

Save this file to a location of your choice, and then type the following at cmus' commandline:

bind -f common F2 shell /home/notfoss/bin/cmus-filesize

Change F2 with a key of your choice, and replace the path and filename accordingly.

Now, whenever you press the assigned key from within cmus, you will get something like:

cmus file size

Interesting Links - September 2013

World of FOSS:

Cool Stuff:

  • Use GNU Stow to manage your dotfiles. You can find a couple of different ways to achieve the same here.
  • Hermit is a new font oriented towards programmers. Don't like it? You can find some of the best fonts available for programming on this page.

Continue Reading...

New Domain

Just a quick heads up for all of the 5 people that visit my site (maybe more :P), I have migrated the site from to

Please update your bookmarks and RSS feed urls.

The previous domain will redirect to the new one for a while, so in a way nothing will change. But in any case, take action while the news is fresh, lest you forget ;)

Interesting Links - August 2013

Linux / FOSS:

  • Elementary OS "Luna" was released earlier this month. Elementary OS is an aesthetically pleasing derivative of Ubuntu, with a focus on a uniform look and feel. Seems Linux Mint has got competition ;)
  • Debian celebrated its 20th birthday.
  • An excellent interview with Ubuntu Founder — Mark Shuttleworth, which offers an insight into the motivation behind funding Ubuntu, and his vision for the future.
  • Vim 7.4 was released. It is the first stable version of Vim to come out in 3 years, after Vim 7.3 was released in 2010.


  • Lavabit — a popular email service among privacy advocates — was shut down by its founder Ladar Levison, in retaliation to unjust interferance by the USA government.
  • In case you haven't heard about this already — those who don't have a Facebook profile, might still have one!! This article explains, how Facebook creates shadow profiles of the people who don't have a Facebook account. The *best* part is that you cannot do anything about it...

Continue Reading...