Author Archives: thameera

Calsen beats Anand to become the World Chess Champion

BBC News:

Norwegian chess prodigy Magnus Carlsen has become the world champion, beating Indian title holder Viswanathan Anand.

Carlsen, 22, secured a draw to win the World Chess Championship in 10 games, with two left to play.

Carlsen won the match in Chennai, India, with a score of 6.5-3.5. The win means that Carlsen achieves the record of having the highest new rating of all time.

He could’ve easily become the youngest to secure the title, but you can’t challenge and get into a championship just like that. Congratulations, Carlson!

Update: Here’s a comprehensive list of games, their summaries and other stuff.

Jenkins gets out of hot water

The Jenkins guys seem to have had a rough day.

yesterday something strange has happen to many Jenkins repositories on GitHub (more then 50 Repos)…
Luca Milanesio seems have pushed to many many repositories without really changing anything – at least I have not seen anything changed.

But the folks at github have helped by restoring the state prior to the force push into a separate branch. Good old git reflog to the rescue.

Typically recovering a force push is straightforward:
1. git reflog > look at the SHA-1 before the forced push
2. git branch -f <name> <sha-1>

As far as I know, bare repos don’t have reflog enabled by default. They might have turned on core.logAllRefUpdates for all the repos at github by default.

Converting a video to an mp3 via terminal

The days we had to remember dozens of ffmpeg flags has long gone. avconv is easy as easy could be.

sudo apt-get install ffmpeg libavcodec-extra-53 libav-tools

To convert video.mp4 to song.mp3, all you need to do is,

avconv -i video.mp4 audio.mp3

It’s so easy it just hurts. :shock:

You can of course give avconv a dozen flags to tune the output to your will, but you just need a simple conversion 90% of the time.


K. Mandla writes on false:

In fact, it’s anything but helpful. It won’t take help flags. It does what it’s supposed to do, but does it unsuccessfully, every time.

Even the man page tells you that. What’s false? Every time, that’s what. Hardly helpful. Hardly useful. Just … false.

It must be really hard when people expect you to be unsuccessful. :neutral:

ACTUAL Vim in Sublime Text

ActualVim is a fucking brilliant project:

The goal is to use a hidden Vim instance to accurately manipulate a Sublime Text buffer as though you were editing the text directly in Vim. This has been accomplished.

It’s not simply a terminal emulator embedded in a text editor. Sublime is still in control of the text buffer. You will be able to use the entire native Sublime interface while in INSERT mode, including plugins.

IMNSHO, all Vim emulators suck. This freak of a project will surely make you feel you’re at home. Heck, you can use your complete Vim setup with this.

The only downside is (you saw this coming :twisted:), it does not work on Windows. On Linux or OS X you can simply use Vim itself, but the Windows version is ugly and Sublime is the best alternative out there. Perhaps I’m asking for too much. :|

Anywho, this is wonderful news for Linux/OS X Sublime Text users out there.

Reading pdf files from the terminal with less

The good old less command can be used to open more than plain text files. All you need is to set the LESSPIPE environment variable to pipe the /usr/bin/lesspipe script in your .bashrc or .zshrc file. In most systems, the lesspipe script is pre-installed. Otherwise you can download it from here.

export LESSOPEN='|/usr/bin/lesspipe %s'

Now simply open your pdf files with less.

less abc.pdf

Besides from pdf files you can pipe in compressed files (like tar.gz, zip, rar, etc), ISO files and even .doc files. But who uses .doc files anyway? :mrgreen:

c for cat

An year-old tweet from @paul_irish:


Countdown timer shell script

I made a small countdown script for the shell. It goes as follows:

Some tricks used in the script include:

  1. echo -ne "blah blah \r" was used to write in the same line over and over
  2. That 19800 is the time difference from GMT 0.0 in seconds. In Sri Lanka, it’s 5.30 hrs. Yes, we’re dealing with epoch time here, but still trying to figure out why we need to offset the time difference. :???:
  3. notify-send sends a desktop notification
  4. zenity --info pops up a message box

You can also add a sound to play with mplayer.

Resuming a failed scp transfer

Every now and then I scp some large files and the connection drops half way through. :neutral: Thanks to rsync it’s pretty easy to resume the transfer.

rsync --partial --progress --rsh=ssh user@ip:remotepath localpath


--partial – this lets rsync know that it should keep the already downloaded partial files and download only the remainder
--progress – show the progress of the transfer
--rsh=ssh – use the ssh protocol
user@ip – remote machine. This might be the alias you’ve given it in your ssh config file.
remotepath – path to the file in the remote machine
localpath – path to the partially-downloaded local file

ShellCheck – static analyzer for shell scripts

Just came across ShellCheck. From its About page:

ShellCheck is a static analysis and linting tool for sh/bash scripts. It’s mainly focused on handling typical beginner and intermediate level syntax errors and pitfalls where the shell just gives a cryptic error message or strange behavior, but it also reports on a few more advanced issues where corner cases can cause delayed failures.

Interestingly, the tool’s completely written with Haskell. You can copy/paste the script on the site, or even install it so you can conveniently check shell scripts every now and then. You need cabal to have installed to compile the source. On Debian, you can install the package haskell-platform to install cabal.