Search Results: "ghe"

29 December 2005

Jeff Bailey: Will bomb for food

CBC reports that fisheries around the world combined consume the same amount of oil per year as the Netherlands. They go on to explain:
  1. Depletion of fish stocks because boats are travelling further out to sea in order to meet demand causes higher fuel consumption.
  2. The fishing industry is still more efficient than other meat based industries.
Another way that your dinner can contribute to global warming and US-style "anti-terrorism".

28 December 2005

Jonathan McDowell: Linux WMDs

So, the delightful Kathy bought me a Marks & Spencer USB Missile Launcher (unfortunately out of stock at present or I'd have linked directly to it. Try searching on eBay / Google to see what I mean.) Problem. WinXP/2k only drivers. That's no fun. Plugged it in to my laptop (as you do). dmesg reports:
input: Tenx Nonstandard Devic as /class/input/input6
input: USB HID v1.10 Device [Tenx Nonstandard Devic] on usb-0000:00:1d.1-2
input: Tenx Nonstandard Devic as /class/input/input7
input: USB HID v1.10 Device [Tenx Nonstandard Devic] on usb-0000:00:1d.1-2
lsusb says:
Bus 002 Device 004: ID 1130:0202 Tenx Technology, Inc. 
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0         8
  idVendor           0x1130 Tenx Technology, Inc.
  idProduct          0x0202 
  bcdDevice            1.00
  iManufacturer           0 
  iProduct                2 
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           59
    bNumInterfaces          2
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0x80
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Devices
      bInterfaceSubClass      0 No Subclass
      bInterfaceProtocol      0 None
      iInterface              0 
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.10
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      43
         Report Descriptors: 
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval               1
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Devices
      bInterfaceSubClass      0 No Subclass
      bInterfaceProtocol      0 None
      iInterface              0 
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.10
          bCountryCode           33 US
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      23
         Report Descriptors: 
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval               1
The Windows software appears to consist of TenxHID.dll (24k) and Missile_Launcher.exe (908k). TenxHID only exports DeviceIni, ReadBuffer and WriteBuffer AFAICT. Which implies the higher level stuff is done in the exe to me. I think it's a job for USBSnoop and a Windows box, but that'll have to wait for a few days until I get back to a WinXP box I can use to fiddle. Unless someone else manages to write a driver in the meantime. :)

27 December 2005

Andres Salomon: xmpp4r and loudmouth

I don’t particularly want to add features to xmpp4r, simply because it is pure ruby. I would prefer to add features to a C library, which can then be used in various language bindings. Lowest common denominator, and all that. I also prefer the license; I’m a fan of the LGPL for these sorts of libraries. I started writing some ruby bindings for libloudmouth, which seems to do some of what I want (but at a much lower level than really desired. Via planet.jabber, I noticed the author intends to write a higher level API for loudmouth 2.x, but there is no code available yet. I may end up writing a separate library/layer to provide a higher layer API, if none becomes available anytime soon.

24 December 2005

Uwe Hermann: 10 + 100 Creative Commons Christmas Songs

Christmas Tree So, it's Christmas today (or it will be tomorrow, depending on where you live). Wouldn't it be nice if you had a bunch of freely and legally available Christmas songs you could listen to all day? Burn on CDs and hand over to your relatives? Share with your friends without the fear of being sued to death by big record labels? Well, here's a list of 110 128 songs which are all explicitly released under a Creative Commons license (no, I did not consider songs which are merely "podsafe"!) and thus can be shared, listened to, and sometimes even modified freely. There's a great variety in style, mood, and genre of the songs: some traditional, some contemporary, some happy, some sad, and some just plain funny. So here's the list: Single MP3s: Compilations: This list is by no means complete, I'm sure. So if you happen to know some more Creative Commons licensed Christmas music, please leave a comment! I'd love to hear about it. (Btw., the nice image on the right is taken from the Wikipedia. The author is Malene Thyssen, and the image is dual-licensed under the GNU Free Documentation License 1.2 and the Creative Commons Attribution-ShareAlike 2.5 license) Merry Christmas everyone! Update 2005-12-24: Added "We Three Kings".
Update 2005-12-25: In the press: Boing Boing, Creative Commons Blog, netzpolitik.org, Technorati, digg.com, del.icio.us and lots more. Added "How George Stole Christmas". Added "Winter Rose". Added "Still, Still, Still".
Update 2005-12-26: Added "Homeless Babe". Added "Christmas Impro".

22 December 2005

Enrico Zini: Custom signals with Ruby-GTK2

How to create a custom signal in Ruby-GTK2 I'm playing with the GTK2 bindings for Ruby. When coding GUI things, I usually like to build my own higher level widgets by subclassing containers and populating them with other widgets. For example, I'm creating an image browser and I like to make an ImageList class that subclasses a Gtk::ScrolledWindow and builds the TreeView inside it:
class ImageList < Gtk::ScrolledWindow
      def initialize
              super
              @files = Gtk::ListStore.new(String, String, Gdk::Pixbuf)
              @fileList = Gtk::TreeView.new(@files)
              renderer = Gtk::CellRendererPixbuf.new
              col = Gtk::TreeViewColumn.new("Thumb", renderer, :pixbuf => 2)
              @fileList.append_column(col)
              renderer = Gtk::CellRendererText.new
              col = Gtk::TreeViewColumn.new("File name", renderer, :text => 1)
              @fileList.append_column(col)
              self.add @fileList
      end
      
      def readDir (root)
              Dir.foreach root do  dir 
                      file = root+'/'+dir
                      if !FileTest.directory?(file) && dir =~ /\.jpe?g$/ && FileTest.readable?(file)
                              thumb = getThumbnail(file)
                              iter = @files.append
                              iter[0] = file
                              iter[1] = dir
                              iter[2] = Gdk::Pixbuf.new thumb
                              File.delete(thumb)
                      end
              end
      end
end
When working like this, I find myself very soon in need of creating custom signals: in this case I want to make a signal that ImageList emits when the user select an image from the TreeView, like this:
fileList.signal_connect("selected") do  filename 
      imageDetails.load(filename)
end
Now, how do I implement that extra 'selected' signal in my ImageList? Ruby documentation is usually very good and easy to find, but this time Google had little to say to me. When the going gets tough, the tough gets to IRC:
enrico> Hi.  http://ruby-gnome2.sourceforge.jp/?News_20031116_1 says that it is
        possible to create custom signals, however I could not find any
        documentation on how to do it.  Anyone has a link or a short explanation?
pterjan> glib/sample in the source IIRC
pterjan>   # define new signal "hoge"
pterjan>   signal_new("hoge",                  # name
pterjan>              GLib::Signal::RUN_FIRST, # flags
pterjan>              nil,                     # accumulator (XXX: not supported yet)
pterjan>              nil,                     # return type (void == nil)
pterjan>              Integer, Integer         # parameter types
pterjan>              )
pterjan> in glib/sample/type-register.rb
enrico> ooh!
enrico> pterjan: thanks!
enrico> I'll blog about it, it might make it easier for others to google this answer
Thanks pterjan, and oh, coolness! So there are nice examples that I was silly enough to miss. Are they included in the Debian packages? Oh, yes! Right in /usr/share/doc/libglib2-ruby/examples/type-register.rb. Here's the ImageList class with the new signal:
class ImageList < Gtk::ScrolledWindow
      type_register
      signal_new("selected",              # name
                 GLib::Signal::RUN_FIRST, # flags
                 nil,                     # accumulator (XXX: not supported yet)
                 nil,                     # return type (void == nil)
                 String                   # parameter types
                 )
      def initialize
              super
              @files = Gtk::ListStore.new(String, String, Gdk::Pixbuf)
              @fileList = Gtk::TreeView.new(@files)
              renderer = Gtk::CellRendererPixbuf.new
              col = Gtk::TreeViewColumn.new("Thumb", renderer, :pixbuf => 2)
              @fileList.append_column(col)
              renderer = Gtk::CellRendererText.new
              col = Gtk::TreeViewColumn.new("File name", renderer, :text => 1)
              @fileList.append_column(col)
              self.add @fileList
              sel = @fileList.selection
              sel.signal_connect("changed") do  sel 
                      if iter = sel.selected
                              puts "Double-clicked row contains name # iter[0] !"
                              self.signal_emit("selected", iter[0])
                      end
              end
      end
      def signal_do_selected(file)
            puts "Selected " + file
            #p caller
      end
      
      def readDir (root)
              Dir.foreach root do  dir 
                      file = root+'/'+dir
                      if !FileTest.directory?(file) && dir =~ /\.jpe?g$/ && FileTest.readable?(file)
                              thumb = getThumbnail(file)
                              iter = @files.append
                              iter[0] = file
                              iter[1] = dir
                              iter[2] = Gdk::Pixbuf.new thumb
                              File.delete(thumb)
                      end
              end
      end
end
And here's the controller code that binds the signal to some effect:
imageList.signal_connect("selected") do  imagelist, filename 
      puts "File # filename  was clicked!"
      image.load(filename)
end
It's quite easy, and (finally!) it does what I want without needing to write thousands of lines of code. YAY! And I finally fulfull my dream of connecting closures instead of callbacks to GTK signals. Yes, I could have done it in Perl. Yes I could have done it in Python. But Ruby is soo cute!

8 December 2005

Clint Adams: zomg

This is not the ugliest code I have ever written. The handling of HTTP/1.1 chunked transfer-encoding is a horrible hack. The indentation isn't quite as random as I would like. I have other complaints, but I've forgotten them, as zomg does mostly what I want, which is to play music and report it to Last.fm. Unfortunately, it lacks the power of vux, but that's another story. zomghelper is a C program that extracts the relevant data from an Ogg Vorbis file. It written because vorbiscomment doesn't report the track length, and ogginfo is much too slow for my needs. I don't expect most people to share my needs, so the five of you that are actually going to use zomg probably won't need it.

6 December 2005

Martin 'Joey' Schulze: Why I joined LinuxTag

In 1999 I went to LinuxTag as a Debian representative after the project has received an offer to staff a booth there. I took over the maintenance and organised the first Debian meeting in Germany. I also gave two talks during this event, one of them was even repeated on the second day. We've had a lot of fun and since this was the first meeting of Debian affiliated people in Germany, it was very interesting to connect faces to mail addresses and to learn more about the people behind a name. This LinuxTag was the last such event that took place at the University Kaiserslautern. Free projects such as KDE and Debian have been offered a booth in one building from which one could reach the lecture rooms, while company booths were located in the Mensa building with their own professional booths. It was a warm weekend and the Jolt people have supported us with cool and caffeined drinks. We had the opportunity to use a lecture room for sleeping with other project members. Klaus Knopper was supporting the network and supervised the security team, and hence, had the unfortunate job to move away all project members from their booths, out of the building or into the lecture room. I've heard, that he had a hard time, and still believes that Debian people don't need sleep. I guess we should have moved him into the lecture room for a sleep instead. This '99 LinuxTag was quite a real success. It took place at the rise of the dot com era and all people were happy about the event. There were about 7,000 visitors in total on both days. The city of Kaiserslautern has called the university several times since there were no free hotel rooms anymore. Former events happened more or less unnoticed by locals, but not anymore in 1999. After the show was over, we dismantled the booth, moved away our own equipment and left the place. However, I made the "mistake" to notice that the LinuxTag people, who have provided us such a great opportunity, still had work to do since they had to dismantle the booth system and clean the ground floor. My biggest "mistake" was that I didn't run away and have a nice evening but decided to help and ask other booth members who were still around to do the same. Having cleaned up the location quite fast was not the only result. Oliver Zendel, who was in charge of talking to the community and who offered Debian the booth, spoke to me afterwards and wondered whether I would be interested to join the team. Well, I knew how to organise stuff, can talk to people, know quite some people in the community, the LinuxTag people were a cool team, so why not. So for the event in 2000 I was in charge of the projects exhibition. In 2000 we also had to move out of the university of Kaiserslautern since 7,000 visitors were already too much for that small university and city. That's why we eventually moved to the Stuttgart fair. That was an interesting experience. It was also interesting to see how such an event can be organised by a team of friends and how the acceptance in the business world was. In Stuttgart we were able to use a small office (max. 15m ) for the entire team as working space. Two computers were installed which we were allowed to touch but not to install a real system on. Hence, Klaus brought Knoppix CDs. This was the first time that I learned about the Knoppix Live CD. Together with my notebook we've had three desks and could work. However, today I really wonder how this could have worked with so many people, but apparently it really did. Due to the need and my experience in both talking to the press and being the press I joined the LinuxTag press team and even held the final press conference, while my colleague held the opening press conference. So after all projects were happy, the show went fine and most of the office jobs were done, I prepared a press release together with others and maintained the final conference. This was also the first time LinuxTag has organised a business congress as a special extra program for business representatives. It was also the time I experienced the need for several supporters for various tasks. In that year, a dozen supporters were paid as "security" who also drove the shopping for us. Hence, I already acquired some people who supported us as volunteers. That was also the time when Benny joined the team. In 2000 the exhibition boomed and there were a lot of large dot com company booths, which was very nice because LinuxTag arose from a students association and became more and more professional, a platform for both companies and projects. It was organised just like a Free Software project and worked non-commercially. Despite several flame wars and disputes, which seem to be normal, it was organised by friends who believed of a higher goal. It was very nice and gave me a warm feeling when looking at what we have achieved. However, I had nothing to do with commercial interests, income, acquisition, invoices etc., so I may have missed a lot. This year, LinuxTag was planned to take place in one exhibition hall, but there were so many companies interested in running a booth that a second exhibition hall was later rented as well. That's why there were two adjacent halls instead of one large location. In 2001 we were using a different exhibition hall, a larger one due to the strong demand in 2000, but still at the Stuttgart fair. This time I was also in charge of the supporters and already dispatched jobs during the event. From time to time I also maintained the shuttle service to the airport to pick up speakers or take back speakers, which I've also done in 2000. This time we've had a larger office in which all of use fit and which was a nice working atmosphere. We were also able to provide more booth space to Free Software projects. In that year I've automatically taken over the office and communication with the outside world, collecting and distribution information. I don't think this was planned, but it just happened since I was able to do the job besides my other obligations. I also gave a talk about Debian, even though others in the team considered me insane for doing that as well. With a lot of help by the local user group, we were able to offer project members a cheap sleeping opportunity. The LUG acquired a gym hall during the night an cooked in the student's office "Hellblaues Nilpferd". After I've picked up Hans Reiser I went there for a snack with him before dumping him at the hotel. It was a nice atmosphere. One of the lead people for this effort, Hubert Kai er, was suddenly overtaken by death two weeks ago. In 2002 LinuxTag moved to Karlsruhe and thus to a new fair where everything had to start again from zero. We had to get acquainted with the local company and their representatives and learn how the new fairground works. The fairground was more interesting since there was a large open area between the conference site and the exhibition hall. Looking at past years, it was used by visitors. Thanks a lot to Jochen Topf from GUUG and members of the local user group KaLUG a lot of community events happened during LinuxTag. They maintained an Internet caf in the conference building and organised the legendary KaLUG party which has become a regular LinuxTag event. In addition to that I've also worked more and more and took over more areas where I noticed help was needed and that I could manage it. So it happened that I took over more work at and before LinuxTag which finally resulted in two months of work were I don't remember a day on which I've worked less than 8 hours for LinuxTag in 2005. In 2002 I worked on the coding marathon and delegated the tasks and support during LinuxTag to two other people, so it will run independent of me. Since I was the first of the team to arrive in Karlsruhe, I also built up the office and the storage. Due to the large distance I had to leave Oldenburg the day before I want to arrive in Karlsruhe, so that I was at the fairground at last at 10 o'clock on Sunday morning. Before the event a lot of issues had to be negotiated with various parties, which required quite a lot of work. Until 2004 the entire team was working in their spare time without getting paid for their LinuxTag work. The higher goal was the impulse and all of us had neglected one issue or another that wasn't important for LinuxTag. We've had some external service providers at least since 2002. The acquisition became a difficult task for students who liked to work until the morning and get up at lunch time, since many companies expect a partner that is available for them from 9 to 5. That's why Charter was eventually hired and this year ergomedia. For press work newthinking was hired. This year the social event was also organised by them. However, having two people from the board of directors being paid by the association for their LinuxTag work from April, and external service providers that were also paid, was something I considered problematic if not unfair, looking at how other people commit to LinuxTag and don't get a monetary compensation. Several people still worked a lot on LinuxTag in their spare time and had to live from something as well. It caused resentment in the team.

2 December 2005

Adam Rosi-Kessel: Dear Msnbot

Dear Msnbot: why do you hammer on port 8080 when there is nothing listening there? I recently set in place a comprehensive iptables firewall and have started logging dropped packets. I’ve noticed the highest number of dropped packets comes from 65.54.188.51 aka msnbot.msn.com. Does it just try port 8080 on every known domain name, “just in case”?

24 November 2005

Martin F. Krafft: Bug squashing bounties

I just sent this to debian-devel-announce. Hopefully it will be a success!
Dear fellow developers and contributors, My publisher, Open Source Press, and I were pondering ways to help the F/OSS community (and Debian in particular) over a beer the other day, and the following idea is the result:
We are announcing a bug squashing period, starting now, and ending 14 Dec 2005, 11:59 CET. Squashing a bug gets you a certain number of points (depending mostly on triviality and severity). At the end of the three weeks, the 25 bug squashers with the highest score shall receive a copy of my book, The Debian System, donated by the publisher. If this turns out to be a success, we'll lather-rinse-repeat sometime soon.
Bug squashing is to be done according to the rules listed on the wiki. In particular, everyone is expected to make proper use of usertags to communicate to others that s/he is working on a particular bug. If you are working on a bug, you are expected to send status updates to the bug report at least once in four days, or someone else may announce the intent to lock the bug and take it over after 24 hours. Fixing a bug also involves augmenting the bug report with any relevant information as you go along, and testing the fix with which you came up.
Points will be given to those whose contributions fix a bug. A bug will be considered fixed if a patch addressing the problem has been sent to the BTS and the package's maintainer has not vetoed the patch within five days. Please do not actually close bugs in the BTS (unless you really know what you are doing). Points will only be awarded to patches for bugs which have been reported before this announcement (but you are, of course, welcome to fix any bug -- if it's obvious you aren't trying to cheat and you are otherwise very actively fixing bugs, you may even get points for those too). After submitting a patch to the BTS, please send a short note to book-bsp t pobox.madduck.net with the bug number in the subject, and from the email address you used to interact with the BTS. In the message, list any contributors who have helped with the bug, as well as an approximation of the time each of you spent on fixing this bug. Also, document how you have tested your patch. The amount of points to be awarded depends on the severity of the bug report, as well as the triviality of the patch you came up with. Put differently: while a one-line patch for a wishlist bug might get you 1 point, I could award 100 points for a clean yet elaborate patch to an important bug. Bonus points can be given if you provide reasonable proof of thorough testing of your fix (you could use test-driven development techniques..., also see here), ideally by a third party. Please be aware that bugs fixed by the reporter him/herself will be especially scrutinised.
Anyway, there are no strict rules for the amount of points a patch will get you. In fact, I reserve the right to announce the scores only after the end of the bug squashing period, and I will not answer questions about scores, or address complaints from people who think they have not received enough. However, I shall act as objectively as possible, fair, and honest; for that, I give you my word. I realise this is sketchy and if you don't trust me on this, it's your choice not to participate -- there is no point to argue at this stage. If you have a better suggestion, I would be interested in trying it the next time 'round. Maybe we can establish a good scoring system for the future, but at the moment, no such system exists. If you have any questions or suggestions, please do not hesitate to speak up (Reply-To set). Do note, however, that my tendonitis forces me to take things slow. For this reason, I would like to apologise in advance should the evaluation of all your contributions extend into the new year. Thanks to Markus Wirtz of Open Source Press for supporting this idea, and to Steve Langasek and Frank Lichtenheld for their advice.

23 November 2005

Antti-Juhani Kaijanaho: The European Union has a bicameral parliament

I claimed yesterday that the council of minister looks very much like an upper house of a bicameral parliament. It is somewhat unusual in that the members are not chosen for a certain term but serve by virtue of holding an office in a member state, but it is not a decisive unusuality. Martin-Éric Racine countered: No, it is not. The council is bureaucracy overruling the Parliament, thus invalidating the very principle of democracy. We have seen this in action with the new EU Patents law: the Parliament had passed several amendments to the original proposal, yet the Council ended up ignoring those democraticly voted amendments and passing an even worse legislation than the original draft. This is clearly different than what happens between a higher and lower chambers each examining new legislation before it is ratified. Wouter Verhelst already said most of what I would have said myself; the bottom line is that Martin-Éric is mistaken about the powers of the council of ministers. Does he by any chance confuse the council of ministers and the commission? It would explain his calling the council a "bureaucracy", which it really is not. The power balance between houses in bicameral parliaments varies. My claim cannot be dismissed just because the two organs do not work exactly like the English parliament, for example. An important thing is that the lower house is almost always directly elected and the upper house comprises often representatives of areas or member states. Finally, I would like to note that the bicamerality of the EU parliament system is independent of my claim that the EU is a country; if a non-country can have a parliament, it certainly can have a bicameral parliament. So you don't have to rebut it just because you don't believe in my claim about the countriness of EU. Oh, BTW, Martin-Éric, please don't mess with your posting dates. It makes your postings to appear more recent in PD than they actually are and to float to the top, where they obscure legitimately new postings by others. For example, your response to my previous posting appears much later in PD than Wouter's reply to it.

Antti-Juhani Kaijanaho: Constitutions and countries

Some people think that only countries have constitutions. I find that strange, since both write at Planet Debian; surely, Debian is not a country! [Update: As hinted in the comments, I did not get MJR's posting. My bad. Let it be known here that he expresses roughly the same argument I presented above.] In fact, the European Union is a country. It has a bicameral parliament (the council of ministers is sufficiently upper-house-like to qualify as one IMHO), a currency it governs, a passport, and it is the highest authority inside its borders. It is an unusual country in that its meber states have broad powers, but it is a country nonetheless. It possesses all four of the defining properties of statehood according to the Montevideo convention: The state as a person of international law should possess the following qualifications: (a) a permanent population; (b) a defined territory; (c) government; and (d) capacity to enter into relations with the other states. The first three are uncontroversial, and though the fourth is weak, it is present. (Okay, that last paragraph is controversial, and I know the arguments are not airtight, but I do believe the case is valid.)

Antti-Juhani Kaijanaho: Strachey

I ran the other day into Volume 13, Issue 1-2 (2000) of Higher-Order and Symbolic Computation, which contains articles by and about Christopher Strachey. From him come terms like l-value, parametric polymorphism, first-class object. He is a classic in the theory of programming languages. The issue is freely available at Kluwer's site. I am unable to give a direct link.

20 November 2005

Matthew Palmer: The Fun Never Stops With Ruby

Well, there's nothing like posting a really rubbish program to your blog to find out the right way to do it. Firstly, Philipp Kern has come up with another, even shorter version than his version I posted in the update to my original Ruby post, this time blowing me away with the strangeness of explicit casts in Ruby. Apparently, casting an input stream to an array produces an array with one-line-per-element, as in this example:
 STDIN.to_a.sort_by rand .each l puts l 
As Philipp warns, however: "Ruby is full of fun and power; one must watch out that the scripts remain readable". For a fairly toy example, this solution is still fairly readable, however I can see hair growing on this thing if your program grows large. Next, Pierre-Charles David showed his qualifications for becoming a co-author of the next edition of the Pickaxe (AKA "Programming Ruby: The Pragmatic Programmers' Guide"), with his example and explanation. He's kindly given permission for me to reproduce his e-mail in it's entireity, since it's too good to chop up:
Here is the shortest and most readable version of your "randomize stdin" script I can think of:
  #!/usr/bin/env ruby
  print ARGF.readlines.sort_by   rand  
 
ARGF is a special variable representing either stdin or, in the case where file names are passed on the command line, the content of these files (think of Perl's <>). ARGF behaves like an IO object (although I think it is not one). In particular, it responds to the #readlines method which splits the receiver's content into lines and returns an array. In other words,
  lines = ARGF.readlines
 
is the idiomatic way of doing
  lines = []
  while line = gets() do
    lines << line
  end
 
in your example. The next part (sort_by) uses a new form of the sort method, which I think is not documented in the Pickaxe. It implements the Schwartzian transform technique. In essence, a random number is associated to each element of the array, which are then sorted based on this index. As a general style remark, note that although Ruby supports "while" and "for x in y" loops, they are rarely used, in favor of iterators and/or higher order methods. For example, to gather all the input lines in an array without using readlines, one might write
  lines = Array.new
  ARGF.each_line    l  lines << l  
 
or
  lines = ARGF.inject([])    lines, l  lines << l  
 
Hope it helps, and welcome to Ruby!
Pierre, your explanation definitely helped, and I hope it helps others too. The third person to help me out is Decklin Foster, through a post in his blog. What particularly caught me about his solution was the neat demonstration of another feature of Ruby which I think I will really learn to love: the ability to dynamically add methods to an existing class. "Aiee!" I hear all the purists scream -- and I can see the potential for severe misuse, too. But, since every good idea seems to get deeply perverted, we may as well have some real useful features to pervert while we're at it. Decklin has the clever idea of adding methods to the Array class that shuffle the elements of the array in a random fashion. His code is beautiful in it's simplicity:
 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
He then goes on to rewrite my bumbling example in probably the most comprehensible manner I've yet seen:
 STDIN.readlines.shuffle!.each    line  puts line  
Decklin writes, "Now that is cool.". I couldn't have put it better myself. My thanks to Philipp, Pierre-Charles, and Decklin, for helping me along the Ruby path. So, two new Ruby Rules for me to live by: Hmm, is it possible that Ruby is nothing more than Functional Programming by Stealth? Aiee!

Gunnar Wolf: ...So we did it!

Note: When reading this entry, please set your date to 2005-11-10. Delays in the system prevented me from posting this earlier.
I have lived together with Nadezhda for almost ten years - And this month (on November 1st, to be precise), it is ten years we first met on one of the few BBSes we had in Mexico by then - Thanks a lot, Mag, for setting it up - you changed my life in more ways I'd ever have thought!
Over the time, of course, our relation has changed a lot - the first step was telling to other people about each other's existence. The second was accepting we were not together only in between (long story... But I was about to leave the country for good. And I did. But then she followed. And we came back together). Then, little by little, we started settling down, we became a formal couple in the eyes of our families and friends.
We always thought social conventions were silly. We laughed about the prospect of marriage, of having to accept in front of others what we felt towards each other - But anyway, some months ago, we started talking it would be nice to make out of our nice, private relationship something serious and formal to commemorate our ten year anniversary.
Not much was told about it for some months... Until by mid-October we realized we would not make it in time if we didn't hurry - So we went to the Registro Civil at Coyoac n and asked for an appointment with the judge. November 1st is an official holiday, so it was not possible to make it right on the same date - We got the appointment for November 9.
Some people might be asking here why weren't they told about this - Well, first of all, as you can see, we didn't have much time to plan this. Second, we decided to take this formal step, but to have it privately. We went only with my father, my brother, Nadezhda's mother, sisters, our nephews and one long-time friend. We were summoned at 10:30AM, had to wait for the judge to marry some other couples until around 12:00PM, had some nice words from him for ~15 minutes, and went for a nice breakfast in a nearby restaurant with the whole gang.
Oh! Something interesting: We actually didn't know when we were formally getting married. We were called some 30 minutes before the official words to sign some papers, which the judge would later, and privately, certify as valid. The judge just talks, he does not sign anything with us present... But, well, it is a nice moment ;-)
And... Well, here is the proof. It took some days to receive the document, it took me some more days to finally post about it - But finally, our acquintances have been informed of our formal step towards a life together :)

15 November 2005

Joe Wreschnig: Sick, 0.15, and so on

Ick.
So I caught some sort of cold/flu thing, which inverted my sleep schedule (especially since it happened as daylight hours began ending around 5PM). In the process of rotating it back I got sick again, probably due to lack of sleep. Last night I didn’t sleep at all, so hopefully I can pass out around 10PM tonight without a problem. Quod Libet 0.15
Released (and uploaded to Debian), featuring all the aforementioned speedups (SVN actually has even more yet, and some significant memory reductions). We are polishing everything up (and working on the audio feed browser (feedparser is seriously hot)) for 1.0. It’s all very cool. Well, except the times GStreamer segfaults; that’s not so cool. Geeky Jokes
In a lecture on quantifier semantics, my NLP professor made the comment “In America, a b F(a, b). In my country, b a F(a, b).” Much of the class laughed. Speaking of NLP, my final project for that class is likely to segue into the next thing [info]gesten and I tackle, assuming I have any free time at all next semester. Books
I haven’t spent money on books in almost two months (aside from textbooks). This means the amount of books I own and haven’t read is actually for the first time in about a decade. Soon maybe I’ll even be able to go back and reread the books I read when I was 12 but don’t remember very well (ruining precious childhood memories in the process). Python Optimizations
Just because all my posts have had one of these lately, two recent things that surprised me: if s[:1] == c: is slightly faster than if s and s[0] == c:. And if v: is slightly faster than if v is not None: if v could be 0, “”, or (), the false immutables (this one surprised me less after some thought, but it’s still easy to forget when is is otherwise faster).

14 November 2005

Jeff Bailey: A letter to Stephen Harper

I am a Canadian citizen living in Montr al.
I'm sad and disappointed at the Conservatives party's politicking.  You
appear to be opposing tax cuts.  You appear to be opposing paying down
the national debt (Which was largely created by a conservative prime
minister).
You and your party keeps chanting that the Liberals have lost the "moral
authority" to govern while at the same time acting like children who
won't play along with others.  Nothing in your current behaviour would
inspire me to vote for you.  I would expect Her Majesty's Loyal
Opposition to conduct themselves in a better manner and I feel strongly
that if anyone has failed to govern effectively in this minority
parliament, it's you.
I urge you to stop trying to get an election called two months earlier
than it would come anyway, I urge you to move to a platform of fiscal
conservativeness which supports the sitting government in debt
repayments, and I urge you to begin working on keeping Qu bec in Canada.
I see these as the highest priority items for the House during the last
6 months of this government.
Acknowledgement of receipt is kindly requested.
Tks,
Jeff Bailey

12 November 2005

Antti-Juhani Kaijanaho: This sounds familiar

Cleaning my apartment is a bit like going on an archeological dig: A dried spaghetti noodle... when did I have spaghetti for dinner? Oh, yeah, three weeks ago.
(Tall Dark and Mysterious: See You in Ten Days)

9 November 2005

Junichi Uekawa: assembly output for x86_64.

I compiled a C program which just gives out 'hello world', and analyzed the gcc assembly output.I suppose subq/addq for rsp is for int parameter; or it couldbe an ABI requirement.It is surprising that pointer is movl'd to edi (32-bit) forthe puts parameter.To set eax=0 (for the return value), xorl (32-bit) is used.I wonder what happens to the higher 32-bits.Maybe it's time to seek for the CPU reference.

7 November 2005

Simon Law: Jeff Bailey Love Day


Jeff Waugh escaped
Originally uploaded by magicfab.
Two Sundays ago, Jim and I walked down to Ubuntu Love Day. The Ubuntu Below Zero conference is being held at the Holiday Inn in Chinatown. That's the one with the fake Chinese tiles on the roof, which is sort of tacky. We found our way downstairs to the conference room and sat down. The previous night's revelries still had quite the effect, so I'm afraid I drifted in and out while listening to people speak. I thought I had rid myself of this habit, but apparently university has trained me to consider digital projectors as sleeping aids. I'll have to do something about this one day. I got to see some fairly interesting people: Mattias Klaus, whom I met earlier at Jeff Bailey's place; Fabio Di Nitto, who is incredibly jolly; Chris Peterman, who was with his classmates from Clarkson; Colin Watson, whom I thanked for working so hard on Debian; Jeff Waugh, who dressed up as an inmate; and plenty of others. Oh, I managed to meet Andrew Mitchell in person, but we failed to have a proper CHUG meeting while we were all in town. We broke for lunch, which was held in the hotel restaurant. A buffet, with some Chinese-style dishes, was being served. There, we had to negotiate with the unilingual (Cantonese) staff to find out what Jeff could eat. We had a special order of plain white rice brought for him and we were informed that it was safe for him to eat the stir-fried vegetables. I suggested to Jeff that he ought to keep a phrasebook on him whenever he travels. On each page, one per language, there should be a written description of what he can and cannot eat. Then, he just has to show this to waiters who don't speak English or French.

Stocking the buffet
Originally uploaded by magicfab.
For reference, the characters that mean "vegetarian" in Chinese are and . Most of the time, they mean "vegan", but there are some places where eggs and oysters are considered vegetarian. After lunch, Mark Shuttleworth gave Jeff a very nice birthday speech. He also gave Jeff a nice bottle of wine, which was very nice. And Matthias came up to give Jeff a bottle of fish-oil pills, which was very odd. Then, there were two Birds Of a Feather sessions, involving how to make an Ubuntu package and how to be an Ubuntu advocate. Being upstream to both these issues, I sat in the middle of the room and listened to both presentations at once. This was quite interesting, and slightly taxing. After this was done, we broke up once more. The plan for the evening was to meet for dinner in the hotel lobby. This transformed to meeting outside the front door. Jim, [info]wlach, and I showed up and were greeted by this mass of people. Since there were stragglers and I knew where dinner was to be held, Jeff took a group of nineteen people in the metro. I followed about ten minutes later with a group of eighteen. We met up on St-Denis, and by this time we had lost some of the more impatient, and more hungry, people. Eventually, a group of twenty-three were milling about outside Le Nil Bleu. Angie had made arrangements for us to be served a set meal, and they had agreed to seat twenty-five of us. I went inside to let the staff know that we had arrived. When 20:30 came around, we were let into the restaurant and seated. I think the kitchen was still preparing food, because we had to wait about an hour before being served. Unlike my previous experience there with Jeff, the food was quite good this time and the service was very attentive. We enjoyed ourselves very much, and Jeff seemed to be having a very excellent birthday dinner. Some of the guests were not so happy, because the food was a little spicy for their European palates. Since gratuities are not standardised around the world, we discovered that some people had not tipped. To cover the embarassment, Angie and I made sure that the wait-staff were adequately compensated for their efforts. I'll be sure to go back to this restaurant again, but with a more significant crowd to ensure good service. After eating, a group of us including Matthias and Tollef went up to B l K , which was just a little north on Mont-Royal. That's a really interesting bar with beautiful tiled floors and ostrich heads on the walls. We enjoyed the lovely music, had a very good conversation there, and laughed until we were all exhausted. Since the Canonical people had to be awake for the 09:00 keynote speech the next day, they left early. Jim and I bid goodnight to them before we staggered home.

4 November 2005

Clint Adams: On nights like this

Once there was a little androgyne named Brendan. He was knee-high to a hamster, long-haired, and full of zest for life. Sometimes he rhymed slow, sometimes he rhymed quick, and sometimes, at least in his opinion, he resembled in some ways a Chick-O-Stick, and did not resemble DeLorean, Gambino, or Gotti. A waitress concurred to some degree. Here is your vermouth on the rocks, ma'am, she said. When Brendan insisted that he was not a ma'am , she was terribly apologetic, but her pleas could not quell the tumult of his bruised and beaten ego. I am virile! he declared, and through will alone he set his mind in motion. He furrowed his brow and concentrated deeply, and, ever so slowly, his facial hair grew. After many breaks for food and sleep, he decided that his masterpiece was complete. He beat his chest and left his home to show everyone his pride and joy, his Mustache. You've got something on your lip, mister, said a young boy. Great success! exclaimed Brendan, for he had been identified as a mister . He was on top of the world, basking in his newfound masculinity. Stay away from my children! screamed a woman who had instantly deduced that he was a member of NAMBLA. Realizing that many people believed him to be a pederast, he decided to make an adjustment. Soon, he had cultivated a Van Dyke, and showed his face in public again. Nice goatee, ma'am! a teenager shouted. It's not a goatee! he replied, and walked on. Reflecting that he had been called ma'am again, he undid his pigtails. What came next was a series of men hitting on him. This will not do, he thought, and converted his Van Dyke to a goatee. When this caused an entirely different set of men to hit on him instead, he swallowed his pride and went to the supermarket to ask for some advice. I am not a homosexual, he explained to Miss Midwest Midnight Checkout Queen. I am manly, and I like the poontang and the boobies. What can I do to stop this unwanted attention? Shave, she said, and refused to acknowledge his protests. So he shaved and went to the bakery. I've got a sweet tooth, he explained, for licorice drops and jelly roll. I'm sorry, ma'am, the baker informed him, but we only sell lard bread and bran muffins here. Brendan let out a high-pitched scream and stormed out to play in traffic. His eye was caught by a sign advertising fortune telling services, and desperation drove him to go ask for a consultation. You will die unhappy, said the Gypsy Queen. Brendan recounted his trials and tribulations and asked her for advice. The Gypsy Queen informed him that he would be subject to additional charges for such, and he assented. Very well, she sighed. People will never respect you if you care what they think. Just be yourself, and if anyone complains about the way you are, or demands that you change to suit them, tell them to fuck off. That's wonderful advice! Brendan gushed. He gave her an enormous tip, and hurried out into the world to try out his new lifestyle. That guy sucks, people said. She doesn't care about anybody but herself. So they shunned him. He died an unhappy little androgyne.

Next.

Previous.