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.
Continue reading Scanning Documents Written in Blue Ink – biscan

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.
Continue reading Convert PNMs to DjVu

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

Convert CSS layout to RTL – cssrtl.py

This is a re-release of a script of mine that helps convert CSS layouts to RTL. I originally released it about a year ago but it was lost when I moved to the new blog. The script, cssrtl.py, utilizes a bunch of regular expressions to translate a given CSS layout to RTL.

Continue reading Convert CSS layout to RTL – cssrtl.py

spass – A Secure Password Generator Utility

spass is a secure password generation tool. spass was designed under the assumption that a password generator is as good as its random number generator, so spass uses the Random class, a /dev/random based cryptographically strong random number generator class. As always, I tried to make the command-line interface as user-friendly as possible (as much as a command-line interface can be friendly).
Continue reading spass – A Secure Password Generator Utility

radio.py-0.4 – Listening to Radio the Easy Way

Update: radio.py 0.5 is available.

radio.py is a little script that makes it very easy to listen to radio under Linux (and maybe other OSs too) with mplayer. All you need to do is to call radio.py with the name of the station you want to listen to. For example:

radio.py Radio Paradise
or
radio.py BBC3
To read more about radio.py go to the first post discussing radio.py.

What’s New

Here are some of the things that have changed in radio.py-0.4 compared to the previous release (0.3). Continue reading radio.py-0.4 – Listening to Radio the Easy Way

Random – A Random Number Generator Class

After dealing with the seeding of srand(), I’ve realized that rand() just doesn’t give strong enough random numbers for some of my needs (e.g. strong password generator), so I decided to find a better solution. The solution came in the form of Random, a cryptography strong pseudo-random number generator class.
Continue reading Random – A Random Number Generator Class

radio.py – a Wrapper Script for Listening to Radio in Linux

Download radio-0.3.tar.gz.

Update: radio.py-0.4 is now available.

I like listening to music and radio while working, and fortunately there are numerous ways to do that. Unfortunately, most ways that allow you to listen to radio are very resource consuming/memory hogs (such as listening to streaming-media via web-browsers) or very unfriendly to users (listening via mplayer for example). So, I set out to find a way that will use as little system resources as possible while keeping it user-friendly. One other requirement that I had, that I will be able to do all that from the command-line, so it will work great with GNU Screen and won’t require an X server (if I work without one).

I used for some time mplayer for listening to radio. I had a file with a list of web-radio streams URLs which I would copy and pass to mplayer -playlist. This method answered two of the requirements (minimal resources and command-line interface), but wasn’t really user friendly. So, I wrote a little wrapper script in python around mplayer – radio.py. After quick installation (download and extract the tar archive and copy radio.py to somewhere in you PATH), radio.py will allow you to listen to stations easily, and it will also do couple more things for you.

To listen to a station just call radio.py with the station’s name, e.g. in the command-line enter radio.py BBC1 to listen for BBC radio channel 1. To view a list of know stations run radio.py --list. Currently there aren’t many stations (just stations I thought that are needed or I listen to). You can easily edit radio.py to add new stations (the script is documented and very clear). If you do so, please write a comment or email me so I will be able to add those stations to next release by default.

So, as you seen radio.py allows you to easily listen to radio, as easy as writing the station’s name. But, as I said, it can do more things that I thought should be in a radio script. It has both a sleep feature (that turns off the radio after specified amount of time) and a wake-up feature (that starts the radio after a specified amount of time). This two features can be used together, and practically allow you to use radio.py as an alarm clock.

You can find more information about radio.py options by calling radio.py --help. I hope you will find this script useful as I do.

Download:
radio-0.3.tar.gz.