Archive for the ‘General’ Category

Online videos, to a VCD, via Linux

With the upcoming elections, there have been some most interesting videos posted on Google Video and YouTube. The opposition is broadcasting on YouTube, sitting on social networks (Anwar and PKR, are on MySpace, Friendster, Facebook). The Internet is becoming more mainstream, for elections and politicians. What does this mean for the 2008 general elections? Definitely, not a 90%+ majority for the ruling Barisan Nasional, I do hope.

Anyway, on to working with video. Lets say, you have found an interesting video on Google Video, and feel that it is your sworn duty to share it with the poor who do not have access to the Internet. Google Video, on the right hand column, allows you to download it for the Video iPod/Sony PSP. Perfect.

What about interesting videos on YouTube? Naturally, you will use youtube-dl. Beware, this software changes often, as and when YouTube changes their protocol, so check back constantly if things stop working. Getting things in .FLV format, is kind of painful, which is why you’ll use ffmpeg to transform your video: ffmpeg -i foo.flv -y foo.avi.

Now, what about creating a VCD or DVD? Whats the easiest way? Hands down, you want DeVeDe. Its available in Fedora, apparently has got some bugs in Ubuntu (something about sound going wonky). Its dead easy to use. It works with Google Video MP4’s as well as AVI files you’ve converted from ffmpeg.

Let DeVeDe do its thing (which is creating a .cue and .bin file), and then, its time to write to a CD. To create a VCD? cdrdao write --device /dev/sr0 movie.cue. I understand, K3B has got all the gizmos to create this in GUI form, but that involves installing KDE libraries, and I’m sure I can use my disk space in a more efficient way. I found HOWTO Make a video (S)VCD a handy guide.

Wait… and you’ll soon have a CD that you can pop into a DVD/VCD player and enjoy viewing.

Technorati Tags: , , , , , , ,

An introduction to ANTLR (sparse notes)

I attended Clinton Roy’s excellent session titled An introduction to ANTLR: A parser toolkit for problems large and small. Now that the slides, and the video (1, 2) are online, I don’t know if my bits of notes are of any use (I made them while the tutorial was in progress), but they’re sitting on my desktop, and really should just get published. The files referenced below, you get via checking out the Antlr Tutorial Preparation wiki page.

Why use Antlr?
To parse configuration files, syntax highlighting, Domain Specific Languages (DSL), interpreters, translation/transformation.

Generates easy to follow code, LL(*) parsing algorithm. Bison is more powerful than Antlr. Compined lexer, and parser generator.

fun (int a, char b); <– as you do LL, till you hit the “;”, you have no idea if you’re dealing with a function or a declaration. Of course, there are look-ahead LL parsers too. An LL3 parser, which can see 3 tokens ahead, you still can’t see ahead enough, till you hit the ;. This is why, there exists an LL(*) – pick the smallest look-ahead, your grammar would need

Antlr, will help you get rid of using regular expressions.

Island grammars – one language, inside another (like HTML, inside PHP, or Doxygen inside C) are supported by Antlr.

Antlr Wiki is good, but hard to find things. Mailing list is great. The book by Terrence Parr is good, but out-dated, so go ahead, and get the online PDF version. A new cookbook/recipe list is coming out soon.

Using AntlrWorks. java -jar antlrworks.jar

conffile.g parses a = 1, b = foo.

IDENT   :       (‘_’|’a’..’z’|’A’..’Z’)(‘_’|’a’..’z’|’A’..’Z’|’0′..’9′)*;
NUMBER  :       ‘0’..’9’+;
WS      :       ‘\r’ | ‘\n’ | ‘ ‘ {$channel=HIDDEN;};

The above are lexer rules. WS = whitespace. It reads from bottom up. White space, a number (0-9). IDENT will match foo, foo, foo1, but not 1foo (identifiers don’t start with numbers).

{$channel=HIDDEN;} <– IDENTs and NUMBERs get through the channel get through the parse. The whitespace, the parser sees them, but it will ignore them (i.e. hide them).

[-(byte@hermione)-(pts/6)-(11:21am:31/01/2008)-]
[-(/tmp/antlrworks)> l
total 248
drwxrwxr-x  2 byte byte   4096 2008-01-31 11:20 ./
drwxrwxrwt 44 root root 192512 2008-01-31 11:20 ../
-rw-rw-r–  1 byte byte    340 2008-01-31 11:20 conffile__.g
-rw-rw-r–  1 byte byte   8492 2008-01-31 11:20 conffileLexer.java
-rw-rw-r–  1 byte byte   4180 2008-01-31 11:20 conffileParser.java
-rw-rw-r–  1 byte byte     28 2008-01-31 11:20 conffile.tokens

conffile__.g – lexer file
conffile.tokes – tokens

CMinus.g takes input, which is a C program. Go to the interpreter, and you can then see the entire parse tree. Very impressive!

Technorati Tags: , ,

foss.in, day 2: A day of Sun

Day 2 for me started with watching Simon Phipps talk about Sun’s FOSS Philosophy and Strategy. It rained in the morning, so the talk started a little late, and there were hopes of better attendance. Nonetheless, the talk was interesting, and the announcement that there was money in it for FOSS developers, was just fabulous. I took away a few points, which I ended up Twittering:

  • There’s this idea of a global mesh nowadays, and its leading to a changing society. FOSS is all about it. And “Its Going Mainer Mainstream”!
  • Investment in skills is important for any country. There should always be a preference to invest in the local workforce. Simon mentions that all this allows you to keep the sovereignty of your country.
  • You cannot pirate free software. Want to avoid foreign interference, and all the worries of WIPO? Free software is the answer.
  • Simon Phipps thinks “software patents are bananas”. I tend to agree.
  • I also found out that the Sydney Opera House owns a trademark on all photos taken of the Opera House. That seemed retarded, and not long after, I found out this was similar with regards to the Petronas Twin Towers in KL. I can take a photo, but apparently, I can’t sell it on say, ShutterStock Photo or anything. Ridiculous.

I didn’t get to attend the next round of talks, mainly because I was giving my talk! The room was full, the questions were good, I was happy. I read a report, from Ditesh, so that’s a pretty good summary, I guess.

I really wanted to attend the Mozilla talk from Mitchell Baker (mainly because I’d have liked to have met her), however, I couldn’t resist going to the PostgreSQL 8.3 talk by Josh Berkus. It was an interesting talk, well rounded, with the occasional jab or two at MySQL. The attendance was about half full, and we had some unwelcome loud noises in the talk! I took away from it:

  • Contributors are full participants. PostgreSQL is owned and run by the community. Write a patch, and its accepted? Be prepared to write documentation.
  • CSV logging is now built-into PostgreSQL 8.3
  • I was introduced to Heat Only Tuples (HOT). Benchmarking, then seems to be skewed towards greater performance gains in PostgreSQL
  • MVCC: Overwriting model (InnoDB, Oracle) or the non-overwriting model (PostgreSQL, Firebird)
  • The attention to standards is great. Extending SQL, to create the SKYLINE feature, to power approximate queries, however, this was rejected for the core of PostgreSQL, and is available in their foundry
  • Release engineering in PostgreSQL is amazing. 6 weeks development, 2 weeks commit, and repeat.
  • There are doubts of an embedded PostgreSQL – this is what SQLite is for. I like the focus of the core team here.
  • You never want PostgreSQL running on handheld devices – heavy writes it has.
  • “There is no one size fits all solution, for databases” — Josh Berkus. I tend to agree
  • Why are few hosting companies providing PostgreSQL? Customers don’t ask for anything else? CPanel doesn’t run with PostgreSQL. pg_hba.conf (my.cnf equivalent) needs fixing, for controlling quotas (can be implemented via tablespaces), etc.

Next up, was the OpenMoko: What, why and how talk by Harald Welte. The talk was packed to the brim, and I didn’t learn much more than I’d have found out from their website. Its an interesting project, but with the upcoming Android, and the idea that I need a working phone now, I don’t know if OpenMoko is right. Besides, the battery life on that thing is horrid.


Colin Charles and Josh Berkus (photo, courtesy Josh Berkus)

Spent time talking to Josh Berkus, in the corridor, nearby the Sun booth about life, the universe, and everything. Then it was Lightning Talks, and dinner…

Technorati Tags: , , , , , , , ,

The Eee PC: After a week

After writing my impressions on Eeedora, it seemed only natural to write about the hardware. There are definitely some issues that I found with the Eee PC that I am not too happy about (and some that are just great).

For starters, who makes a laptop these days, without integrated Bluetooth? It just seems daft. This is a tiny sub-notebook, and how can I get on the Internet if I’m sitting in a train or a bus? The most natural thing would be for me to enable Bluetooth on my mobile phone, and use it as a modem. Oh wait, the Eee PC is missing Bluetooth, and its a WiFi only device. Sure, I can stick a USB Bluetooth dongle on it, but thats an external contraption, that I’ll have to make do with.

I was going through the fine print, and while ASUS provides a 2-year warranty on these laptops, the warranties themselves, seem to be limited to the country of purchase. These warranties, are not international. Who makes a laptop these days, that doesn’t expect the user to travel much? I can imagine that when travelling, the Eee PC can’t be my only laptop – I’m the kind of person that finds Dell’s next-day-onsite-business warranty pretty darn useful.

The keyboard, is tiny, but its expected for such a tiny laptop. I’m wondering why so much space is reserved for the speakers, and why not just give us a larger screen? I have a feeling its got to do with cost, and this can only get better in the future. I’ve noticed that the keyboard requires you to occasionally “jab” it harder, to get the key press that you want. Or its just that my fingers aren’t nimble enough, on this small thing.

The location of the left Shift key, is silly. In VIM, you occasionally tend to press the Up Arrow key, as opposed to the Shift key. I’ve seen people hack their Eee, to ensure that this stupidity is reversed. However, I’m not into moving keys around, to satisfy my needs at this stage.

The one button mouse, that does both right and left clicking is a very nifty feature. How do I middle-click? This is a very crucial feature in Unix land, and especially useful in Firefox (tabbed browsing).

The battery life, for something this tiny, sucks. It sucks even worse, when the WiFi is enabled (quite naturally). My dreams of it being used daily during a conference, or at a meeting, has clearly been shattered. To fix this, I might have to order an external battery pack, that outputs between 9-12V (apparently, 9V is too little to power this 9.5V device, but 12V is just fine).

I’m pretty happy with the performance of the SSD:

[root@Eee ~]# hdparm -tT /dev/sdc

/dev/sdc:
 Timing cached reads:   566 MB in  2.00 seconds = 283.05 MB/sec
 Timing buffered disk reads:    4 MB in  4.39 seconds = 932.40 kB/sec

[root@Eee ~]# hdparm -tT /dev/sda

/dev/sda:
 Timing cached reads:   566 MB in  2.00 seconds = 282.50 MB/sec
 Timing buffered disk reads:   66 MB in  3.07 seconds =  21.50 MB/sec

/dev/sda being the internal SSD, while /dev/sdc being a USB thumb drive (2GB, Sandisk Cruzer Micro).

The built-in video-camera, is pretty standard. Its resolution isn’t great, but it suffices for a video chat.

Sound, is OK. I installed VLC, to allow me to play video/audio, and realised that it was going to set me back, in total, about 21M, with all its dependencies. Hardly appealing, but I was going to have a more interesting time, bringing in Totem, for instance. I have managed to watch a DivX movie, without too much trouble. Will I be able to watch one, entirely, say, while on a plane (or train), I don’t know.

Yes, video, and DivX decoding, works fine on a 630MHz processor. Why has ASUS under-clocked the Eee, giving it a 300MHz performance slack? Did the difference, really save battery life?

There are many ways to hack an Eee. The many guides online, showing how and what one can do (from simple Bluetooth, to a GPS or a touch screen) is just amazing. I don’t plan on hacking my Eee (yet, anyway), and the most I’m going to do, is go get more memory- RAM is always a good thing.

Its small. I spent this week using the train and tram system quite a bit, and realised that even though the trips themselves were short, I was getting some work done (like finding time to write blog entries, and some code – I haven’t gone as far as installing a toolchain on the Eee yet, but if you can find some Internet access later, committing code is easy). Its OK that its cramped. And its OK that it works on top of my huge backpack. These are clear benefits of its size, and hopeful durability.

Its cheap. I had a colleague who’s laptop (a Macbook) died the night before he was about to give a talk. He could head a few blocks down, buy an Eee, and immediately start re-writing his talk again. I saw him deliver his talk, using the Eee and the stock Xandros that was installed on it. In the old day, if your laptop died, you just started to walk around with a notebook and pen,and you gave your talk informally, without slides :)

Anyway, enough rambling (I’m about to reach my stop). Next up, what powertop thinks of the Eeedora install, and re-spinning it.

Technorati Tags: , , , , , ,

Eeedora Impressions

Being the long-time Linux user that I am, there was no way I was going to be satisfied with Xandros, which is the stock Linux that ASUS ships with the Eee PC. I was stuck for choice between Ubuntu and Fedora, and after some careful evaluation, I decided that Fedora, was right for me.

Getting Eeedora, was pretty straight-forward. The installation wiki is pretty accurate when it comes to the “how” of installing Eeedora. For me, it was made easier that I had a Fedora system already, so I could run the tool to create Live CDs from the livecd-tool package.

One snag I noticed, and this is more with the Live CD script, is that when you don’t have a bootable USB thumb drive, it tells you that, but doesn’t quite tell you it didn’t make an installation on the thumb drive. I guess the script could be more idiot-proof. Anyways, making the drive bootable is easy.

Now, once that was done, it was on to installing on the Eee. I ensured that in the BIOS (accessed via pressing F2), the first boot device was the USB thumb drive attached to the system at boot-up. However, it was never booting into Eeedora, and I only managed to see the Xandros start up. Highly disappointing.

Turns out, that hitting the Esc key was the magic sauce, during boot-up. Only when doing that, was I given a boot menu, and then I could choose if I’d like to boot off the internal SSD, or the USB thumb drive. Once that was sorted, I was pretty happy to see a familiar Fedora-looking screen (sure, it said Eeedora, for legal reasons, but I think its a pretty darn good spin :P).

The installation process went on pretty smoothly. During partitioning, I was pretty much rid of Xandros – the chosen default was actually the most sensible. Just one / partition, filling up the entire disk, with no swap. As usual, anaconda (the Fedora installer) will warn you that not having a swap partition will be detrimental to performance – I wonder how many newbies might decide to create a swap partition (kind of a big no-no, on these SSD based devices).

One thing I did notice was the use of ext2 partitioning as opposed to a journalled filesystem like ext3. The natural question then comes to mind, as to why not just use jffs2?

Once the filesystem partitioning was sorted, and GRUB was chosen as the default bootloader, anaconda proceeded to install packages. This was a fairly speedy process, and once that was complete, it was a simple reboot, and I was booting off the SSD before I knew it.

You’re logged in by default as the eeedora user. You get a stock XFCE4 environment (or stock, that I would think anyway), and it comes with the basic utilities you need to get working (Firefox, wireless, etc.).

There were some things I obviously did not like, so decided to poke a little further. First up, was creating a user, that was not”eeedora”.

Dissecting the .bash_profile of the eeedora user, I noticed some things:

  • pulseaudio -D – pulseaudio as a daemon for the user? Why, sound seems to work just fine on my Eee without it
  • xsetroot -solid steelblue – seems OK, but not actually required anyway
  • startxfce4 – if you want a GUI the moment you login, this is useful. But it only really works out well, because of the hack in /etc/inittab that says c7:12345:respawn:/sbin/mingetty --autologin=eeedora tty7. Seeing that I disabled autologin for the eeedora user, I pretty much see a login screen, and startxfce4 manually. Sometimes, I can actually get away with working in just a shell… However, I can see this from a usability point of view, I guess. Of course, the other issue is that the eeedora user, does not actually have a password!
  • Logging out of XFCE4 and going back to the console, immediately triggers a machine shutdown. This seemed counterintuitive.

Needless to say, I disabled all this, in my new user account, as well as disabled autologin in the inittab.

Why XCFE4? Its a 900MHz Mobile Celeron processor, deliberately underclocked to 600MHz, with 512MB of RAM. This is the kind of environment, that can run GNOME. And when we notice problems with GNOME, its time we fixed it. Heck, I have an almost similarly configured IBM laptop, without PAE, that runs GNOME just fine!

I must commend WiFi Radar – this is something that pretty much, just works. And its small. It looks unmaintained, sadly, so its probably time to take an interest in it. Fn+F2 enables and disables wireless very well. I do however notice that even with the wireless disabled, the WiFi light (in blue), remains turned on. I find this to be rather quaint, and must prod it further.

Brightness control (Fn+F3/Fn+F4) seem to work well in Xandros, but I can’t seem to replicate such joy in Fedora. There is absolutely no reason why this shouldn’t work. It does annoy me, because its sucking precious battery life, from my usage of the Eee, by keeping it nice and brightly lit, when I’m on the battery.

Suspend and resume, just work. And because we’re dealing with an SSD, it just works, really fast as well. Sure, when I open up the screen of my Eee, I actually need to press the power button to get it to resume, but this kind of behaviour is perfect for me.

Do I like recompiling all the magic in /root/eee-setup, everytime I get a new kernel? No. Speaking with Dave Jones though, there is an expectation that all the drivers will be available in F9. Kudos.

Webcam? Works fine when I run lucview. Doesn’t work with the Skype beta that I get from the Skype download site. No idea what is missing, I just feel a bit bummed that I’ve got to find the solution to this issue at some stage soon.

As an install report, I think this does, just fine. Its now just time to hack on the distribution, to get it to the way I want it to work.

Asus Eee PC, OLPC, all in one week

This month has clearly been an interesting one. Maybe, I should reserve it to be just this week.

On the weekend, I went looking for a rack, and came back with an Asus Eee PC. Today, while there were about 70 OLPCs given away to lucky, random linux.conf.au 2008 attendees, I wasn’t one of them.

However, I got one of the reserved units. Apparently, 100 units were shipped. Excellent.

Pack comes with a power supply, laptop, manual of some sort, and Jim gave me an Australian adapter (it comes with a US based plug).

Like I said in a previous post, I see great reason for the OLPC to rock. Now, I’ve got plenty of work ahead of me, to ensure thing do. Tasks include ensuring Fedora 9 boots off the Eee (I spoke to DaveJ about this, and the ideal plan is to make it installable by default – now its all driver hacking).

Excited, I am, naturally. Working on Fedora again. Whee!

The Eee has enabled me to work on the train and tram rides to get from South Yarra to Melbourne University. The OLPC, just got on my network (ifconfig -a eth0, find MAC, and voila! it works) and I’m sure to be using and hacking on it soon.

Time to sleep, these 9am keynotes are a killer. I am so not a morning person.


i