Wednesday, August 26, 2009

project announcement: bingcode on Google Code:

I've started a new open source project on Google Code called bingcode. It is a collection of python scripts that I've created. Nothing spectacular, just thought I'd start getting some stuff out there.

The first python script committed to bingcode is It is a simple utitily script to search through a list of files with a list of words. It's still in a very basic form. It simply prints out the list. I will improve the output in the next commits, but I thought it was best to get something out there.

Please leave any comments and feedback.

PS. It is called bingcode because that is my name. I've been using the name Bing longer than Microsoft. So there.

Monday, August 24, 2009

how to strip trailing characters in Python

Oddly enough, you use the rstrip command. :)

Simply import the string module:

import string

Suppose you have a variable oldstring that has trailing spaces, then do this to the string:

newstring = string.rstrip( oldstring, ' ' )


Monday, August 17, 2009

how to get information about a video file using ffmpeg

For ffmpeg, it's simple and easy. Simply:

ffmpeg -i yourvideo.avi

and it will print out some basic information about your video like such:

FFmpeg version SVN-r18866, Copyright (c) 2000-2009 Fabrice Bellard, et al.
configuration: --enable-nonfree --enable-libfaac
libavutil 50. 3. 0 / 50. 3. 0
libavcodec 52.29. 0 / 52.29. 0
libavformat 52.32. 0 / 52.32. 0
libavdevice 52. 2. 0 / 52. 2. 0
libswscale 0. 7. 1 / 0. 7. 1
built on May 10 2009 23:45:03, gcc: 4.1.2
Input #0, avi, from 'yourvideo.avi':
Duration: 01:32:47.92, start: 0.000000, bitrate: 1057 kb/s
Stream #0.0: Video: msmpeg4, yuv420p, 352x288, 25 tbr, 25 tbn, 25 tbc
Stream #0.1: Audio: mp3, 44100 Hz, mono, s16, 112 kb/s
At least one output file must be specified

Thursday, August 13, 2009

how to print in vim without using the GUI

The command for printing in vim is hardcopy:

:[range]ha[rdcopy][!] [args]

range defaults to the whole file.
On Windows, the print dialog pops up unless you use !.
I hardly ever use args so I don't know anything interesting about it. :)

If you want to print line numbers like I sometimes do, use printoptions to control this.

Do the following to enable line numbers in the printout:

:set printoptions=number:y


Monday, August 10, 2009

what is a UUID?

I recently just installed a not so recent Ubuntu distro (8 point something...) and found the fstab to be a little more cryptic than I remembered. Basically instead of the standard /dev/sda* that I knew, it listed a:


After a bit of search, I found that this was called a Universally Unique Identifier. In short, it allows us to identify the disk partition with the knowledge that it won't be mistaken for something else. At least that's what the wiki page tells me. :) So I'm not really sure why this works, but at least I now know what that thing is.

To list the UUIDs for your devices, just run:

sudo blkid

Here's the relevant link on the Ubuntu help pages on fstab.

You learn something new everyday, eh? :)

Sunday, August 9, 2009

how to print to string in Python

Here's how to do it. You have to use the StringIO module.

import StringIO

datastring = StringIO.StringIO()
print >>datastring, " Hello string."

Thursday, August 6, 2009

why i hate reading perl code (aka why I hate Perl)

After going through line after line that looks like this:

my $targetFooThingie =

my nose starts to bleed....
I hate the embedded variable thingie (aka variable interpolation). And the total abuse of punctuation marks just makes things worse.)

PS. perl zealots and fundamentalists, go away. This is my blog and I'll post whatever I want. Thoughtful and insightful comments are most welcome. (Not that I've ever gotten a comment here. Too insignificant of a blog.... ;)

Added 13 August 2009

Given the comment by chorny, I feel the need to explain this point.

It's not the string interpolation per se that I find nosebleed inducing. Like he said, string interpolation in some form is present in all major scripting languages. What I find totally annoying is the way Perl does it. IMNSHO, it was a bad idea to to it The Perl Way as shown above. It makes a simple string concatenation operation doubly difficult in terms of deciphering what's going on.

As I don't know Ruby or PHP, I can not comment on those languages. And given that it looks like PHP is probably a clone of Perl, I probably won't be learning that language any time soon. And I hear that there are a lot of Ruby fundamentalists/zealots given that it's the latest Cool Language, i probably won't be in a rush to learn it either.

Wednesday, August 5, 2009

apt search for packages on Ubuntu / Debian

Sure there's a gui for doing this, but sometimes you're adminitering or working on a Debian/Ubuntu box and you need to figure out the package name for that software package you need.

The command is

apt-get search

Useful options are:


The first option searches only the installed packages. The default is to search both installed and non-installed packages.
The second option searchs only the names. The default is to search the name and description.

Tuesday, August 4, 2009

how to print the current stack in Python

a little screen shot of the source code. (Why a screen shot? Well because i wanted to post some purty pictures... :)