Monthly Archives: September 2012

Chocolatey brings package management to Windows

Chocolatey is the topic in the town these days. When it comes to installing software, Windows is far behind most Linux distributions. Chocolatey is a package manager like apt-get on Debian and Ubuntu. Install it by entering the command

@powershell -NoProfile -ExecutionPolicy unrestricted -Command “iex ((new-object net.webclient).DownloadString(‘http://bit.ly/psChocInstall’))” && SET PATH=%PATH%;%systemdrive%chocolateybin

(yes, in a Windows command prompt) and you’re good to go. The list of available packages can be found here. There’s no huge list of apps like in apt-get as yet though. If you want to install, say, expresso, just type

cinst expresso

in the command prompt. It’s said Chocolatey works in Cygwin as well, but I’m yet to try that out.

Serj Tankian on politics

System of a Down is famous for its themes on war and politics. Huffington Post has a short interview with the band’s lead singer Serj Tankian on, well, politics. While expressing his favor on Obama over Romney, Serj expresses that he has no intention to run for the office.

“I hate injustice, and I can’t help but speak against it,” he says. “But I don’t want to get involved in politics. I have a more direct avenue to expression as an artist than I ever would as a politician.”

Who was my first parent? [Git]

A co-worker of mine had the following tree structure in his git repository and he wanted to get rid of the 2abaf35 and 607f016 commits. The solution is a simple

git reset --hard e5e67d0


But, for the sake of fun, I wanted to do it without referring to a SHA value. The HEAD commit has two parents e5e67d0 and 2abaf35. HEAD^ will refer to the first parent and HEAD^2 will refer to the second parent. But how do we know which parent is the first?

According to charon at #git on freenode, HEAD at the time of invoking the merge will always be the first parent. This is the left-most (straight line) branch. The remaining commits will be the remaining parents, in the order you specify. So, in this case,

git reset --hard HEAD^

would have achieved the same feat.

Printing is not supported in this printer

This was posted in r/linux three days back. Turns out it’s actually been written by a human. And someone has spoiled the fun by sending a patch to gnome with the correct version of the error message: PostScript is not supported on this printer. That makes sense anyway.

Also discussed in the Comments section is the famous error message “Error: Success”. Apparently this mistake is common due to the fact that errors are communicated via a global errorno variable [source].

if (some_c_function() < 0) {
    some_other_c_function();
    print_error(errno);
}

This can be fixed without much hassle though.

csh woes

One thing I hate about the C Shell is the lack of function support. You’re left with aliases but they don’t work out all the time.

The other I wanted to add the git branch you’re on to the csh (tcsh, in fact) prompt. I tried out adding the following to the .cshrc:

alias GIT_BRANCH_CMD "sh -c 'git branch --no-color 2> /dev/null' | sed -e '/^[^*]/d' -e 's/* (.*)/(1)/'"
alias cd 'chdir !*;set prompt=`whoami`@`hostname`": %~"`GIT_BRANCH_CMD`" > "'
cd ~

But it only works when you cd to the directory. Out of luck when you git checkout, etc. To my knowledge csh has no advantage over bash, so the lesson is to use bash whenever possible.

Elevating privileges temporarily with setuid permission (Unix)

You may have noticed that apart from the read (r), write (w) and executable (x) permissions in Unix, there’s an ‘s’ permission as well. This is called the setuid permission. If you have access to an setuid-enabled file, then you can execute that file with admin privileges even though you’re an unprivileged user. So, s means that the file is both executable and has root privileges.

Unix setuid permission

It’s possible to add enable setuid permission just as you do with any other permission.

chmod u+s filename

Be wary though, mistakenly assigned setuid can cause havoc if some stupid user takes advantage of the root privileges.

Using Git to track law changes

Hey look, it’s not just the code changes we can track with Git! Randomly came across this article from The H Open today. BundesGit uses Git to track changes in the German federal law. This is a pretty cool use for something that is intended to be a source code management system. Tracking something that may change every now and then, so you can keep track of what changed. Laws of a country, company policies, documentation; the possibilities are endless.

Automated emails

One day I boasted to my little sis that my inbox receives 20+ emails a day. She was amazed.

Today I came home after three days away from the computer and had to deal with 50+ unread mails. The sad truth is that 95% of those were automated emails. 16 of them were triggered by ifttt recipes, 5 were from goodreads, 4 from twitter. The rest were from StackOverflow, WordPress, Evernote forums, LinkedIn, and so on. Only two mails had been sent by real people, and out of the two, one was a forward. Is this pathetic? Maybe. Maybe not.

2 step verification for Google

If you haven’t activated 2-step verification for Google / Gmail already, it’s high time you did. 2-step verification essentially requires you to provide two proofs to show that you are actually you. After getting the password correct, you’ll get an SMS with a verification code which you have to enter to sign in. In case the phone is lost, no cellular coverage, etc you can add recovery options.

Why bother? Because you never know when your account’s gonna get compromised, and when you do, you’d wish you were dead.