May 7, 2013
Last time we looked at how to get the data to the GPS and now we will have a look at how to parse the data. Turns out that except for the check-sum, everything is pretty straight forward, even in Bash.

So, why bash in the first place? Well, there’s not real reason except that for the something else I’m working on, it’s the ideal glue-code language, allowing me to invoke simply other programs that I do not want to re-code (or take parts of) to do what I want. I must say that I even have a C# version of the GPS data grabber, but while fancier, it does not bring much more than the Bash version.
Read the rest of this entry »
3 Comments |
Bash (Shell), hacks, programming | Tagged: cut, GPS, grep, NMEA, sed, tr |
Permalink
Posted by Steven Pigeon
April 30, 2013
I am presently working on something that requires geolocation. Not knowing much about GPSes and related topics, I decided to get a USB GPS. This week, let’s have a look at how we can extract information from the USB GPS using Bash.

The first step is to locate your USB GPS as a device. If it’s NMEA compliant, it should mount automagically as a USB serial port. You would think that lsusb -v would show you the device, but it does not always. Sometimes it shows as “Brand X GPS”, sometimes it only shows as a generic device, say “MediaTek Inc.”, or even as a modem. It will typically show up as /dev/ttyUSB0 or /dev/ttyACM0.
Read the rest of this entry »
2 Comments |
Bash (Shell), hacks, programming | Tagged: GPS, serial port, usb gps |
Permalink
Posted by Steven Pigeon
April 23, 2013
In the last installment of this series, we looked at Markov chains as a mean of estimating the likelihood of a given piece of text of actually being a message, written in English, rather than mere gibberish.
This week, we finally piece everything together to obtain a program to crack Caesar’s cipher without (much) human intervention.
Read the rest of this entry »
2 Comments |
algorithms, Bash (Shell), Cryptography | Tagged: Caesar Cipher, Markov chains |
Permalink
Posted by Steven Pigeon
February 21, 2012
In a previous post I discussed lossless audio encoding and presented a Bash script using flac to rip and process CD audio files. I also commented on how the psycho-acoustic model used in a MP3 encoder will dominate encoding as bit-rate increases, without much quantitative evidence. In this post, I present some.

Read the rest of this entry »
Leave a Comment » |
algorithms, Bash (Shell), data compression | Tagged: FLAC, Lossess Compression, Lossy Compression, MP3, psychoacoustic model, psychoacoustics |
Permalink
Posted by Steven Pigeon
January 17, 2012
Once upon a time, I discussed how to pick bit-rate for MP3, while considering re-ripping all my CDs. But if I’m to re-rip everything, I might as well do it one last time and use lossless compression.

In this post, we’ll discuss the simple script I cooked up to do just that, and a bit on how Flac works, and how it compares to MP3.
Read the rest of this entry »
1 Comment |
algorithms, Bash (Shell), data compression, embedded programming, Mathematics, programming | Tagged: CD, Entropy, Golomb Codes, GSM, Linear Prediction, music, psychoacoustic model, psychoacoustics, sound, Speech, Speech Codec |
Permalink
Posted by Steven Pigeon
December 20, 2011
In a previous post, I discussed how to set the default power policy with Linux (Ubuntu) by detecting the battery/power status: if you’re plugged-in, set it to on-demand, if you’re running from the battery, set it to powersave. This is rather crude, but proved effective.

But CPUs that support SpeedStep (or similar) usually support a rather long list of possible speed settings. For example, my i7 supports about 15 different speeds, and “powersave” selects the slowest of all, 1.60GHz (on my laptop, that would be 800MHz). Maybe we could leave the policy to on-demand, but cap the maximum speed to something a bit lower than maximum?
Read the rest of this entry »
2 Comments |
Bash (Shell), CPU Architecture, hacks | Tagged: cpufreq-applet, cpufreq-selector, cpufreq-set, i7, laptop, Powersave, SpeedStep |
Permalink
Posted by Steven Pigeon
September 13, 2011
I still can’t figure out exactly which operations are expensive in Python. My C/C++ can’t help me much because it seems that things aren’t implemented like I’d've expected—like lists that aren’t lists, but array lists, leading to
for operations you would otherwise expect to be
.

But a friend of mine—Olivier—showed me a simple, basic, yet rather effective tool to profile Python programs (I’m not sure if I should say script or not).
Read the rest of this entry »
6 Comments |
Bash (Shell), Life in the workplace, programming, Python | Tagged: easy_install, Kcachegrind, optimization, Profiling, SquareMap, Trace, Valgrind |
Permalink
Posted by Steven Pigeon
December 14, 2010
Like many of us, you may need to host stuff on your home computers and access it via the Internet. If you paid for a static address from your provider, you can map a domain name to it via your ISP’s DNS. But for the majority of us, getting a static address from our provider means paying a good deal more for little to nothing more. For example, my provider (which by the way offers excellent service) is so stable that my IP address changes once a year, or even less often. But for others, the IP address changes more often and it’s difficult to keep track of it.

Some services, like DynDNS, provide you with a script and a couple of tools to access your stuff via a virtual domain name (or something like that). The magic behind DynDNS maps your domain name to your ever-changing provider-specific IP address. But what if you just want to find your way home, without a domain name and without having to deal with an extra service provider?
Read the rest of this entry »
2 Comments |
Bash (Shell), hacks, Life in the workplace | Tagged: DynDNS, home computer, hosting, IP Address, router |
Permalink
Posted by Steven Pigeon
November 16, 2010
Sometimes you’re automating tasks that requires you to be informed of changes at the moment they’re occurring (or at least, not too long after). Turns out if you’re planning only to send mail, it takes abouts 3 minutes to setup postfix and send your first automate mail message!

First, you have to install postfix and mailutils, two packages that are fortunately already (likely) installed and readily available from the default repository. In a shell, type:
Read the rest of this entry »
1 Comment |
Bash (Shell), hacks | Tagged: Automation, mail, Postfix, Ubuntu |
Permalink
Posted by Steven Pigeon
October 26, 2010
Every time I add a development library (or any other application) that is not found in my distro‘s repositories, I ask myself how troublesome it will be. If you’re really lucky, it comes in a package (and repository) compatible with the target distribution (like a Debian package or a RPM) and everything is just fine: you install it from the package manager, and that’s it. But if not, you have to download a tarball from some (more or less trusted) location like Sourceforge. It usually comes with a rather well designed set of configure, make, and (sudo) make install scripts that reduces configuration to little more than launching the configuration script, check for any unmet dependencies, add them and rerun the configuration script until they are all met, and then make install performs a smart, standard location install and you’re done. You won’t have the automagical upgrades with everything else, but you can go on with your life.

Then again sometimes you have to install a library (or application) that either has a half-baked installation script, or is incompatible with your distro, or, cerise sur le gâteau, both. And, just to aggravate you just fine, it installs to a non-standard location requiring you to specify include and library paths in your make files or just to invoke the application. And, of course, default location will change from from /usr/local/shared/thislib/ to /usr/shared/include/thislib between version 2.1.5 and 2.1.6, just to make sure to break just about everything you set up.
Read the rest of this entry »
Leave a Comment » |
Bash (Shell), Life in the workplace, Operating System, programming | Tagged: Environment variables, Libraries, scripting, scripts, shell scripting |
Permalink
Posted by Steven Pigeon