Categories
Blog

Microfunding

I’ve recently joined flattr (that’s the icon on the right you can see :-)), and just last week I read about some students from NYU who got almost 200.000$ in funding through kickstarter to write an open source facebook clone. Something is definitely buzzing in the micropayment world.

When you look at kickstarter and flattr, they are attacking the same problem, funding, at different angles. Kickstarter tries to get all the funding up front, while flattr is more of a tip jar model for something already produced. So in a way, they are complementary. I would argue that they both work best if the content is placed into the public one way or another. And that is where I think there is a huge potential.

Something like flattr creates an alternative to paywalls and an alternative to ads. And that is something I would very much like to see.

Categories
Blog

Google search is not a programmers best friend

I was playing around with google this weekend. The original problem I wanted to solve was that last.fm returns strange strange release dates for albums, so I was writing a small script that would extract the correct release date from various sources. I was aiming at www.metal-archives.com and wikipedia. Both of these sites have different search pages, and in general I’ve come to rely more on google’s site:xxx functionaly, than on individual pages own search engines. So I thought, why not just use google programmatically to search the sites. Seems easy enough.

Failure 1 (I’m feeling lucky):

Google has a very nice feature called “I’m feeling lucky” that will direct you to the first result. If I could specify my queries good enough, I could rely on that, and not have to parse google to get the url. It’s very simple, you just add &btnI at the end of your query and google will redirect. Sadly it works fine most of the time, but sometimes it just fails to redirect you. I couldn’t find any patterns to this randomness and a “works sometimes solution” is not a good one ๐Ÿ˜

Failure 2 (google ajax):

I then found out that google has a seemingly very nice api that lets you do queries and get JSON back. JSON is easy to work with and it also allows one to go through several results, in case google doesn’t return the right one as the first result. After a bit poking around I found out that google ajax randomly returns different results from the normal google. It’s like using Yahoo instead of google. A bit of poking around returns the following 2 year old bug report. Furthermore the TOS directly forbids using the API for this kind of activity. Oh well, it didn’t work anyway.

Failure 3 (parsing google results directly):

After two bitter defeats I thought screw it, I’ll just parse the damn google result pages, how hard can it be? At least I know that it gives me the right results. So I did that, coded everything up and checked that things was working. Then let it loose on my collection (2×275 requests) and around the middle it stopped working. I poked a bit around, and found out that google has identified my program as a bad boy and decided to spank it by returning a “Please identify yourself as a human” page back instead of the normal google result page.

As a side note, after 3 bitter defeats I was ready to jump ship and try bing or Yahoo. That was a quick detour though, as none of them where up for the challenge of returning good results.

Categories
Blog

Channel downmixing in MPlayer

Recently I have been playing with downmixing in MPlayer.ร‚ย  When I bought new speakers, I decided to go with stereo instead of surround since I mostly listen to music. As anyone using mplayer or any “derived” players such as vlc have discovered, there is a incredible annoying problem that the voices of the actors are very low, actually in general the sound is very low. It appears that when mixing to two speakers, the center channels is put very low in the mix. The same could be said about the subwoofer although it’s naturally not as easily recognized.

A quick google revealed that MPlayer has several tricks (audio filters) that might potentially work: volume, volnorm, pan, hrtf. I quickly discarded volume and volnorm since I don’t want to just boost the sound, I want it to distribute the channels properly. hrtf seemed like a good simple choice, since pan looked very complex. Sadly in the middle of Harry Potter I had to turn it off because it was making lots of clipping of the sound. So I was left with pan. It took a while to get a good default, but a bit of googling around revealed one with a decent default. I first just tried turning sub + center up to one but in one or the other movie introduced the dreaded clipping. So I had to keep it down a bit while still retaining decent boost of center and sub. After an afternoon of testing I came to the following “magic” formula:

-channels 6 -af pan=2:0.4:0:0:0.4:0.2:0:0:0.2:0.3:0.3:0.1:0.1

Please do note that one needs to add a -channels 6 in order for mplayer to decode all 6 channels so that it can mix it down to two. One can read more about the pan filter here.

Categories
Blog

How far have we come?

Things like these makes me wonder, with all the advances in computer science how far have we really come?

  • 40 years after the invention of relational databases we are still manually defining indexes
  • 40 years after the invention of Unix, the scheduler in Android (= Linux) still does a terrible job at scheduling the tasks that really depend on it (games and audio)
Categories
Blog

+1 Ubuntu

I was flaming Ubuntu in an earlier post for their lack of quality in their releases, so I thought it would be fair to give them credit when it is due. They have a project called One Hundred Paper Cuts where they try to fix low hanging fruit, easy bugs but annoying bugs. Bugs that when stacked together really can make you go from loving a piece of software to hating it. When I look through the blog post for their round 6,ร‚ย I really like what they are fixing.

We need more of this in software. It’s so easy, and has become so accepted, to ship a half-baked product and just slap a beta sign on it nowadays. Release early, release often is great, but there is also a time for making fixing all the small annoying bugs. If they plan on fixing this bug, then this is a step in the right direction.

Categories
Blog

Running Chrome in Ubuntu

Getting Chrome running in Ubuntu is now pretty easy, simple add the following line to /etc/apt/sources.list:

deb http://dl.google.com/linux/deb/ stable main

Then you can install Chrome using the package manager and it will keep itself updated. Sadly the browser is quite alpha (no flash, random errors, no tabs saving on exit) but they update it every week and it runs insanely fast compared to firefox.

Categories
Blog

Making hibernate work after harddrive upgrade

I recently upgraded the harddrive in my trusty old IBM T60. I mirrored the hd using a little dd magic and everything worked fine, including the IBM rescue partition. The only thing that wasn’t working anymore was hibernation in Ubuntu. This was because it relied on wierd UUIDs instead of actual device names. Fixing it was pretty easy, once you know what the problem is. First step is to fix up /etc/fstab so that the swap partition has the right UUID. You can get the UUID of a device using something like:

sudo vol_id -u /dev/sda4

Next step is to fix up the location of the resume partition. Open /etc/initramfs-tools/conf.d/resume and change the UUID to the same as you just put into fstab. Then run:

sudo update-initramfs -u

And you should be running again ๐Ÿ™‚

Categories
Blog

Generators and decorators in Python

Was reading through some old blog posts today and found an interesting talk about Coroutines and Concurrency. The talk is pretty long but presents some nice ideas about how to split a problem up and making it more modular using yielding. It seems like python has extended this a little so that you can actually use generators to consume messages also. What I found particular interesting though in the talk, was when he briefly showed a decorator. Decorators are really powerful and seems to bring about the best of lisps macro extensability to Python without loosing the excellent syntax ๐Ÿ™‚ I googled a bit and found the following list of patterns that you can do with decorators.

Categories
Blog

Streaming media between two linux boxes

I was wondering why it wasn’t possible to playback a movie over a ssh connection using remote X11 forwarding and mplayer. It seems that the latency is simply just too high. I’m not exactly sure if it’s a ssh or a X problem. This was on a wireless link, which might be part of the problem. While researching the problem I found this pretty cool patch for openssh that should give better transfer speeds. It’s in gentoo as the hpn use flag (even a patch for openssh 5.2). Sadly it did not seem to solve the problem. The movie was still very laggy. Then I tried adding a -C to add compression. This help a bit, but it was still painfully slow and uses quite a bit more cpu on the server side. Also the sounds will come out on the server end, so this might not work very well if you’re not in the same machine as the server ๐Ÿ™‚

Back to the drawing board it seems… I found this excellent post on how to stream movies from a server to a Nokia 800 tablet with size conversion done on the fly at the server end. This script is pretty clever and truly UNIX style. It uses netcat to pipe the data from the server to the client, and just sticks a ffmpeg in front to scale the movie first. What is perfect about this solution is that it uses very little cpu (very good for small devices like the Nokia tablets) and it streams the sound to the client. The only downside seems to be that the data is not encrypted. But of course there are ways around that too if you really care.

On the client (mine is 192.168.0.2) do this:

nc -l -p 5000 | mplayer –

And on the server side to this:

cat /movies/nice-movie.avi | nc 192.168.0.2 5000

Categories
Blog

Ginger cookies

My lovely girlfriend Milda made ginger cookies again today ๐Ÿ™‚ The last batch of cookies went so fast that this time she made 3 plates full of goodies. The recipe needs the following ingredients:

100g butter
100g sugar, recommended brown
150g honey
1 egg
400g flour
a bit of salt
1 tee spoon of baking soda
2 tee spoons of blended ginger
1 tee spoon of cinnamon
1 tee spoon of hot wine spices
2 table spoons of sour cream

Put together as:

Mix well butter and sugar.
Peel off ginger and blend it together with an egg. Put it together with butter and sugar.
Mix baking soda with sour cream and put to the bowl for pastry (there should be butter, sugar, egg and ginger by now :)).
Add honey and spices and mix all the ingredients well.
Add flour to make pastry of a consistence for cookies. Put it in the fridge for half an hour.

Flatten the pastry, and form the cookies (I do that by cutting it to squares with a pizza knife :)). Heat the oven up to 180 degrees and bake the cookies for 10 รขโ‚ฌโ€œ 15 minutes. Velbekomme.

OMG so many cookies!