Posts for Saturday, August 8, 2009

sms is a garbage protocol

  • no error on transmission failure
  • no failure on invalid recipient
  • no assurance of delivery to temporarily disconnected recipient

All of which amounts to the result that when you do send a text you have no idea if the number is correct, if the message went through, and in the event the person’s phone is turned off if he’ll ever see it.

Now, I really don’t care if the flaws are in the protocol, the phones or the services we pay for; what I do know is that it all makes for an appalling technology whose reliability imitates Microsoft’s infamous msn messenger where messages constantly go missing without notice. I hear all the time about messages I never saw and apparently when my phone is off for a few days there is zero chance of getting messages sent in that interval.

Compare it to email, which doesn’t have any of these flaws, and it seems incredible that we are actually paying to use this.

And that’s to say nothing of the horrendous user interface for typing messages on a phone to begin with.

This entry belongs in a comprehensive tome I have been writing in my head for a decade, detailing just how much cell phones suck. But the field is so vast that it overwhelms my ability to articulate it.


I've been playing with Renoise since quite while now. Time to write sth. about it (this is by no means a review, rather a short recap of my impressions).

Renoise is a modern music Tracker. Unlike other sequencers like Pro Tools or Cubase, trackers follow a different approach for music creation. The arrangement is based on patterns, and the main focus is on working with samples instead of recording instruments (though, it is of course possible as well). In case of Renoise, musical information isn't represented as MIDI notes, but as hex values (which in turn represent MIDI notes of course). You can modify lots of parameters of a played sample like speed, pitch, pan, volume or even the playback offset by using different control commands in the pattern editor. This makes Renoise ideal for beat programming/slicing as you don't have to cut a loop for example into different pieces and then rearrange everything. Instead you just play one and the same loop from different positions (yes, you can jump around inside a loop in real time by just setting events which triggers the loop at different playback positions).

Here's a screenshot of how the main window of renoise looks like:

Okay, hex instead of MIDI sounds a little bit complicated at first, and I have to admit that I had a hard time at first to get used to this completely different approach of sequencing. But, after some time it gets really intuitive. I definitely recommend an external MIDI controller/keyboard to ease the setting of new events though.

Like you can guess from the screenshot, Renoise also supports automation of lots of parameters of used samples and plugins (btw. Renoise comes with a set of really nice plugins) and also provides automatic delay compensation for used plugins and can render MIDI tracks to patterns inside a session. The mixer provides enough routing options but could be optimized to be a little bit more intuitive.

But the best thing about Renoise, is that it's absolutely cheap. A license costs about 50€ - which is nothing compared to the pricing of other DAWs. If you're into music creation and maybe into electronic music and have never worked with a tracker before I can definitely recommend to give Renoise a try. It's well worth the 50 bucks and it runs on Windows, OSX and Linux!

Btw, in case you, like me, wondered how some of those Breakcore/Drum and Bass artists make their crazy music without editing their brains out in a DAW like Pro Tools or Cubase: Some just use trackers, and some, like Venetian Snares use Renoise (which makes completely sense now that I know it ;-) - the following video shows the Renoise session of the Venetion Snares track Vache):

Of course I made a test track as well. It's some kind of breakcore style electronic piece. It's not really a complete track in itself, but rather a playground for all the possibilities Renoise offers. I'm definitely plan on making some more music with Renoise in the future.

As always, enjoy (or not)!

Download: chizm_lies.mp3

Read or add comments to this article · Save to

Reading "Little Brother" is good procrastination

I've read about Cory Doctorow when his first novel Down and Out in the Magic Kingdom came out, but forgot about it and haven't read it at that time.

Now I've stumbled upon him again and started reading his Little Brother — in short, a novel about kids hacking to get their freedom back, because they feel too oppressed, too monitored and in short robbed of their basic freedoms in the almost Orwellian society.

It might sound like sci-fi and the first few pages did feel like it as well, but both the technology and the state of the society are almost identical to what our current lives. And, being an EU-citizen, once I got over that it's located in San Francisco and got used to some of the specifics of the slang, it's quite engulfing!

The story itself is quite exciting and I'd gobble it up in one day, if I was still in high-school, but its strongest point is how it describes all the technology we use today (TOR, PGP/GPG, SSL, encrypted disks, etc. etc.) to try to ensure at least some privacy in our online lives as well as the technology that's used to spy on us (be it just advertising cookies, credit cards or biometrics, CCTV or worse).

So far I've read halfway through it — although I wanted to read only a chapter a day, I couldn't help myself! XD — and if most books about "hackers" show them in just one light, this one seems to try to cover as many aspects as possible. From the hacker's/kid's views, the normal users', worried parents' and those who think that privacy is a small price to pay for the terrorists to be caught. It also shows the possible good as well as the bad consequences that could happen when you deviate from the norm or even fight for your rights.

It's one of those rare books that come out at exactly the right time and are aimed at exactly the right crowd — the high-school kids, as they are the biggest users of the internet, therefore the most vulnerable and also the ones that can make the biggest change. Just today I read in the local paper's NYT supplement on what all crap the advertising and profiling companies (try to) take from us on the 'net. And if it's already normal news in the papers, the shit's hit the proverbial fan already — it's high time the broader public knows about it (especially the kids).

If you haven't yet, read it — go download it for free (it's under CC BY-NC-SA) or rent it or buy it in a bookstore. Give it to a kid you know at least occasionally uses the internet (yeah, every little bugger, I know :P), share it with your friends, spread it around...

I seldom get this passionate about a book, but — by George! — if I was a kid, that book'd be a real eye-opener for me!

hook out >> have to stop reading ... must learn for exams ... have to stop reading ... must learn for exams XD

Week of bash scripts – rps and commentstrip


These two scripts will respectively: find if a program is running, and strip-comments from text files. The first is useful if you need to see if the program is running or if you need to kill the process with it’s id, comment strip is a good tool to use if posting configurations on forums as often developers or advanced users already know what the settings actually do.


#!/bin/bash # rps - running program search ps aux | grep $@ | grep -v grep | grep -v ".bin/rps" | column -t


Commentstrip will display the output to the terminal, but if you got xclip installed the ‘x’ flag can be used to copy the output to the clipboard (i.e. commentstrip x file).

#!/bin/bash # commentstrip - outputs file without comments or blanklines if [ -z $1 ]; then   echo "commentstrip <*x> <filename> - outputs file without comments or blanklines"   exit fi case $1 in   x | clipboard ) shift                   if [[ `whoami` == root ]]; then                     echo "Must be regular user to copy to clipboard."; else                     grep -vh '^[[:space:]]*\(#\|$\)' "$@" | xclip -selection c                   fi                   ;;   * )             grep -vh '^[[:space:]]*\(#\|$\)' "$@"                   ;; esac

The final day of week of bash scripts… phew! I’d like to thank everyone that posted comments, and to those that stopped by this week. Enjoy.

Posts for Friday, August 7, 2009


If the auto industry makes cars like Microsoft makes Windows?

This is an old one (and I take no credit for it), but cracks me up every time I read it and I’m sure that I’m not the first. However it’s great to share, and here it is … again :)

Bill Gates reportedly compared the computer industry with the auto industry and stated, “If GM had kept up with technology like the computer industry has, we would all be driving $25.00 cars that got 1,000 miles to the gallon.”

In response to Bill’s comments, General Motors issued a press release stating:

If GM had developed technology like Microsoft, we would all be driving cars with the following characteristics:

  1. For no reason whatsoever, your car would crash twice a day.
  2. Every time they repainted the lines in the road, you would have to buy a new car.
  3. Occasionally your car would die on the freeway for no reason. You would have to pull to the side of the road, close all of the windows, shut off the car, restart it, and reopen the windows before you could continue. For some reason you would simply accept this.
  4. Occasionally, executing a maneuver such as a left turn would cause your car to shut down and refuse to restart, in which case you would have to reinstall the engine.
  5. Macintosh would make a car that was powered by the sun, was reliable, five times! as fast and twice as easy to drive – but would run on only five percent of the roads.
  6. The oil, water temperature, and alternator warning lights would all be replaced by a single “This Car Has Performed An Illegal Operation” warning light.
  7. The airbag system would ask “Are you sure?” before deploying.
  8. Occasionally, for no reason whatsoever, your car would lock you out and refuse to let you in until you simultaneously lifted the door handle, turned the key and grabbed hold of the radio antenna.
  9. Every time a new car was introduced car buyers would have to learn how to drive all over again because none of the controls would operate in the same manner as the old car.
  10. You’d have to press the “Start” button to turn the engine off.

Related posts:

  1. Windows 7 Review
  2. Windows 7 “feature”: let’s include XP!
  3. Windows 7

Week of bash scripts – grok and cdf


These two scripts are two different find commands. The first (grok) will list all files in a directory recursively that contain matched text, and the second will locate a file/folder and the change to it’s directory. Neither of these are mine (though slightly edited), I’ve gotten them from the Arch forums where they have a great thread called Post your handy self made command line utilities.


This one is by rebugger and I call it grok. Syntax is:

grok <keyword> <*location>

If no location is given it begins the search in the current directory.

#!/bin/bash # grok - search file(s) for keyword # Author: Gen2ly # Text color variables TXTBLD=$(tput bold)     # Bold TXTUND=$(tput sgr 0 1)  # Underline TXTRED=$(tput setaf 1)  # Red TXTGRN=$(tput setaf 2)  # Green TXTYLW=$(tput setaf 3)  # Yellow TXTBLU=$(tput setaf 4)  # Blue TXTPUR=$(tput setaf 5)  # Purple TXTCYN=$(tput setaf 6)  # Cyan TXTWHT=$(tput setaf 7)  # White TXTRST=$(tput sgr0)     # Reset if [ -z "$1" ]; then   echo "grok <keyword> <location/file> - search file(s) for keyword (recursive)."   exit fi  if [ -z "$2" ]; then   echo "${TXTBLD}${TXTGRN} * ${TXTRST}Files found in ${TXTUND}`pwd`${TXTRST} that contain ${TXTYLW}"$1"${TXTRST}:"   grep -Ilr "$1" .   exit fi echo "${TXTBLD}${TXTGRN} * ${TXTRST}Files found in ${TXTUND}"$2"${TXTRST} that contain ${TXTYLW}"$1"${TXTRST}:" grep -Ilr "$1" "$2"


This one is by segoe that uses locate to find a file and that cd’s to the first match found.

This one I put in my ~/.bashrc:

cdf () { cd "$(dirname "$(locate -i "$*" | head -n 1)")"

Posts for Thursday, August 6, 2009

The timeless Riviera


The beauty of the camping vacation is the enduring feeling of being on site. Air travel is very insular that way, I feel like I’m in the same place right up until I get off the plane, but when you’re on the road it’s a whole different feeling and more authentic in a sense. It’s tiresome if you have to go far to get there, but once you cross the border into where you’re going there is a real sense of expectation that gradually bears out. And you can stop anywhere you want along the way.


Locations of interest:

  • Wien (classical concert)
  • Verona (late night outdoor opera)
    Camping right near Lago di Garda - a summer camping hotspot
  • La Spezia (all day visit to the pictoresque villages in Cinque Terre national park)
  • Genova (city walk and a visit to Europe’s largest aquarium/oceanography museum)
  • San Remo (walk along the promenade and swimming at the beach)
  • Monaco (city walk, swimming at the beach)
  • Nice (walk along the promenade, swimming)
  • Cannes (walk along the promenade)
  • Ramatuelle by St. Tropez
    Camping at the unbeatable Les Tournels
  • St. Tropez (city walk)
  • Marseille (city walk)
    Camping in Aix-en-Provence - a nice town in itself
  • Les Baux-de-Provence (a splendid ancient castle)
  • Orange (the best preserved Roman theater in Europe)
  • Geneve (CERN museum, city walk)
  • Lausanne (city walk)
  • Bern (Einestein museum)
  • Zurich (natural earth museum and a robotics museum)
  • Munich (Deutches museum - world’s largest museum of science and technology)

And that’s a way to spend three weeks.


My Grado SR-80 headphones are more electrical tape than headphone at this point. Inexplicably, sound continues to come out of them. The wires have so many breaks that I'm not sure how this is physically possible.

Also the top of the band is also splitting apart and the pads are worn down and fall off constantly and there are pokey plastic bits that hurt my ears a lot. After prying them apart with a hammer and screwdriver to fix the wires a few times, they look like they've been through a wood chipper. I love those things but it is time for retirement.

Researching headphones can suck up months of your time if you let it, especially if you believe the bullcrap. Going to an "audiophile" site like Head-Fi is like entering a new world. I have no idea what any of the vocabulary means.

"Detailed", "neutral", "open soundstage", I can figure those out to some degree. But what the hell do "sweet" and "dark" and "thick" and "smooth" mean with regard to headphone quality? Are we talking about music or chocolate? What do "forward" and "recessed" and "transparent" and "analytical" mean? These are rhetorical questions, I don't care what they mean. I have my doubts that they even mean anything objective.

Then there are strange beliefs, like that letting your headphones run for 100 hours to "burn them in" when they're new will make them sound better. I'd really like to see that theory put to a proper scientific test. I have strong doubts that it's anything more than people's minds fooling themselves. It sounds like voodoo. At least it's not as bad as $7,000 speaker wires.

I can definitely and easily tell the difference between cheapo $5 headphones and my Grado's, but beyond that I really start to doubt that it matters. Spending hundreds or thousands of dollars on headphones seems like insanity to me.

For this reason I decided to do next to no research, and went and bought the first pair that I found online that looked comfy, got mostly good reviews, got a couple good reviews on head-fi (as far as I could decipher) and had a price of around $100. I ended up ordering ATH-AD700's from Amazon. Should be here in a week.

Posts for Wednesday, August 5, 2009

Week of bash scripts – newx and bgcmd


Here are two scripts: one, that helps improve gaming performance, and the other to free up the terminal. I’ve talked about the later before, but I got a new trick up my sleeve. However, before I go any further, I’d like to point out how to use bash scripts so that they are easily accessible, yet (at the same time) out of the way.


I like to keep my bash script out of plain view. Some people like to put their bash scripts in a folder called scripts in their home folder. This works good but keeping the home folder just for documents can help reduce clutter:

Think about putting your scripts in a hidden directory in your home folder. For example, I use a folder called ~/.bin. To make the scripts executable anywhere, create a path to them in your ~/.bashrc:

export PATH="/home/gen2ly/.bin:/home/gen2ly/.bin/root/arch:\ /home/gen2ly/.bin/backup:$PATH"

To quickly enter the script directory, create an alias to them:

alias cdb="cd /home/gen2ly/.bin && ls -h"

Now, reload the bash environment:

source ~/.bashrc

To get to your script directory you can now just do:


A basic script but useful for gamers that don’t have the most powerful graphic cards. Compositing can zap game performance pretty thoroughly. Rather than digging through menus and disable compositing this command will just start a new xorg server:

#!/bin/bash DISPLAY=:1.0 xinit $* -- :1

By typing newx a new xorg server will be opened on the eighth virtual console (Ctl+Alt+F8). This will also open a terminal where commands can be entered. Typing exit will exit the new xorg server and return you to your original. Alternatively you can type newx urbanterror and urbanterror will be loaded.


bgcmd will background a program so that it doesn’t overtake the terminal. I’ve written about this before but I’ve discovered how to add bash-completion to it. I’ve updated the page to reflect such:

Background a Process


Ballmer at it again...

I just got done reading about and listening to a wonderful audio-bite from good ol' Steve Ballmer.  Honestly, I don't understand why Microsoft keeps him employed.

Anyway...  According to Mr. Ballmer, Linux is no longer free.  So, with that in mind, please do not try to download Linux from here, or here, or here, or here, or here, or here, or here, or here, because somehow, they're gonna charge you for it.  Seriously...  Don't even think about trying to download any version of Linux from here, because I believe in Mr. Ballmer when he says about Linux, "of course, it has a price."

Hmm...  I guess I just didn't give gentoo my mailing address for them to send me the invoice for using gentoo Linux these past 6 years.  Silly me.

All this time, I thought it was free.

Oh wait.  Nevermind.  I forgot who I was referencing all this time.

Me, being a developer, am fully aware of what has a price, and what doesn't.

Heh....  "of course it has a price."  sheesh.

SynCE 0.14 updates

SynCE 0.14 ebuilds are now available in the overlay for all SynCE packages. (See the instructions here for details)

You should have no trouble compiling and installing (of course, let someone know if you do!)

Most of the SynCE problems seem to come from configuring and using (or trying to). So before you report any bugs, please try these steps. Note: this is a short summary! Please read the SynCE wiki for full instructions.
  1. First verify you have version 0.14 of everything, using eix, equery, genlop or whatever.
  2. Backup all your Contacts, Calendar, Tasks and Files. (I use Sprite Backup that came with my Treo Pro). This is important as Windows Mobile 6 will delete all data associated with a deleted partnership.
  3. Remove the multisync group (your command may vary)
    $ msynctool --delgroup synce-sync
  4. Remove the partnership
  5. Delete the ~/.opensync and ~/.synce directories (copy any local config files first)
    $ rm -rf ~/.opensync ~/.synce/*
  6. Create a new partnership (change the name and objects to synchronise)
    $ "TreoPro" "Calendar"
  7. Create a new opensync group, and add members (alter members to suit your needs)
    $ msynctool --addgroup synce-sync
    $ msynctool --addmember synce-sync evo2-sync
    $ msynctool --addmember synce-sync synce-opensync-plugin
    $ msynctool --showgroup synce-sync

    If these steps fail, check the output from --listplugins
    $ msynctool --listplugins
    Available plugins:
If you upgrade sys-apps/hal to >= 0.5.13 (which is now in ~x86) you will have to compile synce-hal again. This is because the hal scripts directory has changed, and synce-hal only detects this at install-time.

Errors similar to were fixed for me by following the steps above.

Let me know of your success / failure. SynCE 0.14 will be in portage in the fullness of time!

Way to go, Arch

KDE 4.3 is available in Arch already. If the Arch MB is to be believed, it was available for install a few hours before KDE even announced it. Good job Arch devs. Arch seems to have pretty fast turnaround on new packages.

The stable release of KDE 4.3 is looking good too. I wiped my KDE profile because I think I've been running the same one since KDE 3.1 and the cruft was becoming noticeable. That helped resolve a lot of things (I can add widgets to the main panel without crashing things now).

One thing that has caused me tons of problems historically is CJK input in KDE. In KDE3 Skim worked OK, but I couldn't get it to work in KDE4. Instead there's UIM which so far has been better than Skim in terms of stability and predictability of interface.

As per a comment by knef on a recent post, you can set per-desktop wallpapers now (as in virtual desktops, workspaces, whatever you call them). You have to:

  1. Zoom out (via the cashew)
  2. Hope it doesn't crash
  3. Go into the Plasma options there
  4. Pray it doesn't crash
  5. Enable the setting to make each desktop have its own "activity"
  6. Yeah you probably crashed right here. In the off chance you didn't crash, once you zoom in you can set per-desktop wallpapers now.

Not just wallpapers, but widgets in general. This is kind of good, kind of bad. If you want to go back to a single wallpaper per desktop, you have to go back and screw with activities. Also I don't think you can "sticky" a widget to span all desktops. It's either everything per-desktop or everything global. I'd bet this will change in future versions.

But I read a suggestion somewhere (probably Slashdot) to set up a different Folder View on each desktop, each pointing to a different folder, and that's actually a great idea. You can set kwin to always open Gimp on a certain desktop and have a folder view of your pictures folder underneath, or something.

Kudos KDE devs, KDE is awesome and keeps getting better.

Posts for Tuesday, August 4, 2009

On crossover work

We are idiots. Most of us. Cause we are trained to be.

When we pick something to study we dive into it, we learn more and more in that specific area. And the world is complex and gets more complex every day, just as much as the topics people work on get more and more specific: You used to study computer science and kinda knew a lot about every branch of computer science but nowadays every branch in itself is pretty much its own little science with its own language, its own concepts and its own … well bullshit.

And that is not a computer science specific problem: In order to know enough about one specific thing we dive into that topic. If we don't we might not be able to solve our problems or we might not pass our exams. Even schools (at least here in Germany) allow pupils to drop certain things they don't like, allow pupils to specialize.

Specialization is something our society loves: Whenever a problem emerges we ask the experts, the specialists, cause they know what to do, right? They've worked so much on that topic, they will make the right recommendation or decision.

But our focus on experts has a dark side, too: We lose the overview; our focus on the details blurs our views on the general.

The problem is simple: Everything is connected, everybody is connected. I have said this in a post before: Nobody is an island. And our actions aren't either.

I studied computer science and philosophy. For my dissertation I am currently diving into social science and systems theory and guess what? It's fun. We tend to chose simple ways to learn new stuff, we choose areas that are connected to what we already know, but I can just encourage you to make a leap: Learn something that has nothing to do with your normal area of expertise.

Don't listen to naysayers telling you what a waste of time it is, how unproductive it is. When getting into a different topic you learn now ways to think, new perspectives and you will start seeing your old knowledge in a new way, you will find new connections, new ideas on how to mix stuff up will form.

Focussing only on one thing limits what you can do in that area. The more you specialize on one topic the less creative you will be in that area. We need input to be great, new ideas, perspectives, thoughts. And those come from connecting the unconnected.

Hello Planet KDE!

Hello all KDE users out there! If nothing got borked in the process this blog post should be aggregated in the Planet KDE feed :)

Obviously, this is my first post, and that warrants some introduction to any new readers out there.

My name is Dion Moult, I am a KDE-user (running on my favourite flavour Gentoo) and have joined Hans Chen in his path to become a KDE developer. My posts would document my progress and should be interesting as we do come from very different backgrounds. I actually described a bit about myself in my first post about “The Road to KDE Devland Moult Edition #0” – so I don’t see any benefit of repeating myself here.

The posts that appear here will be manually filtered from my blog posts with the tag “planetkde” – this means that you will not benefit from the vibrant and unpredictable publications on the full monty of my blog, but this should still add to the community that KDE has managed to create – something unquantifiable relative to “lines of code”.

In case you bothered to click that link to my first road-to-kde-devland post, you would know that I do graphic design too – and since nobody likes walls of text, here is a blue-ish wallpaper dedicated to KDE (not really, it was a design I had started on then stopped because I didn’t like it) and of course, it’s made with GIMP (sorry haven’t tried Krita yet):


In a nutshell: “hello” (I really should apply for law school or something)

Related posts:

  1. The Road to KDE Devland (Moult Edition) #0

Computer e-Recycling (an I.T. WTF Odyssey)

Story Time: Computer e-Recycling

an I.T. WTF Odyssey

I had the displeasure of working at an erecycler several years ago. Even watching stuff come off the trucks, it was very hard to get anything before it was utterly destroyed by the yard goons. Inserting a forklift blade into a 19″ rack cabinet was common practice and I witnessed on numerous occasions the dropping of them in this fashion. Once, they even rolled a forklift off the ramp. These events were always followed by a flurry of Spanish profanity and I usually had to check my pants for continence afterward from laughing so hard. It is a miracle nobody has ever been seriously maimed there to the best of my knowledge.

The highlight of this job experience was when the greedy goons resold a defective Siemens blood handling instrument of some sort that was sent specifically to them to be destroyed (as was EVERYTHING, in theory). The serial number was traced back to them and there was an all out shitstorm. A team of inspectors was flown out from Germany. The goons put on a particularly hilarious show buying hardhats, safety vests, warning signs, identification badges, and more. Somehow, they kept the contract (it was probably just “check you ass” on Siemen’s part — dumping obsolete X-Ray, MRI machines, medical waste, etc for free must be hard to pass up) and all of this change disappeared within a couple days.

What is remarkable is that the above business got multi-millions of dollars of inventory for FREE every year. I really can’t think of any other business model like it. The owner is completely incompetent and morally bankrupt. Very little was put back into the company’s facilities, employees (except maybe a couple at the top), or development. None of the employees had an IQ above room temperature, and everybody seemed content to keep it that way.

There is a happy ending though. A skid of IBM RS/6000 7012 systems from Intel came in at one time. Among the 20-30 machines was a lone -397 that I snagged. This is my favorite collectors box to date (it is the same POWER2 CPU type used in the famous Deep Blue super computer).

Share and Enjoy: Digg Slashdot Facebook Reddit StumbleUpon Google Bookmarks Print this article! E-mail this story to a friend! Turn this article into a PDF! TwitThis

Related posts:

  1. One Small Step for QT, One Giant Leap for Free Software QT Software, under the graces of Nokia, has released the...
  2. Retrocomputing for Fun and Profit Buy Old Computers ??? Profit What is retrocomputing? I...
  3. Xen 3.3 in RHEL/CentOS 5 and more Link Aggregation Fun RHEL 5 includes the now ancient Xen 3.0 hypervisior.  A...


Introduction to Twelf

I always spend some time during my summer holidays learning a new programming language. First was Python a couple of years ago, then Ruby and finally Haskell last summer. This summer I have decided to learn Twelf. The only reason that I have heard of Twelf is because of my friend, Jesper Louis, who keeps talking about it, due to his use of it for our Ex-SML project and this really annoyed me because I did not know what he was talking about.

Twelf is very different from any other programming language that I have ever played with. Twelf is an implementation of the logical framework – called LF – and it is used for logical programming and to formalise programming language theory.

From Twelf’s website:

Twelf is a language used to specify, implement, and prove properties of deductive systems such as programming languages and logics. Large research projects using Twelf include the TALT typed assembly language, a foundational proof-carrying-code system, and a type safety proof for Standard ML.

Twelf’s website is very useful and is, honestly, the only website available on the internet with a plethora of information about the language. You can find some decent tutorials if you look at some of the university websites out there (CMU especially has some very interesting slides about Twelf on their website).

I am going to give a short example on how to implement the factorial function in Twelf and hopefully this will enable you to understand Twelf a bit better than before you read this post.


There are tons of small examples on Twelf’s website, but here is another one. We are going to implement the factorial function in Twelf. The factorial function is, for functional programming languages, what “Hello World” is for imperative programming languages – the first function you will see when you open a book about the language.

The factorial function can be defined recursively as this:


That is easy to implement in most programming languages. In a functional programming language, like Haskell, it can be implemented with pattern-matching so:

factorial :: Int -> Int
factorial 0 = 1
factorial n | n > 0 = n * factorial (n - 1)

In particular, notice how much the pattern-matching method looks like the formula listed above.

It is nowhere near as easy to implement this in Twelf. The first issues we will encounter are:

  • Twelf has no knowledge of numbers. We really take that for granted in any modern programming language (for a very good reason: adding numbers to a language every time you have to write anything feels a bit like reinventing the wheel over and over again);
  • Twelf has no arithmetic operators at all. We need to define all of those and the numbers via the type-system of Twelf.

The Natural Numbers

The first thing we need to define is the natural numbers (equation). We are going to do that with Peano axioms which map well into the Twelf type-system. First we need to define a type for the natural numbers, and then two relations for it.

In Twelf we write:

nat : type.
nat/zero : nat.
nat/succ : nat -> nat.

This says: nat is a type, nat/zero is of the type nat and is going to be the type that represents the natural number zero, nat/succ is the successor of the former natural number. This way we have zero as nat/zero, one as nat/succ nat/zero, two as nat/succ (nat/succ nat/zero) and so on. It is already beginning to get a bit disturbing, right?

We also need to be able to perform some basic arithmetic on the Peano numbers. We have to implement both addition and multiplication (since the latter requires the former) to be able to finally implement factorial in Twelf.

Addition on Peano numbers is defined recursively as:


We need to convert this from the infix-notation above to something that fits into Twelf (Twelf is able to do infix-operators via the %infix-statement). Putting it together in Twelf will result in this:

plus : nat -> nat -> nat -> type.
plus/zero : plus nat/zero B B.
plus/succ : plus (nat/succ A) B (nat/succ C) <- plus A B C.

Multiplication is defined using addition and this is also done recursively, like so:


And in Twelf:

mult : nat -> nat -> nat -> type.
mult/zero : mult nat/zero B nat/zero.
mult/succ : mult (nat/succ A) B C' <- plus B C C' <- mult A B C.

The only operation that we are missing is to be able to do equation, which can easily be defined with:

pred : nat -> nat -> type.
pred/s : pred (nat/succ A) A.

This works for what we are going to use, but it won’t work for someone who decides to do a equation, since our system does not have any knowledge of negative numbers. However, we are never going to reach this in our factorial function (since we have a case for equation) and we are simply going to ignore this issue for now.

The Factorial Relation

The final relation that we have to define in Twelf is our factorial-relation, which can be defined in the form of the previous defined relations thusly:

factorial : nat -> nat -> type.
factorial/z : factorial nat/zero (nat/succ nat/zero).
factorial/s : factorial N R <- pred N N' <- factorial N' R' <- mult N R' R.


Twelf has a very nice declaration called %query where we can query (Prolog-style) a relation for a value. In most programming languages, we are used to functions being one-way. For instance, a function takes an argument and returns a value. With Twelf you can do it the other way around and ask for the input value for a given output value.

To query Twelf for the value of X in the equation equation, we write:

%query 1 1 plus (nat/succ (nat/succ nat/zero)) (nat/succ nat/zero) X.

And Twelf will reply with the answer:

---------- Solution 1 ----------
X = nat/succ (nat/succ (nat/succ nat/zero)).

One thing I discovered pretty quickly after I started playing around with Twelf, is that it becomes really tedious to work with Peano axioms like this. To make it a bit less annoying you can do the following:

0 : nat = nat/zero.
1 : nat = nat/succ 0.
2 : nat = nat/succ 1.
3 : nat = nat/succ 2.

And so on. This makes it possible to use “normal” numbers in your queries, but the answer will still be in the annoying format.

Getting the result of the factorial relation can be done in the same manner. With factorial we have two interesting cases. One where the input is zero and one where the input is larger than zero.

The output from Twelf with equation and equation:

%query 1 1 factorial 0 X.
---------- Solution 1 ----------
X = nat/succ nat/zero.

%query 1 1 factorial 3 X.
---------- Solution 1 ----------
X = nat/succ (nat/succ (nat/succ (nat/succ (nat/succ (nat/succ nat/zero))))).

Both results are correct, but you will soon begin to hate the output-format – especially if you start trying with an equation larger than equation.


Twelf is fun to play with, but I do not have much use for it other than to be able to read the code. It is worth playing with if you want to try “a completely different programming language”.

We are going to use it in the Ex-SML project (a Moscow ML fork using LLVM as backend) to prove that the internal Lambda language is actually type-safe. Currently Moscow ML converts SML into the (currently) untyped Lambda language before it is turned into bytecode that runs on a virtual machine named Zinc. Our problem is that LLVM’s assembly language is typed, so we actually need to keep the type-information during every phase of the compilation.

Week of bash scripts – Extract

HeaderIf you didn’t tune in yesterday, the second script follows the first:


Instead of crush there is now extract. This script was originally written by brisbin33 in the Arch forums (beautiful work man) and is slightly-modified. It will extract most compressed file formats. Syntax is:

extract <compressed-file.ext> <*location>

If no location is given, it extracts in the current directory.

#!/bin/bash # extract - extract common file formats # Author: Gen2ly # Text color variables TXTBLD=$(tput bold)     # Bold TXTUND=$(tput sgr 0 1)  # Underline TXTRED=$(tput setaf 1)  # Red TXTGRN=$(tput setaf 2)  # Green TXTYLW=$(tput setaf 3)  # Yellow TXTBLU=$(tput setaf 4)  # Blue TXTPUR=$(tput setaf 5)  # Purple TXTCYN=$(tput setaf 6)  # Cyan TXTWHT=$(tput setaf 7)  # White TXTRST=$(tput sgr0)     # Reset # Usage - display full argument if isn't given. if [[ -z "$@" ]]; then   echo " extract <compressed-file.ext> <*location> - extracts common file formats"   exit; else   if [ -f $1 ]; then     echo " Extracting ${TXTBLD}${TXTRED}$1${TXTRST}"     case $1 in       *.7z)       7z x $1              ;;       *.tar)      if [ -z $2 ]; then                     tar xvf $1; else                     tar xvf $1 -C $2                   fi                   ;;       *.tar.bz2)  if [ -z $2 ]; then                     tar xvjf $1; else                     tar xvjf $1 -C $2                   fi                   ;;       *.tbz2)     if [ -z $2 ]; then                     tar xvjf $1; else                     tar xvjf $1 -C $2                   fi                   ;;       *.tar.gz)   if [ -z $2 ]; then                     tar xvzf $1; else                     tar xvzf $1 -C $2                     fi                   ;;       *.tgz)      if [ -z $2 ]; then                     tar xvzf $1; else                     tar xvzf $1 -C $2                       fi   ;;       *.rar)      7z x $1              ;;       *.zip)      unzip $1             ;;       *.Z)        uncompress $1        ;;       *.bz2)      bunzip2 $1           ;;       *.gz)       gunzip $1            ;;       *)          echo "${TXTBLD}${TXTGRN} * ${TXTRST}Not a supported file format." ;;     esac   fi fi

Wikipedia, You Scare Me

Weird Al's newest song has been on Youtube for less than 30 minutes and already the Charles Nelson Reilly page has been updated with a link to it.

How long is it going to be before the internet acquires a physical body and rules over us all?

Adventures in blogging

So my newest site is about pareidolia which I think is an interesting subject. It's still in its early stages, using a data import from yet another of my old sites that I ran with a friend of mine. This makes three websites I'm running out of the same JVM on my server now. It'll be interesting to see how many more I can cram in there before my VPS explodes. CPU and RAM utilization are still supposedly minimal. I actually plan to redo my old faltering FF1 site entirely in Clojure too, which is probably the largest Clojure project I plan to undertake in the foreseeable future.

I'm still trying to come up with some kind of "how to make a blog in Clojure" tutorial once I nail down a good way to do it. The code for my blog has "grown organically" (i.e. become a mess) beyond the point where I'd inflict it upon the world without substantial cleanup. Probably easier to start over from scratch with something that's more demonstrative.

I'm also not too savvy on many of the "right ways" to do things in Compojure, as per this discussion. That's the good and bad thing about using a Lisp. You can pull off almost anything. There is no underlying structure to the code other than structure you impose. It's easy to write a mess.

Posts for Monday, August 3, 2009

A week of bash scripts – Crush


Hello blogweb. This week I’ll be posting some of my bash scripts that I use on a regulare basis. I’m not sure I’ll get to every day but I’ll do what I’m able. With that:


I tend to do quite a bit of compressing files for uploading and I cannot always seem to remember the options and order of those options that tar needs. So I built a bash script that does it for me. I call it Crush and it’s syntax is basic:

crush <file1> <folder>… <archive-name>

If no archive name is given, crush will use the name of the last file entered.

#!/bin/bash # crush - archive and compress file/folder(s) # Extract last parameter (archive filename) for variable ARCHIVENAME="${!#}" # Remove last paramerter (archive filename) for file/folder list to compress length=$(($#-1)) FILES=${@:1:$length} # Usage - display usage if no parameters are given if [[ -z $@ ]]; then   echo "crush <file> <folder>... <compressed-name>.tar.gz"   exit fi # Tar the files, name archive after last file/folder if no name given if [[ ! -f $ARCHIVENAME ]]; then   tar -czvpf "$ARCHIVENAME".tar.gz $FILES; else   tar -czvpf "$ARCHIVENAME".tar.gz "$@" fi

Desktop Theming & Panels

Recently I’ve spent some time playing around with the theme and panels I use. I haven’t changed much from what I’ve been using for a while, but there were a couple of subtle changes.

Here’s what I’ve ended up with, on my laptop at least (from the default Ubuntu 9.04 settings):

  • Industrial Tango theme (apt: industrialtango-theme).
  • Compiz desktop wall, expose and scale plugins.
  • Reduced font size to 8pt for everything except window titles which is 9pt.
  • System monospace font set to Terminus (apt: xfonts-terminus).
  • 6 virtual desktops (3×2 grid)
  • Auto-hide bottom panel, which contains only a window list. Other panel items from here either get removed or moved to the top.
  • Customised applications menu, as I have some software not installed with APT.

It’s intentionally quite minimalist since I don’t like a lot of visual clutter. The window list is fairly redundant since I use the expose/scale plugins or alt+tab most of the time – hence the panel gets hidden. I have 6 virtual desktops for two reasons: I often have lots of windows open and to reduce the impact of being on my laptop and hence without 2 screens.

I’m still undecided as to whether I prefer the theme to be light or dark overall, especially having seen the Ubuntu Dust theme, however for the moment I’ve settled on light.

Here are some screenshots (click to view full size):









Making image thumbnails in Clojure

I'm making a new website (in Clojure of course) and I have a need to resize uploaded images to make thumbnails. At first I tried to use JMagick because I'm familiar with ImageMagick already and it seemed like an OK library. But on the crusty old OS my VPS uses, I had a really hard time getting it to build, and even once it built it started segfaulting like mad.

Should've gone with something simpler first. Java has built-in libraries for this. It only took a few seconds to adapt this code on Stack Overflow into Clojure code.

(use '
(defn make-thumbnail [filename new-filename width]
  (let [img (javax.imageio.ImageIO/read (as-file filename))
        imgtype (java.awt.image.BufferedImage/TYPE_INT_ARGB)
        width (min (.getWidth img) width)
        height (* (/ width (.getWidth img)) (.getHeight img))
        simg (java.awt.image.BufferedImage. width height imgtype)
        g (.createGraphics simg)]
    (.drawImage g img 0 0 width height nil)
    (.dispose g)
    (javax.imageio.ImageIO/write simg "png" (as-file new-filename))))

Slow Window Resizing with KWin Compositing on FGLRX

Amongst users of the proprietary ATI driver (FGLRX), it’s a well known problem that KDE4’s KWin’s desktop effects are unusable due to turtle slow window resizing. Unfortunately, bug reports and forum posts fail to come up with a clear answer as to why this happens, who is responsibility for fixing it, and which parts of the stack need to adapt for the bug. If you’re not already familiar with the problem, observe:

Direct YouTube Link

As you can see, the three second delay in window resizing, maximizing, and (perhaps) restoring makes compositing-enabled KWin unusable. Note that the problem still persists when disabling the “show window content while resizing” option.

It’s been particularly difficult to track down the route of this problem and who should be fixing it. From a lengthy discussion on Phoronix’s Forums, ATI’s “Bridgman” user acknowledges the problem but claims “It’s not a driver issue AFAIK, so not sure why we would mention it in the release notes.” He goes on to indicate that the problem was introduced during a hack to ensure KWin compatibility on Intel cards, to work around a glitch with garbage appearing on the screen, and a lengthy debate over the “107_fedora_dont_backfill_bg_none.patch” patch. Somewhere the stack was patched to support Intel cards at the expense of ATI cards, according to ATI’s “Bridgman”.

Over on the KDE bugzilla, we’re met with a curt response from the KWin team: “Driver bug then.” The bug is marked as “RESOLVED” and “UPSTREAM”.

And elsewhere on the Internet, we get a helpless string of “still not fixed” messages, over on the unofficial FGLRX bugzilla, other Phoronix forum posts, and distro forums.

So I ask my readers: who is responsible for this bug and how will it be fixed? If indeed it is neither FGLRX nor KWin and the problem exists in XOrg, why has XOrg been patched to support Intel cards at the expense of ATI cards? Is there anything FGLRX or KWin could be doing to mitigate the problem? Potential workarounds? Users have complained of this problem for over a year now perhaps, but not once has leadership from anywhere offered a compelling explanation or plan for the future. What to do?

Leave comments. The current discussion seems to be fruitful.

Posts for Sunday, August 2, 2009

Better Fox, Cat, and Weasel


When I get my Firefox (Icecat, Swiftweasal…) up and running these are the tweaks I do get Firefox performing how I like it.


A few of these changes can be done in Firefox’s configuration page. Type ‘about:config‘ in the address bar to get to it.

Disable accidental middle clicks

Firefox by default will open a page in a new tab if you middle-click a link. However if you got something in the register (clipboard) and miss the link Firefox will try to load whatever is in the clipboard and you will usually get a “Firefox cannot find the page” message. To disable this set:

middlemouse.contentLoadURL false

New tabs loaded in the background

browser.tabs.loadDivertedInBackground true

External editor to view html source

view_source.editor.external true
view_source.editor.path /path/to/editor

One click to select all in address bar

browser.urlbar.doubleClickSelectsAll false
browser.urlbar.clickSelectsAll true

Disable zooming of images

Though I like the proportionality of images that zoom with text I often just need to read the text.

browser.zoom.full false

If the DPI for your monitor is lower than 96 DPI:

layout.css.dpi 0


I generally don’t add add-ons to keep my firefox light but there are a few I can’t do without, the first primarily being:


NoScript blocks javascript by default. Blocking javascript will disable Flash, roll-over text adds, and alot of things. While javascript can be very useful it can also expose vulneralbilities (like the Firefox 3.5.0 exploit bug). I find it best to to use NoScript and then just allow the javascript I need.

Find Toolbar Tweaks

When I search a page I like all the matching text to be highlighted, Find Toolbar Tweaks does that.

Highlight Focus

I have a problem on when I switch back to Firefox of typing ‘/‘ to look for text on a page but often the focus is in the address bar or the search bar. While I have never found a way to fix this Highlight Focus will highlight the current text box in browswer box itself.

Everything together:

Thanks to all this week that helped to find all these things, and made my life better :).

Posts for Saturday, August 1, 2009

Being a computer hobo

Being a homeless geek (i.e. without my own computer) is neither fun nor easy, but there's a few tricks that I learnt on the way. Here I'll try to share a few that I can remember of and comment them as well.

Most of the time my dad lends me his (Windows XP, brrr) laptop, but of course I cannot expect this to be true all of the time, so I had to find a solution that would a) let me move my data from different computers if needed and b) leave my dad's computer as clean of my clutter as possible.

Then I found (again actually, but forgot about it) PortableApps because they were nominated for's community awards. What they do is take FOSS programs, hack them so they're both smaller and that they store all their settings, cache and other files on the USB key itself. And this is all bundled into a menu launcher that can be ran under Windows.

The first try I gave it was quite pleasant, but on my little 256 MiB USB key I couldn't fit OpenOffice, if I wanted to have space for other applications on it and some for my documents as well. So when Ike (a friend of mine, co-geek and co-lawyer) gave me a spare 1 GiB key, I quickly formatted it and installed more apps on it, including OpenOffice Portable and for the moment use that as my primary

All in all I'm quite happy with the solution. It's relatively elegant, not too wasteful of resources and it's surprising how much apps you can fit on a stock USB key!

Here's what I currently have on it (with comments):

  • 7-Zip (compressing tool) -- so far managed to work with everything that I could throw at it, but the GUI leaves a bit to be desired
  • CoolPlayer+ (music player) -- reminds a lot of early WinAmp and XMMP; doesn't seem to have many features, but works; the on-top, minimal/shaded view brings back nostalging memories ;)
  • Cornice (picture/album viewer) -- small and simple image viewer; again works, but don't expect a DigiKam, Gwenview or Picassa killer
  • DOSBox (DOS emulator) -- heh, I felt like playing some of my old DOS games ;]
  • Firefox (web browser) -- I still miss my Konqueror, but it's nice to have a pimped up FireFox to carry along with all the bookmarks, history and plugins
  • GIMP (image manipulation tool) -- the Windows version of GIMP, 'nuff said
  • Infra Recorder (CD/DVD burning tool) -- I haven't had time yet to test it, but from the looks of it, it seems quite nice; actually seems a lot nicer then most "free" (as in beer) burning tools for Windows
  • MPlayer (video/media player) -- the GUI looks rather ugly, but I've seen worse; otherwise works quite nicely; so far I didn't have any problems with the bundled codecs (I did with Windows Media Player though)
  • Notepad++ (text editor) -- rather advanced text editor; has tabs, syntax highlighting and plugins; I still like Vim and Kate a lot more, but I'm quite happy with it
  • OpenOffice (office suite) -- the whole OpenOffice packed into a small package; works just nicely; I could open my ODT files that I made in KOffice almost perfectly (one tabulator was missing, content and styling was fine), while when I tried AbiWord, it was completely garbled
  • (IM client) -- I'm usually using Kopete and Konversation (or Finch and Irssi when in the console), but I found using Pidgin for IM on Windows to satisfy my basic needs and runs nicely all the protocols I use; IRC-wise it shows the downsides of pretty much all IM clients that support IRC
  • PNotes (sticky notes) -- similar to KNotes, but it's harder to manage notes in it; does it job, but not sterling
  • PuTTY (SSH/Telnet client) -- essential for accessing the server; works like a peach
  • SpeedCrunch (advanced calculator) -- great calculator; exceeds my needs, but has all the features I need; I use it under GNU/Linux as well
  • SumatraPDF (PDF viewer) -- small and simple; so far opened all PDF I needed; GUI is not too nice and the full-screen shortuct (Ctrl+L) is not the most logic IMHO
  • Thunderbird (+ Lightening plugin) (e-mail/RSS reader + PIM) -- not bad, but still like KMail and the whole Kontact in general a *lot* better; handling mailing groups and filters is still inferior to KMail; e-mail scam prevention is a nice touch; RSS doesn't seem to be too predictable at times and is hard to organise; it's great that it has OPML import though, so I could just import my backed up Akregator list; adding events and tasks doesn't feel nice, although I like the time selection menu; overall the PIM bit feels quite rough, but it gets the job done I suppose
  • WinSCP (FTP/SCP client) -- essential to up- and down-load files to and from servers and other boxen via SSH or FTP
  • Xenon (file browser) -- small, tabbed browser; slow; pop-ups not informative enough (e.g. on deletion, copying etc.)

Also it'd be great if PortableApps would tweak the apps so that if they'd see that certain apps are also installed on the USB key that it would default to opening the according MIME types with the portable apps instead of locally installed ones. One such annoyance is that I cannot seem to convience Thunderbird Portable to open HTTP links in Firefox Portable, instead of the one installed on the laptop's harddrive. It'd be also great if it was possible (probably I just don't know how) for the user to tweak the PortableApps menu to e.g. manually remove all the OpenOffice component entries and just leave the OpenOffice suite entry.

The music I still get mainly from Jamendo and lately BlocSonic, so with the above tools and the free content online (and backups on SpiderOak) I somehow made myself a small shed on my lil' USB key, until I find a new home.

hook out >> going to bed

P.S. Another cool project (that sadly didn't win) is RepRap -- a FOSS powered and following FOSS principles 3D printer.

Planet Larry is not officially affiliated with Gentoo Linux. Original artwork and logos copyright Gentoo Foundation. Yadda, yadda, yadda.