Archive for the ‘Projects’ Category
radio.py Station List Patch
Some of the stations in radio.py-0.5 changed the URLs or their streams. The patch updates the stream URLs of three stations: Galgalatz, Galatz and Radius.
To apply the patch and update radio.py, open a terminal and cd to the directory where you installed it. Type the following commands in the terminal (If you installed as root, you’ll need to run the commands as root too).
$ wget "http://www.guyrutenberg.com/wp-content/uploads/2008/11/radio.py.patch" $ patch radio.py < radio.py.patch $ rm radio.py.patch
tarsum – Calculate Checksum for Files inside Tar Archive
Update: I’ve released tarsum-0.2, a new version of tarsum.
Some time ago, I got back a hard disk back from data recovery. One of the annoying issues I encountered with the recovered data was corrupted files. Some files looked like they were recovered successfully but their content was corrupted. The ones that were configuration files, where usually easy to detect, as it raised errors in programs that tried to use them. But when such error occurs in some general text file, (or inside the data of an SQL dump), the file may seem correctly fine unless closely inspected.
I have an habit of storing old backups on CDs (they are initially made to online storage), I do it in order to reduce backup costs. But the recovered/corrupted data issue raised some concerns about my ability to recover using this disks. Assuming that I have a disk failure, and I couldn’t recover from my online backups for reason, how can I check the integrity of my CD backups?
Only storing and comparing hash signature for the whole archive, is almost useless. It allows you to validate whether all the files are probably fine, but it can’t tell apart one corrupted file in the archive from a completed corrupted archive. My idea was to calculate checksum (hash) for each file in the data and store the signature in a way that would allow me to see which individual files are corrupted.
This is where tarsum comes to the rescue. As it’s name applies it calculate checksum for each file in the archive. You can download tarsum from here.
Using tarsum is pretty straight forward.
tarsum backup.tar > backup.tar.md5
Calculates the MD5 checksums of the files. You can specify other hashes as well, by passing a tool that calculates it (it must work like md5sum).
tarsum --checksum=sha256sum backup.tar > backup.tar.sha256
To verify the integrity of the files inside the archive we use the diff command:
tarsum backup.tar | diff backup.tar.md5 -
where backup.tar.md5 is the original signature file we created. This is possible because the signatures are sorted alphabetically by the file name inside the archive, so it the order of the files is always the same.
Note that if you use an updated version of GNU tar, tarsum can also operate directly on compressed archives (e.g. tar.bz2, tar.gz).
radio.py-0.5 – An Easy Interface for Listening to Radio under Linux
This new release of radio.py brings more predefined stations and the much wanted recording feature. radio.py is a python wrapper for mplayer, designed to provide an easy-to-use interface for listening to radio from the command line. And indeed using radio.py is very easy, just pass the station name.
radio.py Classic FM
To read more about radio.py and the existing features go to radio.py – a Wrapper Script for Listening to Radio in Linux.
New stations in this release include Ram FM, Classic FM, Radio Caroline and update to all the radioIO stations. So overall this version of radio.py comes with 81 predefined stations. To see the full list of recognized station run radio.py --list. If your favorite station is still missing you can add via configuration files, ans described in here. If you will send a comment with the name of the stations and its website, I’ll add it to the next release.
The other important new feature is the ability to record radio streams to mp3 directly from radio.py. This is done using the --radio command-line switch. For example the following
radio.py CNN --record cnn.mp3will record the radio stream of CNN to a file called cnn.mp3. To stop recording just press ‘q’. This option also be used with the --sleep and --wake-up to time your recordings. For example if you want to record a show that start in 30 minutes and is 60 minutes long you should do
radio.py BBC1 --record bbc1.mp3 --wake-up 30 --sleep 60
You can download the new version from here. Installation is pretty straight forward, just untar the archive and put the radio.py some where in your path (e.g. /usr/local/bin/) and the package is installed.
As always if you want new stations added to the next release, send a comment with the station details (at least name and website).
UPDATE 14/12/2008: I’ve changed the download link to point to radio.py’s SourceForge project page.
spass 1.1 – Secure Password Generator
This is a new version of my /dev/random based secure password generator – spass. The new version doesn’t have new features, it’s mainly a bug-fix release. The package now uses autotools, which means it has the standard configure script and makefile. I also fixed some typos in the help message. Overall the new version doesn’t offer anything new compared to the old one, except for easier installation.
Read the rest of this entry »
mctext 0.2 – A Markov Chain Text Generator
This is the second release of my Markov Chain text generator – mctext. This text generator takes existing sample text, and generates a new text using Markov Chains.
The main new thing in the version in that it allows the users to specify via the command line how many words should be considered when generating the next one. The bigger the step number the closer the generated text is to the original one. The value used in mctext-0.1 was 2, and this is also the default in this one. The number of steps can be set using the --steps command line switch.
Read the rest of this entry »
Scanning Documents Written in Blue Ink – biscan
After writing the post on converting PNMs to DjVu I’ve ran into some trouble scanning documents written in blue ink. The problem: XSane didn’t allow me to set the threshold for converting the scanned image to line-art (B&W). So, I tried scanning the document in grayscale and in color and convert it afterwards to bitonal using imagemagick. This ended up with two results. When I used the -monochrome command line switch, the conversion looked good, but it used halftones (dithering), when I tried to convert it to DjVu it resulted in a document size twice as large as normal B&W would. The other thing that I tried is using the -threshold switch. The DjVu compressed document size was much better now, but the document was awful looking, either it was too dark, or some of the text disappeared. After giving it some thought I knew I can find a better solution.
Read the rest of this entry »
Convert PNMs to DjVu
I’ve decided to scan some notebooks. After researching a bit, I’ve decided to use DjVu (instead of PDF which I normally use). I’ve chose to use DjVu because it offered great quality with very good compression rate (~26KB per page) in lineart (black and white).
While XSane can natively save a multipage project into PDF it can’t do so for DjVu. So, the solution is to use the PNMs generated by XSane and convert them using the command line tools offered by DjVuLibre to bundle them together to a DjVu file. As you can guess doing this manually is pretty hard work. To make this task easier I’ve written a small bash script to automate the process.
Read the rest of this entry »
Backup Directories To Amazon S3 Script
This is a small script I wrote today, to automate my backups, which I do on Amazon S3. This is fairly short, yet useful bash script that utilize the s3cmd to do the actual sending of the files.
Read the rest of this entry »
Fixing the Home Link in the Telem System (OpenU)
This post can be helpful for students of the Open University of Israel. As a student there, I found it very annoying that the link to the courses’ homepage in the Telem system is a JavaScript link. This prevents it from opening in a new tab, and thus require various workarounds to get back to the homepage in a different tab. So, a little while ago I wrote a little Greasemonkey script to fix it.
// telem.user.js // version 0.1 // 2008-01-01 // Copyright (c) 2008, Guy Rutenberg // Released under the GPL license // http://www.gnu.org/copyleft/gpl.html // // ==UserScript== // @name OpenU's Telem - Fix Home Button // @namespace http://www.guyrutenberg.org/ // @description Fixes the home button link in the telem system of the OpenU. // @include http://maagar.openu.ac.il/opus/* // ==/UserScript== home = document.getElementById('home'); if (home) { re = /javascript:find_home_page\('(.*?)','(.*?)',/ match = re.exec(home.href) home.href = 'http://telem.openu.ac.il/courses/'+match[2]+'/'+match[1] }
This script changes the link to a regular non-JavaScript link. I’ve tested it for more than a month now, without finding any bugs. However if you find something, or have any suggestion, please comment.
Update: See A Greasemonkey Fix to the Top Menu in Sheilta (Open University), it has a fix for the top menu bar in the Sheilta system
mctext – Using Markov Chains to Generate Text
mctext is a new project of mine, focusing on text generation using Markov Chains. This little utility reads a sample text file, preferably a large one, and generates new text based on the semantics given in the sample text.
Read the rest of this entry »