Home
Alexandra Zaharia
Cancel

Summing a column with awk

Suppose you want to sum values on the nth column in a file. Here is how to do this using awk: awk '{ sum += $<COL> } END { print sum }' <FILE> Replace <COL> with the index of t...

Function timeout in Python using the multiprocessing module

The problem Sometimes you may want to impose a timeout on a Python function. Why would you want to do such a thing? Let’s say you’re computing something but you know there are some hopeless scenar...

Function timeout in Python using the signal module

The problem Sometimes you may want to impose a timeout on a Python function. Why would you want to do such a thing? Let’s say you’re computing something but you know there are some hopeless scenar...

How to split files in Linux from the command line

[I originally published this post on Blogspot.] It can be useful to split large files, or even smaller files and ensure all the resulting volumes have the same size. For this we will be using spli...

How to manually modify a .deb package

[I originally published this post on Blogspot.] Every now and then you might need to tweak a .deb package for testing purposes. For instance you just want to change the behavior of the postinst sc...

Converting .m4a and .wma to .mp3

[This is a synthesis of two posts I wrote on Blogspot in 2008.] I’ve compiled here two recipes for converting to .mp3. Convert .m4a to .mp3 Install lame and faad, then cd into a directory contai...