It’s been a bit more than three years since I’ve written about a workaround for getting hyperref
to play (almost) nicely with Hebrew. Over the past few weeks, I saw I rising interest in this and few people contacted me regarding this issue. So I thought it’s a good opportunity to better document the current situation, and possible ways that should be further investigated which I believe might lead to better solutions.
Continue reading Hebrew Support in Hyperref – Situation Review
Author: Guy
Sending Desktop Notification from Cron
Usually when one wants to keep track of one’s cron jobs, one tells the cron daemon to email the output of the commands. While this is probably the best solution for servers, on desktop machines is problematic. Many ISPs block outgoing traffic on port 25 (SMTP), and if you want to send the emails via external SMTP server (such as GMail) this requires you to store authentication details in plain text. A better solution for the desktop would be to harness the desktop notifications available in Ubuntu.
There is a useful tool called notify-send
which is able to send desktop notifications directly from the command line. However, there are few caveats:
notify-send
expects its input on the command line, it can’t read fromstdin
.- If you run from cron you must tell it which display to use.
The first issue can be worked around by using cat to pick up the input. The second issue is handled by adding a DISPLAY
environment variable to the crontab. So your crontab will look something like this:
DISPLAY=:0
10 1 * * sun some_cool_command | notify-send "Backup Documents" "$(cat)"
The first argument to notify-send
is the title of the notification. The second is the actual text to appear in it, in our case it’s whatever comes in the stdin
. If you want to store the output in a log file as well as displaying it in a desktop notification, you can use tee
, which basically saves its input to a given file and also pipes it again to stdout
.
DISPLAY=:0
10 1 * * sun some_cool_command | tee -a ~/some_log.log | notify-send "Backup Documents" "$(cat)"
WiFi won’t connect on Samsung Galaxy S2 with CyanogenMod 9 (ICS 4.0.4)
After upgrading to CyanogenMod 9 (ICS 4.0.4) I’ve experience problems connecting to WiFi networks. Most of the time I’ve tried to connect to a WiFi network it would try to connect and then fail. Often it would also show the network I’ve just tried to connect to as “Not in range”. This was extremely irritating, as I could stand by my router and have the phone report that there is no signal, while another Galaxy S2 phone would connect immediately, the only difference was that the other phone was running Android 2.3.7. Needless to say, I haven’t made any major (or minor) changes to my WiFi equipment and the problem wasn’t confined just to my home. Sometimes, it would connect after being idle for a day or so.
Back when I was using CyanogenMod 7, I had no problems with the WiFi on my phone, and I could also replicate this behaviour on another Galaxy S2 I’ve upgraded to CyanogenMod 9. Initially I thought it was some bug in CyanogenMod, but I came up with nothing. Over the weekend, I’ve figured maybe the bug isn’t specific to CyanogenMod, and I’ve found this bug report WiFi freeze on Samsung Galaxy S2 with ICS 4.0.3. For some reason many people have problems with WiFi on Galaxy S2 with ICS. While the report relates to the WiFi freezing, which I didn’t experience, I’ve decided to sift through the comments. Some people mentioned the “Wi-Fi frequency band” feature available in Wi-Fi settings -> Advanced (available by pressing the menu button), so I’ve decided to try playing with the different settings there.
This setting allows you to choose the WiFi operating frequency between three options 5GHz, 2.4GHz and “Auto”, which as you can guess automatically figures out the right frequency, 5GHz (802.11a and 802.11n) and 2.4GHz(802.11b/g/n). However, it seems the phone (probably due to a problem in the driver) fails the “Auto” thing. Instead of guessing the right frequency, it fails to connect. So I’ve changed it to 2.4GHz, which is still more popular choice in routers over 5GHz, and instantly my phone connected to my router.
For conclusion: If you have trouble connecting to WiFi on Samsung Galaxy S2 with ICS, you should probably set the phone to use 2GHz only (or 5GHz only) instead of the default “Auto” mode.
spass
-3.0 Released
I’ve released today the new version of spass
, a tool that creates cryptographically strong passwords and passphrases by generating random bits from your sound card.
In the user facing side, spass
can now create passphrases as long as passwords. The words for the passphrases are chosen out of a list of 8192 words which means each word adds 13 bits of entropy to the passphrase.
spass
can now use one of three audio backends (the old version could only use OSS):
- Advanced Linux Sound Architecture (ALSA)
- Open Sound System (OSS)
- PortAudio
The PortAudio support will hopefully make it easy to port spass
to other platforms as well (such as Windows). The random number generator got overhauled and now there is an unbiasing step before applying the hash function. This should help getting consistent results in terms of entropy. In the backstage I’ve migrated the project from autotools to cmake
.
You can find more information, as well as both source and binary packages in https://github.com/guyru/spass.
Auto-Detect Dependencies when Building .deb
s Using CMake
CMake (via CPack) as a great feature that allows you to automatically generate Debian/Ubuntu (.deb
) packages. One of the annoying things to do when you create a package is listing its dependencies. CMake asks you do it via the CPACK_DEBIAN_PACKAGE_DEPENDS
variable. For example:
set (CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>=2.7-18)")
But what happens when you work on a more complex project? Keeping track of all the dependencies by hand is a tedious task. Debian provides a tool named dpkg-shlibdeps
which makes this task easier by updating the debian/control
file with dependencies extracted from the dynamic libraries needed by a given executable. Luckily since CMake 2.8.3, CMake also supports running this tool automatically to figure out the required dependencies. The documentation is sparse, and I had hard time finding how to do so (I actually found it via a bug report and a commit message, but afterwards I’ve seen it the official documentation too). To enable it, you need to add the following line to your CMakeLists.txt
file:
# autogenerate dependency information
set (CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
SQL Dump for MS Access databases (.mdb
files) on Linux
I recently had to work with some data that came in a huge Microsoft Access database. Because I like SQLite (and despise Access), I’ve decided to export the data to an SQLite file. The first thing I needed to do was to somehow get all the data out of the db. Being a Linux user, complicates things a bit, but thanks to mdb-tools
it’s possible to process the .mdb
files without resorting to Windows and buying Access. Using mdb-tools
directly can be tedious if you want to export a large db with multiple tables, so when I’ve looked for a way to automate it, I came across Liberating data from Microsoft Access “.mdb” files. This post shows a nice script that dumps every table in a .mdb
file to separate CSV file.
While useful, I wanted something that I could easily import into SQLite. So I’ve modified their script to generate an SQL dump of the db. Given a db file, it writes to stdout
SQL statements describing the schema of the DB followed by INSERT
s for each table. Actually because mdb-tools
doesn’t support SQLite as a backend, the dump uses a MySQL dialect, but it should be fine with SQLite as well (SQLite will mostly ignore the parts it can’t process such as COMMENT
s). The easiest way to use the script is
$ python AccessDump.py access.mdb | sqlite3 new.db
If the original db contains non-ascii characters, and isn’t encoded in UTF-8, you should set the MDB_JET3_CHARSET
environment variable to the correct charset. The dump itself will be UTF-8 encoded.
$ MDB_JET3_CHARSET="cp1255" python AccessDump.py access.mdb | sqlite3 new.db
Continue reading SQL Dump for MS Access databases (.mdb
files) on Linux
Conditional Compilation in Autoconf and Automake
While working on my audio based random password generator (you view the source in github), I wanted to do some conditional compilation: Compiling certain parts of the program only in case some option is passed to the configure script. As it usually happens with GNU’s autotools, it kind of hell to do it. Documentation is spread across dozens of sources, each provides only a specific part of what to do. I’m writing it here in the blog, in hope I’ll never have to search how to do so again.
Continue reading Conditional Compilation in Autoconf and Automake
Some Thoughts About Android’s Full Disk Encryption
One of the new features touted by ICS is full-disk encryption (actually it was first available in Android 3). The first look is promising. The android developers went with dm-crypt as the underlying transparent disk encryption subsystem, which is the de-facto way to perform full-disk-encryption in Linux nowadays. This ensures both portability of the encrypted file systems and tried-and-tested implementation. The cipher itself is 128-bit AES in a ESSIV mode, and the encryption key is derived from the password using PBKDF2 (actually it’s the key that encrypts the actual encryption key, allowing fast password changes). So where do I think it went wrong?

Continue reading Some Thoughts About Android’s Full Disk Encryption
A Note About Open Sound System (OSS)
A while ago I wrote about creating random numbers out of noise gathered from audio device and also created a password generator based on the idea. The implementation was based on Open Sound System (commonly known as OSS). OSS was the defacto way to access audio device couple of years ago, when it hit licensing issues and subsequently replaced by ALSA. As Ubuntu no longer supports OSS (and even the ALSA wrapper for it is in Universe), I’ve decided to re-write the code in some modern alternative.
Continue reading A Note About Open Sound System (OSS)
Fixing virtualenv
after Upgrading Your Distribution/Python
After you upgrade your python/distribution (specifically this happened to me after upgrading from Ubuntu 11.10 to 12.04), your existing virtualenv
environments may stop working. This manifests itself by reporting that some modules are missing. For example when I tried to open a Django shell, it complained that urandom
was missing from the os
module. I guess almost any module will be broken.
Apparently, the solution is dead simple. Just re-create the virtualenv
environment:
virtualenv /PATH/TO/EXISTING/ENVIRONMENT
or
virtualenv --system-site-packages /PATH/TO/EXISTING/ENVIRONMENT
(depending on how you created it in the same place). All the modules you’ve already installed should keep working as before (at least it was that way for me).