Posts for Sunday, April 25, 2010

avatar

qbook

This morning I was up rather early (well not that early but the others were still asleep ;) ). So I decided to do a little coding and came up with a very simple Qt desktop client for facebook. Since it would of course be nice to have client sitting in your task bar showing new notifications, later this can be extended but for now that will do.

All this was created in a about an hour but would not have been possible without qfacebookconnect.

It is far from finished and no notifications are really visible yet but a nice start is made (not bad for 45 minutes coding). See the git repository of qbook if you want to take a peak, all paths are currently hard coded so you will need to do a little hacking, this is mainly because qfacebookconnect is not yet in portage so I can properly link to it.

Maybe next time when I am up early I will first fix an ebuild for that one :D

Posts for Thursday, April 22, 2010

An experiment about rules

So after some recent events I thought it would be fun to combine three things I really enjoy in one blog post:
  1. Doing an experiment
  2. Drawing awesome pictures
  3. Pissing some people off

Now as you will see, while I do have some skills in two of those areas, one of them is not exactly something I am very talented with but it's my blog so nobody can kick me out for sucking (yet another reason everbody should have a blog ;-)).

Let's just start with one of my brilliant, awesome, artistic and heartwarming pictures:

Pretty, isn't it? And (as any piece of art) it is open for interpretation: Maybe the person depicted is a clown working every day at the Happy-Fun-Land amusement park, maybe he's a Doctor curing cancer, maybe it's not a dude but a woman, maybe a model on the catwalk or Computer-science-Barbie come to life. It's up to you my dear reader to think of something, I just ask you to think of something cool. You got a minute, I'll wait.

Thought of something? Great! Then let us continue with the experiment, which will blow your mind. I can piss people off by just adding a word to the image.


BAM BAM BAAAA. Now the picture depicts the Prophet Mohammed which is forbidden by the rules of the Islam and opens me up for being burned in hell or at the stake or somewhere. Am I a rude fuckhead for posting this?

Let's look at yet another picture:


This is a picture of the judeo-christian god. The 10 commandments state explicitly that
"You shall not make for yourself an idol, whether in the form of anything that is in heaven above, or that is on the earth beneath, or that is in the water under the earth."
which is a very similar rule though it does not bring the hate and flames that depicting Mohammed does.

Now this is not a pisstake on the Islam or a sign of how much better Judaism or Christianity are. Let's look at a few aspects of what happened.

What we see is that there are more than just one religion that forbid the creation of idols and that is pretty much exactly what a rule like "don't depict the prophet Mohammed" is about: Don't make you deity or holy people comic book characters, keep them abstract to avoid having too "worldly" gods like for example those the greeks had, gods that stole, lied and fucked around. From that background the rule itself isn't bad (always given the fact that you subscribe to some sort of religion).

But some people seem to consider any picture displaying the Prophet Mohammed heresy and whatnot, consider any picture like that an insult to their religious belief. Those people don't seem to understand the intention of their own rules: Your religious rules don't apply to people outside of your own religion, they are meant for you to support your belief and make sure that you don't stumble off the way. Complaining that some atheistic guy in Germany drew your Prophet is like a Jew complaining that some Christian is eating non-kosher meat: Retarded.

That does not mean that there might not be pictures of your prophet that can be considered insulting or propagandistic but most of them aren't. And if people who are not believing into your religious concepts do make some fun about it (as in satire) that is also fair game, just as you can think that we of the "wrong belief" will all go to hell or whatever punishment you can come up with. We can make fun, you can feel better than us. And everybody wins.

Rules are important and are what makes many of the constructs of our society working but rules have a wording and an intention and especially what you and your club come up with new rules make sure to think of them as something that has an intention and not something that has to be followed by the letter.

The Zen of Python (a set of rules or principles for Python) has two notes about exactly this problem:
Special cases aren't special enough to break the rules.
Although practicality beats purity.

Yes you have rules and you should try to apply them in a generic way but at some point you need to use your brain and understand what the rules was meant to achieve in the first place. I tired of having to explain these simple things. If your god is so smart why didn't he make everyone smart enough for these things?

Well I hope I didn't insult too much here. Let the flames come in the comment section ;-)

Posts for Wednesday, April 21, 2010

Apple

Two years ago, I purchased my first Apple product. After the iPhone had dropped in price from $599 to $299, I was able to afford one. I purchased the white iPhone 3G 16GB model. I was amazed at the speed and ease of use. The iPhone was and is definitely a revolutionary device. Before the iPhone, most smartphones were very primitive. The iPhone was the first phone to implement multitouch and the first phone to implement a touch screen in an easy-to-use and user-friendly way.

I am very impressed with the iPhone. I upgraded to the white iPhone 3GS 32GB when it was released last summer. The speed of the 3GS was amazing and the battery life was decent.

In November, my Dell laptop died and I had many bouts with Dell over receiving a suitable laptop for my needs that was comparable to the one that I originally had. After Dell was unable to offer all that I needed, I decided to buy a MacBook Pro and sell the one that Dell gave me. I had had it with Dell and Windows in general. I wanted to move to a sleek, simple interface that offered the robustness of UNIX. Mac OSX is perfect for that.

Three days ago, my MacBook Pro arrived. It is absolutely amazing. It is fast and simple to use. Everything about it is polished beyond belief. I have no major or minor complaints so far. I have been adjusting some to the new UI and the new way of finding things.

Installing applications is just as easy as downloading a single file and dragging it into the applications folder. *.dmg files are really just CD/DVD images, so burning a program to a CD/DVD is extremely simple. The OS takes care of all of it for you. Additionally, the $70 Magic Mouse is definitely worth the purchase. I like it because I can use it left-handed easily. I also like the multitouch functionality of it. I’m blown away by Apple’s OS.

It is no marvel that Apple yesterday reported their best non-holiday quarter ever.

The only thing that I must shun Apple on is their unwillingness to open source their products. That is it.

Here is a screenshot of my workspace. I currently have my MacBook Pro connected to my TV VIA Mini DisplayPort -> HDMI.

Posts for Tuesday, April 20, 2010

DD-WRT: 1, Microsoft: 0

An xbox360 wireless card is $100, and it's theoretically the only wireless card that works with an xbox, so if you want wireless internet, you have to buy that card. I guess the idea is to sell the console cheap (for sufficiently large values of "cheap") and then gouge customers on proprietary cables and addons afterward. Microsoft isn't the only company that does this, by far. (Not nearly as bad as $20 for 8MB worth of PS2 memory card. Ughhhh.)

Fortunately, if you have a spare Linksys router lying around (as I do) you can throw DD-WRT on it, put it into Client Mode, connect your xbox to the router via a bit of ethernet cable, and there you go. I can also plug my aging desktop machine (sans wireless card) into the same router, and two other devices if I can find any.

Installing DD-WRT was surprisingly straightforward if you take the time to read through the wiki instructions first very carefully. A bit of healthy paranoia of turning your hardware into a brick goes a long way.

15 minutes, $100+ savings. Thanks again, Linux and open-source community.

No it's not 'logical'

Today we'll be looking at one of my pet peeves and from this you will be able to see a rant coming so let's not beat around the bush anymore and dive into the usual rambling ;-)

When people try to explain something to you the probability of somebody saying a phrase like "But it's so logical!" approaches 1. They might be telling you the way to a point of interest or their way to paint a bikeshed, it doesn't matter. Everything is always logical.

The adjective "logical" means that something behaves according to the laws of logic which luckily are not all that many: You take true and false, add variables and a bunch of operations like "and" and companions and you have what we call logic.

There are a few different approaches to what logic actually is: Some believe that Logic is the one structure that can never change, that is true for every conceivable world, others believe that we see logical structures behind things because our brains are hardwired for logic. Either way: Logic is something you have a hard time arguing with because a logical term has the useful property to be either true or false.

But why is it that when after a 3 hour lecture on how to properly organize a directory layout somebody talks about how his/her opinion is oh so logical we hear nothing about "true" or "false" and also no logical operations? Because we've been bullshitted. Opinions hardly ever have anything to do with logic, what people mean when they say "It's logical" is "I personally find that rather plausible." But since they claim to base their opinion on logic you cannot argue with it anymore.

It's actually a neat trick to win an argument. The best thing about it is that you don't have to understand any logic, you can just magically make your opinion "logic". How useful and how much better than spending the time to understand what logic means and how it's different from opinion and plausibility.

Just repeat after me: Logic does probably not mean what you think it means. Write it a hundred times.

Posts for Saturday, April 17, 2010

DFD 2010 in Slovenia — report

The first Document Freedom Day in Slovenia has passed and it went pretty good.

I know that for the biggest impact I should have reported about it the very same day or at least the next one, but a) I was too tired b) I had to much other important tasks to do and c) I wanted to gather everything so I can submit a nicely rounded off report. Warning: longer post ahead.

The impatient of the more audiovisual persuasion can check out the photos of the DFD cake transfer at the Supreme Court here, the evening event's pictures on Kiberpipa's Flickr account and the lectures and the Q&A session on their video archive. Others read on.
<!--break-->

DFD Cake

Quarter to eleven a group of us (Katja Guček, Rok Papež, Igor Kolar and me) met in front of the Court palace in Ljubljana. Despite heavy rain and some shenanigans including our cake, the court's security x-ray scanner and several people giggling, the cake reached its destination safe and sound. There we met the representatives of the Supreme Court — Alenka Jelenc Puklavec, (temporary) president of the Supreme Court; Janko Marinko, secretary of the Supreme Court; Gregor Strojin, head of the PR office; Bojan Muršec, director of the Centre for Informatics and head of the open source and open standards projects.

What followed was a full hour of chatting while eating (our) cake and supping (their) coffee not only about the importance of open standards, but — what we honestly did not expect — a deeper insight into how important these are to the courts, their painful experience with closed formats that stopped being supported, how hard they fought to be able to use open formats and open source solutions. What was really touching was how much dedication these people (as well as the Supreme Court's former president Franc Testen and others) have put into this. It showed that the biggest hurdle for the migration to open standards along with some open source solutions was neither finiancial nor technical nor practical, but solely pressure from the politics and the business side.

The courts were also the first in the country to produce a study on how much a migration to open source alternative (mainly OO.o at the time) would cost. It showed — oposed to the later governmental study — that the open source solution would in the longer run cost less, be a lot more reliable and tweakable. In the means of openness as well as in using standards, code and access to and from the people, it surprised us that our courts are at the very top of the EU — on par with the Finnish!

This all shows that our courts trully "get it" — we can only wish the government, parliament and others follow suit!

This is one cake and coffee I think neither party will easily forget. We were reassured of our choice and they were happy that a civil initiative is starting to form to be vocal about the importance of document freedom and free software.

Of course pictures were made and are available here.

The evening event

The event was quite a success as well.

We met in Cyberpipe/Kiberpipa at six in the evening and there was about 25-30 people present all the time. Because the people at Kiberpipa were so kind to record the whole event, I can provide you with the video and audio. The whole event was quite informal and people were mingling and talking while munching snacks between presentations.

After the greeting, I made a short introduction into open standards and open formats [video&audio]. I took the oportunity to promote the FSFE and our Fellowship group a bit as well.

After that Gregor Strojin explained a bit about the Supreme Court's need of open standards and Bojan Muršec held a presentation of the courts' centre of informatics and on how the courts migrated to ODF and OO.o during the years 2003-2006 [video&audio].

The last presentation was held by our Fellowship's own Andrej Čremožnik, who presented several open formats for multimedia and compared them to their proprietary counterparts both technically and otherwise [video&audio].

We concluded the formal part with a round table, giving the microphones also to the public. This resulted in a nice Q&A session [video&audio].

Of course, there are pictures from the evening event available as well.

Media coverage

We could have made even better use of the oportunity, but all in all it was more then good for our first event. A list of internet articles (we found about 20) who mentioned the event is available on the FSFE Wiki. Apart from that the DFD was mentioned in the IT section of Delo (one of the two biggest newspapers in Slovenia) and mentioned on at least two radios. I gave an oral statement for STA, a short live interview for Radio Slovenia International and in the evening Radio Val 202 (both very popular national stations) came to check out the event and interview all of the lecturers. A list of links can be accessed on the Fellowship Wiki.

Althought it was quite a handful, it went good. I hope the rest of the DFD teams had and equally successful day.

P.S. As a cherry on top, we were later told that the rest of the cake went to the IT department — to the people who did the hands-on technical work of migration and everything — where everyone got a piece and they made a small party out of the occasion as well. So the cake was shared equally between the policy makers and the techincal staff. Despite the rain, it could not be a better day for document freedom in Slovenia.

Posts for Friday, April 16, 2010

Printing a nicely formatted plaintext table of data in Clojure

I use this fairly often while data-munging, when I want to quickly view a list of hash-maps of data in a simple table format. Usually this is coming out of database. Maybe someone will find it useful.

(defn table
  "Given a seq of hash-maps, prints a plaintext table of the values of the hash-maps.
  If passed a list of keys, displays only those keys.  Otherwise displays all the
  keys in the first hash-map in the seq."
  ([xs]
     (table xs (keys (first xs))))
  ([xs ks]
     (when (seq xs)
       (let [f (fn [old-widths x]
                 (reduce (fn [new-widths k]
                           (let [length (inc (count (str (k x))))]
                             (if (> length (k new-widths 0))
                               (assoc new-widths k length)
                               new-widths)))
                         old-widths ks))
             widths (reduce f {} (conj xs (zipmap ks ks)))
             total-width (reduce + (vals widths))
             format-string (str "~{"
                                (reduce #(str %1 "~" (%2 widths) "A") "" ks)
                                "~}~%")]
         (cl-format true format-string (map str ks))
         (cl-format true "~{~A~}~%" (repeat total-width \-))
         (doseq [x xs]
           (cl-format true format-string (map x ks)))))))

Then you can do this:

user> (def data [{:name "Brian" :job "Code monkey" :age 29}
                 {:name "Bob" :job "Janitor" :age 97}
                 {:name "Johnny McLongname" :job "None" :age 3}])
#'user/data
user> (table data)
:name             :job        :age 
-----------------------------------
Brian             Code monkey 29   
Bob               Janitor     97   
Johnny McLongname None        3    
nil
user> (table data [:age :name])
:age :name             
-----------------------
29   Brian             
97   Bob               
3    Johnny McLongname 
nil

lessons from “Coders at work”

I already mentioned Coders at work in an earlier entry. The point of this one is not to write a review, but to make a note for myself of what I’ve gotten out of the book. I think I could do better to read more books with a pen and a pad so I have a better chance of exploiting the content.

So these are notes to myself. I wouldn’t take it upon myself to summarize a more general listing of notes that would somehow apply to the average person, because I think we’re all in very different places in the universe that is called “learning to program (well)”, and every person has to figure out for himself what he most needs to learn relative to where he now is.

Advice: Read code

Read other people’s code, “open black boxes“. This is something I never really do, I should start. Just take some codebase and check it out, get used to the practice. Reading code is not the easiest thing to get into, so here are some tips:

  1. First, get it to build.
    Sometimes everything you have to do to build it already teaches you a number of things about the codebase. And once you have it built, you can start making changes to it and try out little things dynamically.
  2. Read while building.
    Making builds for any codebase can be hairy and painful, so parallelize this activity with code reading. Great way to use the time you’d otherwise waste in between debugging the build.

Advice: Write unit tests for new library

You’ve found a library for something that you’ve never used before: how do you figure out how to use it? Write unit tests. Some libraries have bad unit tests (or no tests) to begin with, so it could be a way to improve it. In any case you can test your basic hypotheses of how the library works.

Ideas to investigate

  1. OO and classes vs prototypes (JavaScript).
  2. “There is a lack of reuse in OO because there is too much state inside”. Libraries must expose too much of their innards through APIs, functional programming model should be better at this.

Pointers

Articles:

  1. Richard P. Gabriel – Worse Is Better

Books:

  1. Douglas Crockford – JavaScript: The Good Parts
    In the absence of the book, Crockford’s lecture series on JavaScript is probably a good start.
  2. William Strunk, Jr. and E.B. White – The Elements of Style
    For writing better English.
  3. Steve McConnell – Code Complete
    On software engineering process and best practices.
  4. Gerald Weinberg – The Psychology of Computer Programming

Talks:

  1. Joshua Bloch – How to Design a Good API and Why it Matters
avatar

Notes on setting up Gentoo

I’m installing Gentoo on my laptop – here are some notes (for myself, really).

  • Gentoo installs the flash plugin to a path with “netscape” in it. There is a problem with this http://groups.google.com/group/opera.linux/browse_thread/thread/9e9a3c21cd413c2f/3949ce2e8f96f84a so we need to symlink the plugin to the opera plugin path.
avatar

Geotagging my Flickr photos

Tonight I finally got round to adding my photos to the Flickr mapping feature. I guess I got inspired by taking and uploading my first photo using Zonetags with my phone (Nokia 6680) and my Holux bluetooth GPS receiver.

Zonetags

Zonetags is a trivially easy-to-use beta-ish application for Series 60 Nokia smartphones that acts as a wrapper for the standard camera software. It can record the cell id (I think it uses the last known value if you’re not in reception) and attach it to each photo you take. You can also connect an external GPS device to add much more accurate longitude and latitude information to the photo. Once you have taken a photo you’re asked if you want to upload it to Flickr. If you do, Zonetags can optionally add action tags to do things like rotate your photos as well as suggestting extra tags based on your location and the tags that other people have given to nearby photos.

For example, when I uploaded a photo coming down from Snowdown at the weekend, “Caernarfon” and “United Kingdom” tags were added along with the geotagging and celltagging ones. Over time, this could get really smart.

Unfortunately, my camera can’t use my bluetooth GPS. I think as a workaround way of geotagging those photos, I might also take one with my phone and upload it with private permissions via Zonetags (to get the geotags into Flickr) and just replace the photo with the better camera shot when I get back to a computer. We’ll need to wait and see if that is too much of a pain in the arse to be practical when out in the hills though.

Flickr map

I’ve wanted something like this for a while now – being able to browse photos by location is nifty stuff. It’s super easy to get photos on the map (if you’re using a supported browser, of course…), but I find it is limited by the poor quality of the maps, at least for most of Scotland. Of course, Flickr can’t help this and it will improve given time, but it would all be so much cooler if the maps I use most were worth looking at! There are 3rd party apps that are more accurate or you can hand geotag the photos with the lat/longs yourself and import them instead, but I haven’t bothered looking at any of those options yet since my priority was to just get them all geotagged.

In some crazy alternate reality where I actually have some spare time, I will use the Flickr API in my desktop mapping software to give the same functionality in a faster and much more detailed environment. That’s after re-writing it so that it’s not just a prototype, adding in GPS tracklogging and a million other neat things… sigh.

The good

  • Flickr map is very cool, I like it
  • Zonetags is very cool, I like it

The bad

  • Yahoo! Maps isn’t as good as Google Maps
  • Yahoo! Maps is vastly inferior to Google Maps
  • Scotland has pish quality maps – ces’t la vie
  • Zonetags doesn’t allow you to change your mind and upload a photo you previously took with it – pretty poor
  • My phone/bluetooth/software combination only allows one phone -> bluetooth connection at a time

The ugly

  • The admin map interface doesn’t work in Opera – boo

From that list it looks like I’m not too positive about this stuff, but that couldn’t be further from the truth – it’s excellent and is going to keep getting better.

Update (26/10/2006)

I forgot to mention that I was a little annoyed that Flickr didn’t add geotag tags to my photos when I added them to the map. Last night I found this excellent bookmarklet which embeds Google Maps into Flickr, giving you much more accuracy. It totally rocks. Or, it will totally rock if it starts to work in Opera. For now it just rocks. It adds the geotags as well as giving your photos a link to Google Maps (you can see the singletrack!). There is a little discrepancy between Yahoo! and Google Maps (about 100-200m), but it is definitely preferable for me to use Google Maps for the forseeable future. Now I need to go back through my photos again…

avatar

Migrated blog software (yet again)

I’m checking out Mephisto just now, RSS/Atom readers might have just got some double posts – sorry! I’ve written some more mod_rewrite rules so most of the important old URLs should work fine and, to be honest, I don’t care about any of the more obscure ones.

Recently, I’ve hardly had any time to write here and I hate switching blog software – so why have I done it yet again? Mostly to abandon the downright abysmal Typo and Mephisto offered a simple migration process away from that. So far so good, but we’re a whole two hours in…

We’re also (thankfully!) at least considering using Rails for some projects at work and every little helps when getting back in the swing of things.

Posts for Thursday, April 15, 2010

avatar

Greek spammers email addresses blacklist

GrRBL
In the beginning of the year I announced my RBL for Greek spam emails. The blacklist is growing larger by the day, thanks to some really kind people forwarding me their Greek spam emails, and has reached more than 120 IP addresses of verified Greek spammers.This alone though is not enough.

Why
Some spammers use their aDSL lines which have dynamic IPs to send their massive email “newsletters”. These people are split into 2 sub-categories. The ones that use their own PC as an SMTP server and the ones who use their ISP’s mail server as SMTP. I’ve tried to complain to some of their ISPs…some replied back saying that they were willing to look into the issue (but did nothing at all in the end) and others did not even reply to me. For both sub-categories, GrRBL is ineffective since I can’t add dynamic IPs in the blacklist nor can I add the IPs of the email servers of those major Greek ISPs.

Another category of spammers is the one that uses their gmail/yahoo accounts to send their emails. GrRBL is ineffective for this category as well since I can’t add gmail/yahoo to the blacklist…

What
So there was no alternative but to gather all those email addresses of these 2 categories above and add them to a new blacklist, one that will contain email addresses. I use this blacklist with my spamassassin configuration to eliminate Greek spam that GrRBL can’t. Each time I receive (or someone forwards me) a new Greek spam, I add the “From:” email address to this new blacklist. This new blacklist grows far more aggressively than GrRBL since it’s a lot easier to gather the data and already has more than 140 addresses.

Distribution
There are two available formats of the blacklist, one ready for use by spamassassin and another one with clear formatting ready to be used even by SMTPs to drop these spam emails without even touching your inbox.
The blacklist is currently only distributed to a group of well trusted people and it is available only through rsync with a username/password.

I don’t want to make the list completely public yet, but if you are interested you can request it at the contact email of GrRBL and I will reply to you about accessing it.

Sidenote
If you need a good tool to check a host again some RBLs, adnsrblcheck by Yiorgos Adamopoulos is the way to go (and it includes GrRBL!)

What Happened?

Rant ahead!

Some of you might remember the blog post I wrote almost two years ago about what I do in front of my computer most of the time and why (if not you might want to read it now ;-)). Today I was thinking about how things were back then, and how my view on the whole Open Source topic has changed since.

The three main things I pointed out why I'm so attracted to being actively taking part in the Open Source movement by spending my free time on contributing stuff where fun, interesting people and the rewarding good feeling of getting cool things done and make them available to others.

Recently however, I spend less and less time contributing to projects. And I asked myself why and ultimately came to the conclusion that it's the people:

For me, the people are taking away the fun and without fun there's no reward EOL

Okay, you've read that correctly, now take a step back and let me explain. Of course I don't mean all you nice people I meet over the past years. I'm rather talking about the so called Open Source movement which I think has lost quite a bit of it's shiny glory.

For example, how can it possibly be that the decision of one distribution (I wont drop any names) to change a certain default setting, which every user can change back to his own preference in less than 10sec, can trigger a shitstorm of bad press and whining, about, you know, something you get FOR FSCKING FREE (I really had too allcaps this one, I'm sorry). And all that under the - you're taking away our freedom - flag. We can all agree that this was just one of the many examples how thankfull everyone is about the tools which are provided to us FOR FSCKING FREE and we use everyday to get shit done.

The most common counter argument I heard in the past when I wondered why it is the way it is was:

9 out of 10 people are assholes, just don't worry about them and carry on.

But that ain't that easy. Not with the recently periodically absence of fun and thus reward. The phases I had fun coding stuff compared to the days where I was completely unmotivated have shifted 180 degrees. 2 Years ago I was happily coding on an interesting project for days with one day of demotivation occuring every 2 or 3 weeks. Now I'm demotivated for weeks and experience a coding “high” only occasionally. Ever since that shift became more apparent to me I keep thinking about ways on how to escape this unpleasant situation. I mean, I care about the stuff I'm doing - or don't I?

One thing I tried was to setup a “coding day”. It was just one day of the week where I would try to get my stuff done, bugs fixed, features implemented and new stuff released. This worked for a couple of month. But that phase went away too. As of late I completely switched to what I call slide-mode.

slide.jpg

I simply let it happen and don't force myself to think about my Open Source contributions all that much. Just two weeks ago I had such a moment and a high kicked in and I spit out a good 1000 lines of code for something I had planned to do for a long time (and probably some more people are looking forward to too). Now that unfinished projects sits there, waiting to get finished, but I'm not the least motivated to do it.

Okay one could argue it's really just me, it has nothing to do with the people I talked earlier about. But I tend to disagree. Two years ago I was happy doing this stuff for people (and for myself of course) - today I feel I'm doing it mainly for myself (and for a small group of people). The problem with that is, I don't even use 90% of the stuff I'm maintaining. If I don't do it for the people who actually use that stuff, I do it for nobody, and spending time on “nobody” is quite a stupid thing to do if you ask me.

So, slide-mode isn't the only thing I try to escape my motivational low caused by my lack of understanding for the Open Source movement and it's unique way of showing appreciation for the people who put so much work in stuff (no, I'm not talking about me and yeah I'm exaggerating right now). I cut down the FOSS related blogs I've subscribed to 0. If something important happens I will get hit by the next shitstorm via any of my social networks anyway. You know, like Apple releases a new product, Ubuntu changes it's default search engine, Microsoft goes Open Source, Linus is happy with Kernel blobs, whatever.

Side note: Am I alone with the opinion that the overall reaction of the Open Source community to the release of the iPad was completely inappropriate? I mean, I don't like it either, but that doesn't entitle me to shit on everyone's head who ever got himself a Apple product. I thought we people in the Open Source community ought to be smart, right? From all the blog post I read about the topic maybe only one out of 10 didn't treat the average Apple user as a stupid low life monkey (not to mention twitter/identi.ca). Excuse me? In the world I grew up smart people had manners. Also you don't change anything by pointing a finger at someone and telling him he's a dumb fuck who knows nothing about what's good for the society. Well, that's another reason why I'm so unhappy with that whole Open Source thing and I'm not sure anymore if I want to associate myself with it that much at all.

So, what happens now? I keep sliding and continue doing things I'm really happy to spend time on. Tae Kwon Do is the one thing. The best thing about Sport is the reward which kicks in instantly and grows the more you progress. I'm also playing Eve Online since two month. Yes it's a MMPORG and I can literally feel all your fingers pointing in my direction. I would probably have quit playing it a month ago (my average motivation for any computer game is less than 3 days before I find it boring). But I found a group of nice people to hang out with in the game and there's absolutely no pressure and no need for me to be online 7 days a week (I usually play Friday/Sunday evenings if I have nothing better to do, which happens to be the time I would have spent coding stuff). Also the Summer is coming and I have prepped my bike already and I started to learn Korean. All those things give instant reward. None of it confronts with stuff I would have a hard time to just ignore. And I'm doing all of it for myself.

Right now I'm happy. But I sort of don't like where the Open Source community is heading.

This blog post was created on 2010-04-15 at 16:32 and last modified on 2010-04-15 at 16:37 by Michael Klier. It is tagged with brainfart, opensource.

avatar

Does anyone have the ruby-maemo source?

Tom Swindell (AKA alterego) created the Maemo bindings for Ruby and they’re great. I’m writing a couple of programs with them, including Nibbles, my feed reader. Unfortunately, Tom seems to have vanished and I’ve not been able to find the source code for the bindings anywhere. Does anyone have it? I’d really like a copy.

In other news, I hear that a new release of ruby-gtk2 is near. This is excellent as it will hopefully fix the battery life problem with the current bindings where Ruby/GTK programs (and, therefore, Ruby/Maemo programs) wake up 100 times a second regardless of what they’re doing. Happy days.

avatar

A Ruby binding to cracklib

Just released rubylibcrack as a gem (0.1.1). I developed this teeny-weeny binding to the *nix password strength checking library cracklib at my work. Big props to my work, they totally get open source and the way things should be done.

The gem has only been tested on Redhat, Fedora, Gentoo and Ubuntu (all 64bit, I think), but I’d love to hear how it fares on other platforms. Here’s a Gentoo ebuild for the package.

avatar

Gentoo on an Acer Aspire One

Since details seem to be all over the place for getting everything working with a non-Linpus Linux on the Aspire One, I decided I’d add another place!

This isn’t a complete guide, since I haven’t got time. These are only the unusual things or the things that I found tricky during my install. If I don’t mention something here, it’s because it “just worked” or was obvious.

Kernel

Attach .config.

I use vanilla-sources, which is the unpatched kernel from kernel.org. For this install I decided to use the latest release candidate in the hope that it would make life easier for getting the SDHC cards and wireless working.

Wireless card and LEDs

I’m using the ath5k driver from the kernel. I’ve only had a single problem (detailed below), but haven’t been to many wireless networks yet.

avatar

Ruby process management with Jobby

Jobby is a generic forking process manager written in Ruby, built with robustness as a primary goal from the start. It was initially developed for offloading long running background tasks from the webserver in Rails applications, but it turned out to be useful in its own right, so we extracted it to work more generally. It uses Unix sockets and a call to fork(), so won’t work on Windows or JRuby, but has been tested on several flavours of Linux and OS X. It is also copy-on-write friendly, should the Ruby interpretter that’s used support it.

If you prefer to read code than blog posts, server.rb does most of the heavy lifting.

After a long struggle of using the old BackgrounDRb, last year we finally threw in the towel. We checked out the alternatives, but nothing really fitted the bill. Since background job processing is quite central to some of our applications, we built our own. From the start we had some requirements:

  • Run jobs in parallel up to a maximum number or processes, then start queuing
  • Robust – it just had to be solid
  • Easy to manage – we hated those BackDRb scripts
  • Reliable logging
  • Able to get messages from the background processes

Jobby itself does not provide a mechanism for getting messages from the child processes. I’ll detail a jobby_rails plugin that handles that some other time.

Installing Jobby

gem install jobby will do the trick if for some reason you don’t hate gems. You can also check out the source from github.

Gentoo users can install Jobby from the Gentoo Ruby overlay. Note: I stopped using Gentoo sometime around March 2010. It might still be there.

How does it work?

Jobby is a command line program. It consists of a daemon that listens on a Unix socket and will fork when it receives a connection. The forked child either runs some Ruby code or executes some shell code, depending on how the daemon was started. When you call Jobby, you pass a single parameter to STDIN – this string is passed to the forked child. It could be an ID of some sort, a whole email, a marshalled object or whatever.

There is only one command used, jobby. When this is run it first checks for the existence of the daemon process listening on the socket. If it’s not there, it starts one (and then executes the child command). This is great because it makes daemon startup totally automatic and if the daemon should go down (this hasn’t happened to us yet in the months that we’ve been using it), the next request will start up a new one.

Stopping Jobby

There are two ways to stop the daemon, both using Unix signals. Issuing a USR1 initiates a “very friendly shutdown”, which will stop the daemon accepting any new connections but will allow it to finish the jobs in the queue before terminating. Issuing a TERM signal will stop the daemon forking, then issue a TERM signal to the child processes and terminate the daemon.

Other nifty stuff

When using Jobby to run Ruby code, you might want to have the children load a few libraries before they do any work. Repeating this every time is a pain, so you can instead pass a --prerun parameter to prerun some Ruby code in the daemon before any forking takes place. This will load the libraries (at least in this example) so that they are immediately available in the children when the fork occurs. If you’re using a copy-on-write friendly interpretter, like Ruby Enterprise Edition, you’ll get the memory saving benefits of that too.

You can run multiple Jobby daemons – just call each one by passing a different socket parameter. This is how you can run different code for different job types that you have.

To make your debugging life easier, the forked children will show up in process listings as jobby: /path/to/socket. The actual daemon process will show up as jobbyd: /path/to/socket.

Using Jobby with Rails

Jobby was designed for use in Rails applications, but was extracted since it is generally useful. This post only describes Jobby itself, which you can happilly use from a Rails app using a system call. Sometime I’ll get round to releasing and detailing a Rails plugin for Jobby that adds a communication layer to Jobby and makes Rails intergration nicer. We’re using it just now, but it’s not really releasable as it is. I decided that since the main Jobby code has been so stable for us, it made sense to release it now.

avatar

Ensuring epatch works correctly on embedded Gentoo

On my BeagleBoard, the ebuild messages were telling me that the patches had been applied successfully, but inspection of the code showed they hadn’t. It was a nasty problem to fix – it seems like a epatch wasn’t liking the cross-compiled bash.

After compiling bash natively and getting a another shell, the epatching was successful.

avatar

Nibbles 0.1 released

I’m pleased to say that I’ve just released version 0.1 of Nibbles, an alternative RSS and Atom feed reader for Maemo. A big thanks to the people who were kind enough to help out with the pre-release testing, you’ve been (and hopefully continue to be!) a great help.

Nibbles screenshot

Nibbles is quite stable, can parse a wide variety of feeds and is pretty bandwidth efficient. Nibbles is finger-friendly and does aim to be a good mobile feed reader, but things like downloading of full offline articles didn’t make it into this initial release (I have some working code for that, but it’s not working enough!). New users might want to know that the zoom in/out hardware buttons hide and show the feed and article lists.

Of course, since this is a first release, things aren’t perfect. The biggest problem for me that I think people should be aware of is that Nibbles uses too much battery power. This is detailed in bug #2342 and is really a problem with ruby-gtk2 rather than Nibbles. As I said, with some luck, the next ruby-gtk2 release will fix this.

You can install Nibbles from the project page.

avatar

Nibbles, a feed reader for Maemo

I don’t really get on with the supplied RSS reader on my N800. It doesn’t work like I expect and it lacks mobile features like offline reading that I’d like. So, I’m writing a feed reader for Maemo called Nibbles. It’s still very early stages, but there’s enough for a development release now, I think. Below is a screenshot of the current preview version, 0.0.4:

Nibbles screenshot

It seems to cope nicely with a wide variety of RSS and Atom feeds, despite my proof-of-concept code somehow making it into the app ;) .

Currently it’s quite bare of features and can be considered the simplest app that could work (for example, the feeds update at a fixed 30 mins). It will likely stay that way until I get a few bugs worked out and 0.1, the first ’stable’ version, released. After that, I’ll work on some more interesting new features. I’m still very open to suggestions though and all feedback is welcome, so please don’t be shy!

If you’d like to play along and help the development of a better feed reader for your internet tablet, use the .install file. Please report issues to the Maemo Garage tracker.

You can make Nibbles the default feed reader by editing /usr/share/applications/defaults.list. You need to set hildon-news_reader=nibbles.install. This will allow you to tap on the feed icon in a browser window and have the feed added to Nibbles.

I’ve only specified that the app will work in OS2008, but I’m pretty sure it’ll work in OS2007 too. Since I only have an OS2008 machine, I can’t test it easily. If anyone is still using OS2007 and would like to help, please do get in touch.

avatar

Creating RubyGems .debs for Maemo

I’m writing an application (more on that sometime soon) using the very nice Ruby bindings for Maemo. I’ve got some dependencies that are packaged as RubyGems that I wanted to be managed through the Application Manager, so I created some .debs for them. Here is their temporary home The rake, hpricot, feed-normalizer, simple-rss, atom and htmlentities gems are available in my repository. I didn’t create the rubygems and librubygems packages themselves – I was sent them, but couldn’t find them hosted elsewhere.

It took me a little while to suss out how to create the .debs so I’ve included the steps here in case anyone finds themselves in the same boat. This works for native Ruby gems and compiled C extensions.

  1. Install the gem inside Scratchbox. Irritatingly, “gem install example” doesn’t always want to do very much, so you may need to dowload the gem file and “gem install example-0.1.gem”.
  2. Make a new directory with the rubygems-<package>-<version> syntax (the rubygems- prefix seemed to make sense to me): mkdir rubygems-example-0.1</lil>
  3. cd rubygems-example-0.1/ ; mkdir gems specifications bin
  4. cp -r /targets/CHINOOK_ARMEL/var/lib/gems/1.8/gems/example-0.1/ gems
  5. cp /targets/CHINOOK_ARMEL/var/lib/gems/1.8/specifications/example-0.1.gemspec specifications/
  6. cp /targets/CHINOOK_ARMEL/var/lib/gems/1.8/bin/example bin/ (if there are any bins)
  7. Create a Makefile with this content (you will need to replace the spaces at the start of the lines with tabs):
    all:
    clean:
    install:
            mkdir -p $(DESTDIR)/var/lib/gems/1.8/gems/
            mkdir -p $(DESTDIR)/var/lib/gems/1.8/bin/     <------ REMOVE THIS LINE IF THERE ARE NO BINS
            mkdir -p $(DESTDIR)/var/lib/gems/1.8/specifications/
            cp -r gems/* $(DESTDIR)/var/lib/gems/1.8/gems/
            cp bin/* $(DESTDIR)/var/lib/gems/1.8/bin/     <------ REMOVE THIS LINE IF THERE ARE NO BINS
            cp specifications/* $(DESTDIR)/var/lib/gems/1.8/specifications/
  8. dh_make -e you@example.com then choose the type of package.
  9. Edit debian/control to suit. Make sure the section is something like user/Utilities, not just Utilities if you want the package to show in the Application Manager.
  10. dpkg-buildpackage -rfakeroot -b
  11. The parent directory should now contain rubygems-example_0.1-1_armel.deb

As a final note, /var/lib/gems/1.8/bin/ may not be in $PATH, so you'll need to deal with that if you have files in bin/.

avatar

Mercurial 0.9.5 for Maemo

I’m using Mercurial to track changes in my latest project, a GTK mapping application. I couldn’t find a build for my N800, so I made one myself. I’ll host a .deb until I get around to putting it on the garage or creating a repository.

Edit: I’ve started a garage project.

To install python2.5-runtime I needed to add repository.maemo.org to the application catalogue to satisfy some dependencies. Tested with OS2008 beta on an N800 only.

Posts for Wednesday, April 14, 2010

Installing Clojure with Emacs and SLIME: so easy, yet so hard

How do you install Clojure with SLIME/Emacs support? The answer is either really easy or really hard, depending.

Easy!

If you're new to Clojure and want to get it working fast, you are in luck. Go to swank-clojure's home on github and follow the directions to install it via ELPA. This is very easy and fast and it works.

If you want more documentation, there is (thankfully) a single, central, official-ish location where documentation for installing Clojure is slowly but surely accumulating. You can read about it at http://www.assembla.com/wiki/show/clojure/Getting_Started. This site includes instructions for Emacs, Netbeans, Eclipse, Maven, and everything else under the sun. This is a great resource, and attempts to solve the problem of out-of-date Clojure documentation. (This problem is natural given Clojure's young age and rapid growth, but it's painful for people trying to get started, I bet.)

Or is it...

This is all great. But if you want to do anything non-standard, you run into a bit of a wall. How do you install Clojure+SLIME on Windows? I find that sometimes it works, but sometimes things mysteriously fail, and I have no idea where even to begin to debug it, because there's so much automation going on in the background nowadays. What if you want to build a .emacs.d directory you can simply copy from one system to another and have everything work? (You can do this with most Emacs libs.)

Or how do you install and use a bleeding-edge Clojure or clojure-contrib tree with SLIME? There's good reason to want to, because it has some awesome new features, e.g. deftypes and protocols and rest-parameter destructuring. But most of the "official" methods of installing things give you stable versions of everything.

And then, you generally end up with a bunch of opaque .jar files, auto-downloaded all over your system, which isn't helpful if you want to hack on anything yourself. Most of these jars end up in ~/.m2 nowadays, I think? Used to be ~/.swank-clojure or ~/.clojure or something? And ~/.emacs.d/elpa gets stuff too? Color me continually confused.

The automated build tools we have nowadays (ELPA, Lein, Maven) are awesome when they work, but extremely painful when they fail or when you don't know which knobs to turn when you want to step slightly outside of the mainstream. This is incidental complexity if I ever saw it. While it's far more manual labor, I find it to be so much simpler to download things myself, build everything myself, put it all somewhere on my system myself, and configure Emacs to tell it where to find everything.

Well, this site is as close as I can find to good up-to-date documentation, and what I did to get set up was almost identical to this. But it will likely stop working in a month or two. There's also a recent thread on the Clojure mailing list which has some more tips (and valid complaints).

I will push my Emacs setup to my github repo once I get the kinks worked out. But if you want to get bleeding-edge everything working yourself, all I have to say is God help you, because it's largely unsupported. Be prepared to hack and patch until it works. I'm looking forward to the day when most of the kinks are worked out and things settle down a bit.

systems are too complicated, dammit!

I’m reading Peter Seibel’s book “Coders at work”. It’s a collection of interviews with famous programmers. This is the kind of book I really like, it’s not a technical book, but it’s a meta sort of book where these people tell you what they think about various relevant issues in the industry. And not just issues that concern them directly, but general trends too. It’s a very easy read, perfect for the plane or the airport.

There are 15 interviews and almost all these people started playing with computers sort of roughly before there were computers. So if there is a theme running through the book, it is this:

  1. Kids today don’t understand how the metal works.
  2. I don’t like all these layers of software.

I think it’s an understandable point of view coming from people who’ve written operating systems and compilers and coded assembly and machine code because there was nothing else available. But I don’t find it a very helpful perspective.

The basic complaint is this:

  1. Things used to be simple.
  2. Instead of remaining simple, they got complex, but not in a good way (ie. bad technical decisions).

I think this is an “argument from nostalgia”, essentially. Back in the days, systems were simpler. Today they are very complicated. And so we wish things were simpler. But this is because some people were present more or less at the “birth” of computer science. The field went from zero and just keeps expanding. That’s normal, though.

If a physicist said “I hate how when you discover a layer of particles, there’s always something smaller than that!” would people nod in agreement? I remember learning about atomic orbitals and not understanding them and I kept thinking “what was wrong with the Bohr model, that one was so much simpler and nicer?”

The difference between physics and computer science is that in physics there’s noone to blame for what is there. There is this sense of “nature is the goddess who bestows gifts upon us and we have the privilege to explore them“. In computer science we’re not trying to explain or discover anything, we make all this stuff up!

In physics there’s no way you can remove the complexity and be left with a simple system, the complexity is there at all levels. But in computers you can delete everything save for the kernel and you indeed have a simple system. (Better yet, delete the kernel too and install a simpler one that you wrote yourself.)

The fundamental difference, to me, is that there is someone to blame. There is noone to blame for atomic orbitals and “why do they have to be so complicated??“, but there is someone to blame for every programming language and every system. I don’t think for a minute that we wouldn’t do the same in physics if we had the chance, though.

What’s Plan B?

Of course, the difference between the physical sciences and computer science raises the old “is it a science?” question, but at any rate it is becoming more like physics in the sense of a top to bottom system that is difficult to understand at all levels.

In physics you don’t say things like “I would like to throw all this out and start over, make it simple“. This is something you can totally do in computers, but chances are you’re not gonna have much impact. Sometimes people bemoan how there hasn’t been any innovation in operating systems in 30 years. So go write your own, see how many people you can convince to use it.

In a way, the answer is right there. The fact that there aren’t any new operating systems taking over from the old ones, _means_ that the old ones have succeeded. They’ve successfully laid that layer of bricks that has proven to be a strong enough abstraction to move away from that layer in the system and focus our attention on something higher up. They’re not works of art in terms of simplicity and purity, but neither are layers of abstraction in physics. *ducks*

Complexity is often presented as a mistake, but the fact that we have all this complexity is not really an accident, it has to be there to do the kinds of things that we want to do.

Posts for Tuesday, April 13, 2010

how do you structure your python codebase?

One thing that’s awesome in python is having a small codebase that can fit in a single directory. It’s a comfy setting, everything is right there at your fingertips, no directory traversal needed to get a hold of a file.

Flat structure

Let’s check out one right now:

./frame.py
./master.py
./mystring.py
./page.py
./sentence.py
./user.py

Download this code: python_codebase_structure_flat.txt

And here’s the import relationship between them:

python_codebase_structure

Easy, straightforward. I can execute any one of the files by itself to make sure the syntax is correct or to run an “if __main__” style unit test on it.

Tree structure

But suppose the codebase is expanding and I decide I have to get a bit more structured? I devise a directory structure like this:

./media/book/__init__.py
./media/book/page.py
./media/book/sentence.py
./media/__init__.py
./media/master.py
./media/movie/frame.py
./media/movie/__init__.py
./media/mystring.py
./user.py

Download this code: python_codebase_structure_tree.txt

The same files, but now with __init__.py files all over the codebase to tell python to treat each directory as a package. And now my import statements have to be changed too, let’s see master:

# from:
import mystring
import page
# to:
import media.mystring
import media.book.page

Download this code: python_codebase_structure_master.py

Nice one. Okay, let’s see how this works now:

$ python user.py
page says hello!
sentence says hello!
frame says hello!
mystring says hello!
master says hello!

Download this code: python_codebase_structure_run_user.txt

user imports page and then master. The first 4 lines are due to page, which imports three modules, and finally we see master arriving at the scene. All the files it imports have already been imported, so python doesn’t redo those. Everything is in order.

As you can see, imports between modules in the tree work out just fine, page finds both the local sentence and the distant frame.

But if we run master it’s a different story:

$ python media/master.py
master says hello!
Traceback (most recent call last):
  File "media/master.py", line 3, in <module>
    import media.mystring
ImportError: No module named media.mystring

Download this code: python_codebase_structure_run_master.txt

And it doesn’t actually matter if we run master from media/ or run media/master from ., it’s the same result. And it’s the same story with page, which is deeper in the tree.

These modules, which used to be executable standalone, no longer are. :(

A hackish solution

So we need something. The nature of the problem is that once we traverse into media/, python no longer can see that there is a package called media, because it’s not found anywhere on sys.path. What if we could tell it?

The problem pops up when the module is being executed directly, in fact when __name__ == ‘__main__‘. So this is the case in which we need to do something differently.

Here’s the idea. We put a file in the root directory of the codebase, a file we can find that marks where the root is. Then, whenever we need to find the root, we traverse up the tree until we find it. The file is called .codebase_root. And for our special when-executed logic, we use a file called __path__ that we import conditionally. Here’s what it looks like:

import os
import sys
 
def find_codebase(mypath, codebase_rootfile):
    root, branch = mypath, 'nonempty'
    while branch:
        if os.path.exists(os.path.join(root, codebase_rootfile)):
            codebase_root = os.path.dirname(root)
            return codebase_root
        root, branch = os.path.split(root)
 
def main(codebase_rootfile):
    thisfile = os.path.abspath(sys.modules[__name__].__file__)
    mypath = os.path.dirname(thisfile)
    codebase_root = find_codebase(mypath, codebase_rootfile)
 
    if codebase_root:
        if codebase_root not in sys.path:
            sys.path.insert(0, codebase_root)
 
codebase_rootfile = '.codebase_root'
main(codebase_rootfile)

Download this code: python_codebase_structure_fix.py

So now, when we find ourselves in a module that’s somewhere inside the media/ package, we have this bit of special handling:

print "master says hello!"
 
if __name__ == '__main__':
    import __path__
import media.mystring
import media.book.page

Download this code: python_codebase_structure_master_new.py

Unfortunately, importing __path__ unconditionally breaks the case where the file is not being executed directly and I haven’t been able to figure out why, so it has to be done like this. :/

python_codebase_structure_treeYou end up with a tree looking as you can see in the screenshot.

I’ve pushed the example to Github so by all means have a look:

We pass the test, all the modules are executable standalone again. But I can’t say that it’s awesome to have to do it like this.

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