Search Results: "spa"

31 December 2005

Dirk Eddelbuettel: Quantian in VMWare Player: Create a virtual disk with qemu

A few days ago, I blogged about booting/running the Quantian iso via VMware Player, a 'free as in beer' virtualization tool. Over the last few days, I have experimented a little more, perused the VMware Player Forum and googled a bit. It turns out that you can employ the 'free as in speech' virtualization tool qemu (using version 0.7.2 from Debian unstable is fine, looks like a newer 0.8.0 it out upstream) to create a virtual disk image in vmdk format suitable for VMware. For example, the command
qemu-img create -f vmdk Quantian.vmdk 512M
creates a 512mb file of the given name in the in required vmdb format. By the way, qemu is smart and creates a much smaller file -- an 'empty' 512mb partition occupies only 12mb. It is then only a matter of updating the previously posted Quantian.vmx file to add the 'new disk'. I.e. instead of defining just one ide device, we now use two as per
# CDROM Info
ide0:0.present = "TRUE"
ide0:0.fileName = "quantian_0.7.9.1.iso"
ide0:0.deviceType = "cdrom-image"

# edd 31 Dec 2005 adding a virtual disk file
ide1:0.present = "TRUE"
ide1:0.filename = "Quantian.vmdk"
ide1:0.redo = ""
ide1:0.deviceType = "ata-hardDisk"
On the next reboot, Quantian will display a disk symbol for hdc. It it then a matter of starting a root shell in Quantian, running cfdisk or fdisk to partition the new "empty" disk drive and to add a /dev/hdc1 partition (or more), running mke2fs -j dev/hdc1 to add a filesystem --- and on a subsequent reboot, the disk is ready for use. It should thus be possible to create a suitable disk file of, say, ten or so gigabytes (given that Quantian expands to around seven gigs), create a filesystem and then run knx2hd to install Quantian onto the new virtual disk, make the disk bootable and, presto!, have a virtual instance of Quantian on stateful read/write media. While my tests have been limited to using a Linux host, this procedure should work just the same way in Windows. Oh, and as it's still early afternoon here: Best wishes for 2006 to everyone!

Zak B. Elep: away from keyboard

Ok, so I’m supposed to write about some things in retrospect with 2005, like the many folks who did so already. Unfortunately, I’m out of time here (’tis around 30 minutes before midnight, yet my folks are nagging me to join them at my tita’s house, so I’ll just save the retrospecting for later. Well, later… HAPPY NEW YEAR!!! PS: Sorry for spamming Planet Debian as I just upgraded to WP 2.0, and my feed b0rked :(

Uwe Hermann: 22C3: Final Stuff

More Bandwidth OK, I will make this short because a gazillion of other people will probably blog about the 22C3 for several days or weeks to come... Today (last day) I only attended one talk — Bluetooth Hacking - The State of The Art. Funny stuff you can do with Bluetooth... All in all it was a great conference. Get the proceedings or browse the list of talks (most of them have PDFs attached) for more details. Videos of all talks should be available anytime soon (I hope!). Oh, and the 22C3 is probably the only event where you will see such signs (attached to walls by the congress staff!)...

30 December 2005

Andres Seco Hernandez: Video again, sponsoring and Noche Vieja


Holger Levsen wrote me with news from "the lost video" from debconf-es II. It has a special meaning for me, as my old boss and dear friend, Salvador Garcia, talks about the reasons we must continue looking for new software options continuosly. Holger gets the VHS tape and i didn't remember about it. Thanks, Holger.

Finally my ipw2200 runs with the correct firmware version in 2.6.14. Uff.

I have spent this two last nights reviewing some packages from two future NM, Ivan Forcada and Javier Ballesteros. They are swscanner, ksalup and mgm. Sponsoring packages is really hard. If they were my own packages i have not to explain what i see inadecuate, but i think is worth enough because they have much ilusion and desire to contribute something to the project. Amaya talk in debconf-es II about "El sponsor, ese animal esquivo" was really funny. I am thinking about creating an Amaya's Fun Club, as she made with Branden ;-)

Be careful with alcohol in the last night of the year. We call it in Spain "Noche Vieja".

Fun for all.

Adeodato Sim : Guadalajara

A couple weeks ago, Debconf-ES II was held in Guadalajara. It was terrific: meeting again some people whom I already knew, many of which are more than fellow developers; meeting for the first time some others who I hadn’t; and, of course (and finally!), Mao. There was also a KDE talk, telling a bit the story of the Debian Qt/KDE Maintainers. I enjoyed it a lot; among other things: As always, eternal gratitude to the people that worked their asses off to make this event possible. Even if not tons of work got done during that weekend, it was surely a big dose of energy for all of us! NP: Astrud, Masaje

29 December 2005

John Goerzen: Hospital For Sale on eBay

Halstead Hospital and Hertzler Clinic in Halstead, KS are both for sale on eBay for $1.9 million. This was once a thriving hospital in central Kansas. It shut down abruptly a few years ago after it turned out that the management was engaging in their own mini-Enron with its finances. My family doctor was in the clinic part of this building for several years. It's still surprising to me that it's closed.

Decklin Foster: lastfmsubmitd

Apparently, tis the season to be writing your own Last.fm plugin. So here is mine. I finally got fed up with finding and causing bugs in mpdscribble (I am a bad sponsor!) it s written in C with libsoup, blah blah, can t stand C, and so I revived the MPD pseudo-listener I had started on as a replacement for that awful orphaned cacheless one-off we were all using before mpdscribble. I also fixed a few issues that were bugging me, like failing to detect restarts and tag changes. Not wanting to muddy up any of that logic with HTTP gar, I decided to write a separate program to queue, cache and send along song submissions. They re two or three hundred lines of Python each, and single-threaded (yes, that means child writers blocking and hanging around if the network code is in the middle of timing out or backing off. Deal with it! This is UNIX). I m pretty happy with the design, although the implementation is still very rough. This also mimics the model they want to move to for player plugins in general, which is good, because it will be less work for me to implement version 2.0 of the protocol once that is finalized. Additionally, I was able to find a more satisfying way to solve the disconnected-CD-player problem than my previous dreadful method of either using a few kludgey scripts to frob around in my primary plugin s cache or dealing with using cdscrobbler and having to be very careful about one plugin not stepping on the other s toes and invalidating my backlog. So this is the second example program included. (Oh yes, that part uses the Python bindings for MusicBrainz. MB is awesome. The Python bindings are hideous, however straight port of the C++ API. I d probably be better off just dumping the RDF into a real RDF implementation and doing my own cross-referencing, instead of prying it out piecemeal with select queries and non-polymorphic getters and all the other absolute nonsense you have to deal with when writing in a language without high-level data types or garbage collection. But regardless of implementation woes, this has kept me close to the MB metadata for my favorite CDs, and so I ve been busy all week entering and voting on mods (and doing research to justify my changes), which is very satisfying. I have yet to begin the gargantuan task of adding MB tags to my Ogg collection (I know, this is really just a matter of babysitting tp_tagger, but I ve got some work cut out for me to even get to that point).) And of course, once this becomes less prototypey, anyone who likes it can knock all the networking code out of their plugin and use it as their system service . Perhaps if I m agile enough this can become official code! It is at least a mootable proof-of-concept that UNIX systems don t necessarily need a heavyweight libscrobbler to abstract the service stuff out of the player plugin. I won t get my hopes up though. Still a bit unsure about the name. Theoretically it seems the service (you know, the thing we pay money to if we like it) should be Last.fm, while the software and protocols should still be Audioscrobbler, but the distinction does not seem to be drawn very clearly in practice. With the analogous situation of livejournal vs. ljcom you had a grokkable technical delineation (different repositories) as well as other widely used installations besides ljcom (DeadJournal, etc). I really can t see there ever being a competing installation of Audioscrobbler, because licensing the streamables is a formidable investment hurdle, and there s a negative market effect (also, the web site is not open source). But I am also bored of just sticking scrobble onto something else, so I wanted to grab sticking last onto something else before it got old. I haven t the faintest clue what makes me prefer whimsical names for some projects and prosaic ones for others. Note to actual MPD users (all, like, 5 of you): the stuff in the package will not handshake at the moment, as I have not yet gotten Russ to bless the client ID I made up. Will try to catch him tomorrow. Or later today I suppose. It s ready to go now. Next up: Because it s either this or Sound Juicer, I think perhaps it s time to bid adieu to abcde and write a MusicBrainz plugin for jack (jack is nice enough, I just haven t had a truly compelling reason to switch, and there have always been lots of good eyeballs on abcde). FreeDB delenda est.

Decklin Foster: Humane interfaces

You know, I think the whole thing missing in this whole kerfuffle (as James Robertson put it) from a few days ago is that it s not list.first(), it s list.first. Just pretend you re sending a message, baby. Of course, if your brain is still stuck in imperative mode, the first is available; it s simply a matter of how to express what you wish to convey that you are doing, which is really not something that minimal class design defines as part of the problem. So. Ahem. Curtain.
HAMLET
Java s a prison.
ROSENCRANTZ
Then is the world one.
HAMLET
A goodly one; in which there are many classes, methods, and runtimes, Java being one o the worst.
ROSENCRANTZ
We think not so, my lord.
HAMLET
Why, then, tis none to you: for there is nothing either functional or procedural, but thinking makes it so: to me it is a non-Lisp.

Decklin Foster: Non-GUI Music Players

Clint, I use MPD. You can do everything from the command line with mpc. (I frequently do, but I m also trying to help hack Pygmy into something decent for clicky-clicky use as well.) Also very useful if you want to do the whole diskless machine in the stereo cabinet with its library mounted over NFS thing.

Decklin Foster: Ruby Love

Matthew Palmer writes about the goodness that is Ruby. I, too, have just recently been won over, and am stumbling along with the online docs. In fact, this can be done in one line:
STDIN.readlines.sort_by   rand  .each    line  puts line  
But this is slow, as sort_by needs to be at least O(n lg n), and probably not perfectly random (I suppose you could do rand <=> 0.5, but that s not perfect either). What to do? We can implement a proper Fisher-Yates shuffle in a function, but that takes a couple lines. Can we still perform the actual read-and-print in one? Yesterday, why wrote something that really made me stop and go wow . We can attack the random sort problem in a similar (if more boring, as there are no lambdas to pass in) way, by simply adding another method to Array:
class Array
    def swap!(a, b)
        self[a], self[b] = self[b], self[a]
        self
    end
    def shuffle!
        each_index do  i 
            j = i + rand(length - i)
            swap!(i, j)
        end
        self
    end
end
STDIN.readlines.shuffle!.each    line  puts line  
Now that is cool.

28 December 2005

Paul van Tilburg: Christmas 2005

Two days before Christmas I was invited by my colleague, Krzysztof, and his wife to come over to their place during Christmas to have a (Polish-style) Christmas supper/lunch. This meant that I didn’t have to be home alone on campus for Christmas, just hacking a bit, slumbering and watching some movies/series. The Water of Leith near Currie The trip to their home involved quite a walk from the university campus through villages and alongside the Water of Leith, but it was perfect weather to do so (in contrary to the weather on the second day of Christmas). We had a nice supper and I want to thank them for the invitation and the meal. Work Progress I feel I have made a lot of progress since the last time I reported. In the past week I have been able to implement a big part of the MathLang checker and create a lot of output generators useful for debugging such as a debugging library for printing data structures, an ASCII tree (a la the output of the tree command) representation of the AST and an AST-DOT-file generator which in turn can be transformed to many formats. I have worked it all out for a simple example that I have just added to my MACS site.

Uwe Hermann: 22C3: Impressions, lectures, hacking, bb ported to iPod

Train Station It's day 2 of the 22C3 congress — time to post some stuff. I've been travelling to Berlin by train with Daniel Reutter, taking a bunch of photos with my new PowerShot A610 (see photo on the right, for an example). You can browse the 22c3 flickr group for more photos. We've listened to quite a lot of lectures already, and many more will follow. Especially the keynote by Joi Ito was really great, the network here works most of the time (wired net, as well as WLAN), so everything's fine for now... As far as hacking is concerned, we played around with iPodLinux a bit. We managed to port aalib to the iPod an then (more interesting) we also ported bb, the portable text-mode demo. There are some issues on both the 4g iPod and the 5g iPod we tried this on, but we're working on it... We have documented the ports in the form of HOWTOs (currently Debian-specific) in the iPodLinux wiki (aalib, bb). bb on a 4g iPod
bb on a 5g iPod photo 1
bb on a 5g iPod photo 2 Up next: porting Ruby to the iPod.

Andrew Pollock: [life] Back online

Our DSL modem finally arrived today. Well, it kind of involved accosting the UPS guy in an adjacent street whilst walking back home from 7-Eleven acquiring ice cream, but hey, we got the thing in the end. I went with Sonic on advice from guys from work, and I have to say I've been totally impressed with their customer service to date. Today I got an email from them because I'd reached my activation date, but they hadn't seen any ADSL traffic from me yet, and they just wanted to check that everything was okay. We had a free dialup account for use while we waited for the ADSL to be provisioned (and the delay was with receiving the modem over the holiday season, not the ADSL provisioning itself). Also, their account management website allows an impressive amount of self-control over aspects such as spam filtering and firewalling. I'm a very satisfied customer so far.

27 December 2005

Matt Brown: Miredo/Toredo Patent Status

Miredo is an implementation of the Teredo - IPv6 over IPv4 tunnelling protocol which I have been playing with lately. I have filed an ITP bug to get Miredo into Debian, however this has been delayed while I try and get a handle on some of the patent issues surrounding the Teredo protocol. While Miredo itself is licensed under the GPLv2 the state of the Toredo protocol is less clear. Teredo was created by Christian Huitema, an architect with Microsoft. It is currently a Proposed Internet Standard waiting for the IETF editor to review it and assign an RFC number for it, IANA will then assign a permanent prefix for use by Teredo clients, servers and relays. According to the IETF IPR disclosure page, Microsoft has filed a statement of claim against the technologies described in the Proposed Standard. Microsoft states that they will provide a Royalty-Free, Reasonable and Non-Discriminatory License to All Implementers in their statement. Specifically the license that they offer the Teredo protocol under is called the Microsoft Royalty Free Protocol License Agreement. This is a catch-all license that Microsoft uses for all client-server protocols used by Windows. The license itself doesn’t make any claims about Microsoft’s IP rights, it simply gives you a license to use any rights Microsoft may have in the specific protocol you are using. For example at the end of the license agreement you select which protocols you wish to have covered under the agreement. Alongside Teredo you can also choose protocols such as IPv4, DNS, 6to4 and lots of other common protocols. The actual patent application for Teredo is incredibly difficult to find, the IETF IPR disclosoure doesn’t link to it, none of the proposed standards link to it and googling for “Teredo Patent Application” isn’t particularly successful either. In the end it turns out that the title is quirkily named “Allowing IPv4 clients to communicate over an IPv6 network when behind a network address translator with reduced server workload” and was published as Patent Application 20040190549 on the 30th September 2004. Incidentally if anyone knows of a nicer way to link to a US Patent Application than the ugly URL above, I would love to know. Half the reason that the Patent Application was hard to find is that it doesn’t actually mention Microsoft anywhere at all, unlike the ~5000 odd other Patent Applications currently filed by Microsoft. From what I can tell it appears that Christian Huitema has filed the application through is own personal attorneys independently of Microsoft. So where does this leave us in terms of getting Miredo into Debian? The short answer is I’m not entirely sure. I can’t seem to find a definitive statement regarding Debian’s position on patents anywhere, the best I’ve been able to come up with is a debian-legal post from Andrew Suffield from Jan 2005 which offhandedly describes the informal Debian patent policy as:
“ignore patents until somebody starts to wave them around, then drop the offending thing like a hot rock”
So maybe I’ve already shot Miredo in the foot, by investigating its Patent Status… :( My take on the situation seems to be that Debian is perfectly happy (and perhaps has no other option but) to ignore patents applicable to software in Debian until it becomes apparent that a particular patent is being enforced or has the potential to be enforced. So the question now becomes whether the Microsoft Royalty Free Patent License is acceptable enough to Debian to allow Miredo to be included in main or non-free, or whether it simply can’t be redistributed at all. The main problem I see with the license is that it does not permit you to sublicense other parties to make use of the Toredo technology used by Miredo. If this were a copyright license then that would most certainly fail to pass the Debian Free Software Guidelines, does Debian treat patents in the same manner? I think it’s time for me to post to debian-legal to seek some “official” guidance on the situation, but hopefully this post has ordered my thoughts enough that I can now write a coherent mail seeking help. If you have any comments or pointers to Debian statements on this sort of situation that I have missed they would be most welcome.

26 December 2005

Clint Adams: No hay gracia en este elitismo

She was a fierce and majestic creature, with a fearsome bite and terrible claws. The anger of a thousand suns burned within her. She was a spoiled brat who needed to be the center of attention. In order to incite people to hurt her, she abused those who were foolish enough to pay her attention. She was a bandit, waltzing in the nighttime with a hundred sparkling rings. She was indigo, red, gold, green, light blue, red, yellow, orange, green. She was green. She was a fierce and majestic creature. She was GREEN.

Christine Spang: Aftermath!

My parents are buying me a professional French horn! (The one I use currently is owned by the school.) Like this. Also, I think I have six months worth of new books to read, combining Christmas with my birthday last month. <boggle> Plus, I have one gift certificate to Borders and one to Barnes and Noble (from birthday). And the special edition DVD of Monty Python and the Holy Grail. Thank you, I felt the need to share that with the world.

Axel Beckert: Yet another old laptop

My father got me a nice IBM ThinkPad from 1996 earlier this year, so the next old laptop he digged up was planned to become a christmas present for my brother. But my father didn’t manage to find out, how old nor how fast that laptop was. And when I found out that it was a Pentium I with 90 MHz, it was clear, that my brother wouldn’t have any use for it, so he got “only” the used 850 MHz AMD Duron midi tower and my parents declared that old Compaq LTE 5100 laptop as a christmas present for me. :-) As my IBM ThinkPad bijou, this Compaq LTE 5100 is from 1996 and has a Pentium I processor. Both also have a 800×600 resolution, a double PCMCIA slot and a floppy drive, which can be replaced by a CD-ROM drive (if I had one). But that are all similarities. Technically the Compaq has 90 MHz instead of the ThinkPad’s 133 MHz, but therefore has 72 MB RAM in comparison to the 48 Megs the ThinkPad has. Also regarding disk space the Compaq outperforms the ThinkPad: 1.6 Gigs of disk space in comparison to the ThinkPad 1.0 GB hard disk. Another difference is the battery: While the ThinkPad can work over 2.5 hours without external power, the Compaq even didn’t manage to completely boot its currently installed Windows 98 (the ThinkPad had a Windows NT installed when I got it) when running on battery. (Will do that test again when I can confirm, that the battery was full before testing. :-) Yet another difference is the keyboard layout: The ThinkPad has an US layout while the Compaq has a Swiss-German layout. But the most obvious difference is the look: The black ThinkPad still looks like having a modern design while the Compaq looks very very outdated in its perfect computer beige and with its quite small display. So retroperspectively, it was a good a idea to name the ThinkPad “bijou” (French for jewel, jewellery, gem, etc.; named after a very neat british two-door limousine built in the UK by Slough on a 2CV base during the ’50s). Because now I have the choice between a lot of not so nice looking (not to say ugly ;-) 2CV derivatives to name the Compaq after. My favourites currently are the Iranian “Baby Brousse”, the Greek “Namco Pony” and the German “Fiberfab Sherpa”, all canvas and flatbed style 2CV based buggies, similar to the original Citroën Méhari but with steel body instead of the Méhari’s controversial plastic body. And one of the not used names, I can use for further ugly Compaq laptops¹. Another question yet to answer is the question of what operating system to install on it. Since the ThinkPad runs fine with Debian 3.0 Woody and I have a lot of other Debian boxes at home (running Woody, Sarge or Sid), I currently think about installing the very fresh NetBSD 3.0 (released on Christmas’ Eve 2005), FreeBSD 6.0 (released early November 2005), DragonFly BSD 1.4 (to be released in December :-) or DeLi Linux 0.7 pre (which was also released in early December 2005 and already uses X11R7). Another idea was to install grml 0.5, but since grml is a live CD distribution, it probably would be hard to install it over network. Same counts for ReactOS (version 0.2.9 was released shortly before Christmas 2005), which doesn’t seem to have a floppy disk plus network install. Since I always planed to upgrade my currently defective Toshiba T6400 i486 laptop ayca (maybe after getting an organ donor on eBay or so) to DeLi Linux 0.7 (and perhaps write a review about it for Linux Magazine or so) and I may get an Sun Ultra Enterprise 2 soon (on which NetBSD 3.0 would be the perfect OS since Linux’ performance still seems to suck on Sparc :-), I currently prefer the FreeBSD or DragonFly idea. If the Ultra doesn’t come, it probably will get NetBSD, since I haven’t a NetBSD box yet. (Haven’t a DragonFly box either, but a FreeBSD 4.x running somewhere. :-) Well, I guess, I’ll take even more old laptops than last year to the Vintage Computer Festival Europe (VCFe) next May. And since the two 1996 laptops are now 10 years old, they’re even ontopic! Yeah! ;-)

¹: I have two other not yet working Compaq laptops, both from an elder generation than Pentium I. One I got on a Swiss flea market for a few euros and the other was the first laptop of my boss, which he else would have thrown away. Unfortunately both are without power adapter and neither the usual allround laptop power adapters from Conrad, etc. nor the one from the LTE 5100 fits. But since there is eBay, I expect to get such a power adapter once. :-)

Andrew Pollock: [life] First Christmas abroad

(I love the term "abroad". It sounds so English.) Well that happened. We had Michael and another Andrew from work who started two weeks before us and his wife come over for what Michael was calling "linner" (the inverse of "brunch"). Sarah cooked up an absolute storm. We had roast turkey, roast potato, pumpkin and sweet potato, steamed broccoli, cauliflower and asparagus, and Yorkshire puddings. We had so many types of gravy we completely forgot about the cranberry sauce. Michael managed to track down a plum pudding (this country seems obsessed with pumpkin pie) and we had something approximating custard (something else this country doesn't seem to do) with it. A very good feast was had by all, and six hours later we were done. Back to unpacking boxes. Brought to you by some kind neighbour's open access point.

Matthew Palmer: Language Is Not Just Syntax

My current long-term learning project is Ruby on Rails, the ultra-hyped web application framework from David Heinemeier Hansson and friends. I like it (primarily because I can see a lot of my own abortive ideas from a web app framework for PHP I used to develop), but there is one big thing about it (or, rather, it's surrounding hype) that irritates me. Throughout the Rails literature (webpages, magazine and webzine articles, and the book Agile Web Development With Rails), there is a consistent message -- that, because everything is written in Ruby, you don't have to learn any new programming languages to write Rails applications. This is a wonderful theory -- no large XML config files to define my database schemas, and no castrated and irritating HTML template system to learn. From defining table relationships to printing a select tag, It's All Ruby, All The Time. Sweet, right? Sort of. The problem is that you won't find the language primitive to declare a one-to-many relationship in the Pickaxe (the definitive Ruby language reference book -- like "the Camel" for Perl, "the Bat" for Sendmail, or "the Turkey" for PHP). Defining a separate namespace in Rails for all of these operations is, of course, necessary, since the language didn't already define these operations. But, once you've defined a whole new set of methods to do all of these operations, you can look back on your hard work and see -- what? A new language -- one specifically designed to describe webapps. Don't get me wrong -- domain-specific languages are teh r0x0r. If everyone had to do all of their HTML manipulation by hand, programmers would be even more insane than they are. But, when you're writing your application in Rails, you're not speaking "pure Ruby". Your syntax and basic structure is Ruby, but your methods and attributes are new, different, and All Rails. It may not be a separate programming language in the usual sense, but by the time you've added a whole new pile of classes, methods, and attributes (not to mention whole new ways of structuring your application), how much importance is the use of the @ symbol to signify an instance variable, compared to the whole new set of methods to learn? Natural languages, of course, have similar issues. Most western european languages share a lot of common characteristics -- similar character sets, punctuation sets, and they read left-to-right. So I can look at a page of German or French, and identify most-to-all of the salient features (hey look, an 'a'!), and even grok the meaning of a few of the words (familiar to me, probably, because English misappropriated them from wherever they came from) but I still have no hope whatsoever of understanding the meaning of the passage as a whole. The language syntax looks familiar, but those nouns and verbs don't have any meaning to me. You can't plonk a Rails app in front of even a seasoned Ruby developer and expect them to immediately jump in and start hacking on it like they've been writing it all their life. The language syntax looks familiar, but those methods and attributes don't have any meaning to them. This is nothing peculiar to Rails, of course. If you want someone to hack on your Hibernate or Spring app, you'll get better results if you advertise for a Hibernate or Spring programmer than a Java programmer. But Rails advocates regularly say "it's all just Ruby, so there's nothing new to learn!", and that's Just Wrong, in my opinion. As an aside, if you're looking around for something a bit different, do seriously consider Rails (or just Ruby, if you don't need a webapp framework). It's different from the "usual" suspects (C, C++, and "the Ps" -- PHP, Perl, and Python), and pleasantly so. If you judge your programming languages by the old adage "a programming language that doesn't change the way you think about programming isn't worth learning", Ruby will score well. I know it's helped me think about my programming differently already, especially my Python programming (and thanks to Anthony Baxter for answering all of my esoteric python questions at OSDC a couple of weeks ago).

25 December 2005

Enrico Zini: Including inline images in Ruby GTK2

Including inline images in Ruby GTK2 I'm making a simple application and I'd like to keep it self-contained into a single file; however, I'd like to use some custom icons in it. I tried storing a pixbuf in a string:
ICON = <<EOT
/* XPM */
[...]
 ;
EOT
icon = Gdk::Pixbuf.new ICON
but it tried to open a file called "/* XPM */\n....". I tried with an array:
icon = Gdk::Pixbuf.new ICON.split("\n")
But I kept getting GdkPixbuf-WARNING **:Inline XPM data is broken: Invalid XPM header. Note that trying to write that data to a file and loading the file, worked. This worked:
icon = Gdk::Pixbuf.new "pippo.xpm"
This didn't:
tmp = IO.readlines "pippo.xpm"
icon = Gdk::Pixbuf.new tmp
I finally managed using csource:
  1. gdk-pixbuf-csource --raw --name=antani image.png > /tmp/antani

  2. insert /tmp/antani in the Ruby source code, strip away the comments, concat the various strings:

    ICON = ""+
      "GdkP"+
      "\0\0\4\30"+
      "\1\1\0\2"+
      "\0\0\0@"+
      "\0\0\0\20"+
      "\0\0\0\20"+
      "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"+
    [...]
    
  3. load the data with icon = Gdk::Pixbuf.new ICON.unpack("C*"), true

A possible improvement could be using --rle in gdk-pixbuf-csource: raw is good for avoiding to copy the image data, but I don't feel comfortable in doing it since the image data is an integer array temporarily generated by unpack. As usual, if you know of better ways please send me a mail and I'll update the blog entry.

Next.

Previous.