Monthly Archives: October 2013

Github and Government

Git’s being used to do many more things besides version controlling code. I once wrote about tracking laws with git in Germany.

Github has introduced government.github.com. From their blog post:

Governments at all levels have been using GitHub for some time now to build better, more accessible websites, publish laws and data, and even collaborate on policies themselves.

Today we’re proud to announced the launch of government.github.com, a website dedicated to showcasing the amazing efforts of public servants and civic hackers around the globe.

Open data projects in github isn’t new. Concepts like forking your city shows the possibilities are boundless.

Random limerick

A preoccupied vegan named Hugh
picked up the wrong sandwich to chew.
He took a big bite
before spitting, in fright,
“OMG, WTF, BBQ!”

pkill script for cygwin

pkill is a basic necessity of life. For cygwin, this comes in the package procps which is not available for x64. You can of course ps and grep then awk but who has the time.

This small script from cygwin mailing list archives to the rescue:

#!/bin/sh
# pkill
# be VERY careful with parameter $1
case $1 in
'' )
cat "$0"
;;
* )
for pid in $( ps -aW | grep -i $1 | awk '{ print $4 }' );
do tskill $pid /V;
done
;;
esac
view raw pkill hosted with ❤ by GitHub

tskill is actually a kill equivalent in the Windows world.

Kasparov to run for president

From chess.com:

On Monday night in Tallinn (Estonia) Garry Kasparov announced his candidacy for the 2014 FIDE Presidential Elections. The 13th World Champion aims to “revitalize FIDE with a focus on serving the national federations and raising the commercial profile of chess worldwide.”

They also have an exclusive interview with Kasparov about the decision.

The current president, Kirsan Ilyumzhinov, has been on the position since 1995.

Ghost is here

Ghost, the much awaited blogging platform, is finally here. You need to sign up to download.

It only took me 5 minutes to download and have Ghost up and running. You download the file, run an npm install (yes, it’s built on node.js), run sudo npm start and bang! Ghost is ready. The interface is minimal and clean, you can write with markdown, and there’s a marketplace for themes. And there are guides on deploying Ghost on various platforms like Amazon EC2, Digital Ocean and Azure.

They are planning to run a hosted Ghost platform as well (like they do at wordpress.com for WordPress), and they’ll be rolling it out in the coming weeks.

Note that Ghost needs a node.js server running so you can’t host it like a static site in places like Dropbox or with most shared hosting providers. But you can use an Amazon Micro EC2 instance for free for one year. The database used is SQLite, so it won’t be practical to run this on Heroku.

print statement for C++

print-stmt is a Python-like print statement for C++. It’s damn easy to add it to the project:

The easiest way to use this is to clone this repo and copy the file print.h into your project. Then simply

#include "print.h"

at the top of the file, but after the system #includes.

This is pretty handy. Some example features:

  • bool prints ‘true’ or ‘false’
  • A type that defines a member function called c_str() is converted to a string by calling this function.
  • A type that has a begin() member function that returns in iterator but does not have a c_str() member function is printed like a list, e.g. [“one”, “two”].

Connecting to mobile broadband from a terminal

In Linux, connecting to internet using a mobile broadband connection (i.e., a dongle) is fairly easy. If your distro has nm-applet installed (like most modern distros do) all you need is to create a new network connection and choose your country and network provider.

But how do you connect with a dongle when you don’t have a GUI? azeemigi’s blog has the solution. I’m reproducing it here just for the sake of my own future reference.

First determine the name of your broadband connection using the command nmcli -p con You will get the list of network interfaces in your computer and among them might be a row corresponding to your dongle. It’s easily distinguishable. In my case it was,

~ ยป nmcli -p con
 =============================================================================
                                                   Connection list
==============================================================================
NAME                      UUID                                   TYPE         
------------------------------------------------------------------------------
Wired connection 1        cbd369e1-b2fa-46a6-83b1-fbfdc9d28e0f   802-3-ethernet
Dialog GSM Postpaid       bb06d9f7-772c-4b4b-851a-4564503c3798   gsm       

Obviously it’s the last row.

Now download the following gist and copy/paste the name and the UUID of the connection in the relevant lines.

It goes without saying that you need to make the script executable with chmod +x mbb and add to a location in your $PATH.

Now you can connect to the internet with mbb start, disconnect with mbb stop and check the status with mbb status.

4b825dc642cb6eb9a060e54bf8d69288fbee4904

4b825dc642cb6eb9a060e54bf8d69288fbee4904 is a special hash value in git which denotes an empty tree. And it does not change from repo to repo. This opens way to some neat tricks, but how the hell would one remember this value? You don’t need to.

Colin Schimmelfing:

In both of the links that mentioned the special hash, it looks like there is another way to find the magic value, a little faster:

> git hash-object -t tree –stdin < /dev/null
4b825dc642cb6eb9a060e54bf8d69288fbee4904

Thus you get the hash of the ‘null’ tree.

The author of the post mentions about changing/diff-ing the first commit using this, but remember that since git 1.7.12 or so you have this awesome –root flag for git-rebase which does wonders in this particularly intimidating situation.

So, if you want to amend the initial commit or add one after some commits (humans forget), you can just:

git rebase -i –root

Now just do whatever you want in the editor window that pops up. Anything’s possible with git-rebase.

Installing Sinhala Unicode in Crunchbang Linux

Being debian-based, the usual commands can be used to install Sinhala Unicode in Crunchbang Linux. Tested with #! Waldorf.

  1. sudo apt-get install ttf-sinhala-lklug ibus im-switch ibus-m17n m17n-db m17n-contrib
  2. rm -f ~/.xinput.d/* ; im-switch -z all_ALL -s ibus
  3. Logout and login again.
  4. ibus-setup
  5. Choose the Wijesekare layout from the Input Method tab and close

Now you can switch between English and Sinhala using the key combination Ctrl + Space.

Upgrading to thunar 1.6.2 in crunchbang

I switched to CrunchBang (#!) today. The debian-based distro is fast and everything installed effortlessly. Except I didn’t like thunar, the default file manager. Some googling revealed that despite #! comes with thunar 1.2.3, the 1.6 version is available with lots of new features including tab support. After some messing around, here’s how I installed thunar 1.6.2.

Setup siduction keyring:

wget http://packages.siduction.org/base/pool/main/s/siduction-archive-keyring/siduction-archive-keyring_2013.03.29_all.deb
dpkg -i siduction-archive-keyring_2013.03.29_all.deb
rm siduction-archive-keyring_2013.03.29_all.deb

Add this line to /etc/apt/sources.list:

deb http://ftp.spline.de/pub/siduction/xfcenext unstable main

Add the following to /etc/apt/preferences:

Package: thunar libthunarx-2-0 thunar-data
Pin: origin ftp.spline.de
Pin-Priority: 1200

And finally,

sudo apt-get update
sudo apt-get install thunar

The new thunar looks much better. I might try this for a few days and consider moving to nautilus only as a last resort.