Search Results: "dom"

1 December 2005

MJ Ray: PR, GR, Law

On the first day of Christmas month, GPLv3 sent to me: three corporate counsels two FSF spokesmen, a research corporation director and a lawyer in a pear tree. No community projects support GPLv3? Were they excluded or did they refuse? If GPLv3 is a similar corporation-placater to the FDL, sacrificing freedom for sponsorship, I predict a riot. A bit of discussion about this problem here. The proposed resolution on publishing debian-private emails both contradicts itself and may have copyright problems. At best, reject. At least, amend. Also troubling, a claim from FSF France that new laws threaten free software developers or at least public distribution of source code. What madness is that?

Matthew Palmer: A trace mixin for Python

Although I am by means an expert Python programmer, I do dabble -- at the moment, I'm dabbling fairly heavily in a project for work. I had need, as you do on occasion, for a call trace (I called this method, it returned X, I then called this other method, it returned Y, and so on). Astoundingly, I got no answer when I asked on #python, as I would have expected this sort of thing to be a gimme -- even possibly including it as a core language feature. But nary an answer was forthcoming. Searches for mixins or magic function calls which might solve my problem were similarly fruitless. I resigned myself to manually sticking print wrappers around the function calls of interest, but that got old real fast (especially after I spent about a half-hour chasing my tail because I'd forgotten to return the return value after I printed it). As usual, my subconscious saved the day. On the train home this afternoon, I suddenly had a brainwave, and the code which I've reproduced below appeared almost fully-formed at my fingertips. It's times like this that I really enjoy programming. Now, of course, someone will pop up and say "oh here it is over here", or "you just set the __trace_me_baby__ attribute on your object", but I can console myself with the fact that I know a lot more about grubby Python internals than I did before. The code: (a pre-saved version is also available).
# tracemixin.py
#
# A python mixin to trace the calling of methods.
#
# Copyright (C) 2005 Matthew Palmer 
#
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
#   or see http://www.gnu.org/licenses/gpl.html
#   
"""
A mixin class to permit the tracing of method calls on an object.
This class, when mixed in, overrides the default operation of method calls
so that requests to call methods which have been listed in the
self._traced_methods list will be printed with their arguments and return
values.  Also included is a simple call depth indication, using indents.
Tracing of particular methods can be turned on and off on a per-object basis
by simply including or removing the method's name in the _traced_methods
list on the particular object.  Whole classes can be traced by setting
the list as a class attribute.
To include this class, simply make it the first class name in the list of
parent classes when defining a new class, like so:
class Something(TraceMixin, RealParentClass):
You could probably leave the TraceMixin in your production code, although
it'll slow execution down by a bit.
Complete usage example:
from tracemixin import TraceMixin
class RandomTask(TraceMixin):
	def x(self):
		print "X!"
	
	def y(self, arg):
		print "%s Y!" % arg
		self.x()
x = RandomTask()
x.x()
x._traced_methods = ['x', 'y']
x.y('why?')
Output:
X!
::y(why?)
why? Y!
  ::x()
X!
  =>None
=>None
"""
class TraceMixin(object):
	_traced_methods = []
	_depth = 0
	def __getattribute__(self, attr):
		if attr in object.__getattribute__(self, '_traced_methods'):
			self.method = attr
			attr = '_trace_proxy'
		return object.__getattribute__(self, attr)
	
	def _trace_proxy(self, *args):
		realmethod = object.__getattribute__(self, self.method)
		if realmethod and realmethod.__class__ == self._trace_proxy.__class__:
			print "%s::%s(%s)" % (self._depth*'  ', self.method, ', '.join(args))
			self._depth += 1
			rv = realmethod(*args)
			self._depth -= 1
			print "%s=>%s" % (self._depth*'  ', rv)
			return rv
		else:
			raise AttributeError

Dirk Eddelbuettel: Mail broken

Comcast, in their infinite wisdom, decided to RBL block (at least one of) Debian's mailhost(s), master.debian.org. As essentially all my mail is forwarded from Debian to Comcast, mail traffic was affected. At first, I noticed dropped posts from mailing list subscriptions relative to the list web archives. I posted the suggested noticed to the Comcast RBL admins, so far to no avail other than a to yield a more complete stop. The mail forwarding has been disabled for now, and I am dealing with this more manually. If you tried to contact me in the last few days and have not gotten a response, please resend your mail. I should now be in a position to receive it. Sorry for any inconveniences. Offers of better mail hosting would be gladly accepted, of course.

30 November 2005

Martin F. Krafft: OOP

But Steinar, it does... or what would you do if you had to limit the domain of a member variable so that e.g. it must not be set to an even number. If you have users of your class accessing public members everywhere, you are going to have a really hard time. Unless, of course, you use a proper language such as Python, which allows you to define implicit accessors for member variables.

29 November 2005

Gunnar Wolf: Pacman trouble

I have found visual evidence that the Pacman xscreensaver hack levels are produced by random and, contrary to what many people say, were not simply copied off the console. Atari's good soul must thank $ DEITY that this didn't happen to a human player!
Still, it was funny watching this game, mainly as Pacman's speed is roughly 10% faster than the ghosts', and he cannot just stand still.

Aigars Mahinovs: Fotography is dangrerouse


Fotography is dangrerouse
Originally uploaded by aigarius.
After a bit of sleep, a bit of rest and several hours of workign trough all the 293 photographs taken during the 3 days of AnimeFest, I must finally write something about the last day.
The last day of the fest (sunday) was easily the best. The morning was a bit disapointing as the planned special showing of Steamboy did not happen and the korean Hammerboy was quite boring for anyone over the age of 7. Many had a good nap.
Everything went wild when the second part of Hellsing series was supposed to start. Previouse day the showing stopped on 6th episode, so when after the intro we saw that the 10th episodes starts, all started shouting so loud that even mechanics understood that something was wrong. For about 5 minutes they seemed to wander aimlessly around the menu of the DVD. The mechanics were in a sealed room, so they couldn't hear us and we couldn't quite go to them either. I had a fun moment running up to the screen and showing with my hand which button should the mechanic press on the screen. I mimiced both pushing the button like it was a touchscreen and a also runned around trying to "drag" the cursor across the screen. It looked very fun to the audience. In the end it turned out that the DVD was doublesided and had to be turned around, but it took almost ten times of starting the 10th episode and around a half an hour of time. Thankfully the rest of days schedule could be pressed a bit to compensate.
Hellsing itself was just wonderfull, I hope they will decide to make a sequel soon and that they'll make it well.
Next up was Millenium Actress. I did not expect much realism from the creators of Prefect Blue, but I was so wrong. The movie is simply great - it is fun, has great story and ingeniose way to tell that story. Simply a marvel.
The final ceremony of the festival started with a concert of a local group of two Latvian girls singing Japaniese pop songs - "Tokio Dolls". Nice voices, very good choreography and reasonable lights - all in all a good show. In the conclusion there was Ghost in the Shell 2: Innocence. This is my second time trying to get it. I loved the first film. I liked the first season of series. But this film and the second season of series is just ... too smart? The first movie was a good combination of action, elegance, politics and wisdom. In the second part only distilled wisdom remains - typical scene is three people standing in a room for 20 minutes speaking loosely related citations of philosofers to each other. After a sleepless night of debugging gphoto, I slept well there.

All in all this festival was a fonderful event - lots of good friends came, lots of cosplays were seen, lots of anime was watched, a bit of go was played, a bit of buffed weapon fighting was done, a lot of good photos taken. I look forward to next animefest sometime next year. In the meanwhile I will try to sort out the few best pictures and post them to my flickr album during the week.

Aigars Mahinovs: Photography is dangerousAfter a bit of sleep,...


Photography is dangerous
After a bit of sleep, a bit of rest and several hours of working trough all the 293 photographs taken during the 3 days of AnimeFest, I must finally write something about the last day.
The last day of the fest (Sunday) was easily the best. The morning was a bit disapointing as the planned special showing of Steamboy did not happen and the Korean Hammerboy was quite boring for anyone over the age of 7. Many had a good nap.
Everything went wild when the second part of Hellsing series was supposed to start. Previous day the showing stopped on 6th episode, so when after the intro we saw that the 10th episodes starts, all started shouting so loud that even mechanics understood that something was wrong. For about 5 minutes they seemed to wander aimlessly around the menu of the DVD. The mechanics were in a sealed room, so they couldn't hear us and we couldn't quite go to them either. I had a fun moment running up to the screen and showing with my hand which button should the mechanic press on the screen. I mimicked both pushing the button like it was a touchscreen and a also ran around trying to "drag" the cursor across the screen. It looked very fun to the audience. In the end it turned out that the DVD was doublesided and had to be turned around, but it took almost ten times of starting the 10th episode and around a half an hour of time. Thankfully the rest of days schedule could be pressed a bit to compensate.
Hellsing itself was just wonderfull, I hope they will decide to make a sequel soon and that they'll make it well.
Next up was Millennium Actress. I did not expect much realism from the creators of Prefect Blue, but I was so wrong. The movie is simply great - it is fun, has great story and ingenious way to tell that story. Simply a marvel.
The final ceremony of the festival started with a concert of a local group of two Latvian girls singing Japanese pop songs - "Tokio Dolls". Nice voices, very good choreography and reasonable lights - all in all a good show. In the conclusion there was Ghost in the Shell 2: Innocence. This is my second time trying to get it. I loved the first film. I liked the first season of series. But this film and the second season of series is just ... too smart? The first movie was a good combination of action, elegance, politics and wisdom. In the second part only distilled wisdom remains - typical scene is three people standing in a room for 20 minutes speaking loosely related citations of philosophers to each other. After a sleepless night of debugging gphoto, I slept well there.

All in all this festival was a wonderful event - lots of good friends came, lots of cosplays were seen, lots of anime was watched, a bit of go was played, a bit of buffed weapon fighting was done, a lot of good photos taken. I look forward to next animefest sometime next year. In the meanwhile I will try to sort out the few best pictures and post them to my flickr album during the week.

Erich Schubert: SELinux up and running

My "test" boxes (well, they are in fact production systems) are now all up and running SELinux with a "strict" policy and in enforcing mode, after some weeks in "permissive" mode to detect the last missing policy rules (well, maybe I'm still missing something in cron.monthly?) What took most of the time was in fact to write policy for some services or custom applications that didn't have one before. And that I basically was just checking the logs every day to see if some new audit errors had appeared. Oh, and inbetween we completely emptied the server racks and their wiring and redid the room... Just to mention a few things that were "missing": My OpenVPN is running a custom script to update DNS on login and logout, which obviously was missing from the SELinux policy. I'm also using heartbeat to failover between the two firewalls and two mailservers; that policy took me probably one hour (without much previous experience) to write. Then I have another custom LDAP to aliases for a Lotus directory (which hopefully will be replaced by a sane application soon... whoever invented "implicite email adresses" should be shot. Just put all email adresses into the directory, so any app can look them up without trying to guess what your generation rules are... firstname.lastname@domain.tld sounds easy, but what with non-ascii characters?) Anyway, the systems are doing pretty well. Maybe I'm going to enabled SELinux on the web server next. ( (cra-)PHP and typo3 will probably make that more difficult, though...) Oh, and I need to sort out which of my policy changes are local changes, and which I should feed "upstream".

28 November 2005

Radu Spineanu: Shoot the movie industry

A couple of years ago i watched a really interesting movie. It was apparently about nothing, but in fact it was rather deep, and not a cliche. The story of two persons, stuck in an unfamiliar place who found each other and started spending time together in this pretty magic place. The action was placed in Tokyo, and the whole idea was based around it's beatiful scenery. The movie is called 'Lost in Translation'.
'.

I really enjoyed the movie, and most of all the two actors. One of them was Bill Murray, and the other one Scarlet Johansson. Scarlet Johansson, even though she was only 18 (i think) when she shot the movie, portreyed a young woman left alone in this unknown universe, who tries to find herself (sounds cheesy, but it's not).

And then came this day, when i had some free time and dediced to see 'The Island'. I have never wanted to kill myself more. Basically ObiWan finds out he's a clone, escapes from the military bunker while in the proccess taking his cloned girlfriend with him, and then frees all the other clones. Also in the movie you can find out that MSN will rule the world, Cisco the telephony, and Puma the shoes industry.

Now about Obiwan's girlfriend who is interpreted by miss Johansson. She is the regular stupid innocent blonde (too many adjectives?), who everyone wants to have sex with. Her role in the movie is probably to look good and have a sex scene with Obi. I mean what the hell ?

The movie thing is probably nothing new under the sun, and i accept the quality of today's movies. I think it was just sad to see somebody i really liked, and thought maybe i would enjoy nice movies with, become another random actor.

Bleah...

25 November 2005

Simon Law: Montr al geeks


Casa Magica
Originally uploaded by sfllaw.
There's this artists collective on St-Laurent, across from La Sala Rossa. They call their place Casa Magica, and it's really quite groovy. They've got this cozy living area with an open plan. The kitchen is separated from the living room with a tiled countertop someone built themselves. It's decorated in that way with splashes of paint, splashes of light, and furnishings that look like they grew there. I showed up at this place to meet some people in the Free Software world. I've been in Montr al for about a year and I still don't know very many hackers in the city. So when I got invited to Les 24h SQIL, I decided to show up and meet some people. I went up St-Laurent to a non-descript red door with a poster about SQIL on it. "This must be the place," I thought as I tried the door. Upstairs, I was greeted by a living room full of random people: some sitting in front of computers, some chatting away, and one guy fiddling with a projector. I wandered around in a state of confusion until I was introduced to Robin. Robin Millette seems to do a lot of work for FACIL, which is an organisation for promoting free content in Quebec. He introduced me to a bunch of people, like Simon Raven whom I helped with finger-ldap. I met Fran ois from Quebec City, who was interested in Nitix. There was Nicolas who is a Java developer that writes web-based applications. And other people like Alex, Yan, Marco and Matthieu who seemed nice but I can no longer remember what they do. I returned later in the week to Robin's birthday party where I happened to meet Fabien, who is a consultant that does work on Firefox and Yannick who's a Ph.D. student at McGill. We had a good time talking about quantum computing and how to design a programming language for quantum computers. Good geeky times were had.

24 November 2005

Antti-Juhani Kaijanaho: Cally s War by John Ringo and Julie Cochrane

There’s a reason why I’m going through Baen’s pile of published books. He is the only publisher I know who gets ebooks, I mean really gets them. (Virtually?) all of his catalogue is available in ebook form – with no Digital Restrictions Management! – for a reasonable price, and quite a few are available for free in the Baen Free Library. You can read these books on the browser, or download them to your PDA, whatever works for you. Naturally, you can always buy a dead-tree version, instead. I figure, this publisher is worth the money I pour at him, and hence I pour it in quantity. This is my explanation for having expended six euros for the following ebook. Cally’s War by John Ringo and Julie Cochrane is a sequel to a four-book trilogy by the first author. The trilogy is heavy-duty military science fiction, telling an excellent version of the “aliens invade Earth” story. Cally’s War is set forty years later, and features a minor supporting character from the trilogy as the main character. By the start of the book, Cally is an assassin working for a secret society which wages a secret war against the galactic domination of the Darhel species. The plot of the book revolves around the threat of the secret society being exposed to the opposition, and Cally’s mission in this book is basic counterintelligence: find out the mole and destroy it. However, it would be wrong to think that this book tells an espionage story, or that the counterintelligence plot is integral to the book: the plot is weak, mainly serving as a thin connector between episodes involving Cally’s personal life, or the lack of it, and her sex life (from whose lack she does not suffer). This book, however, seems to suffer from the lack of an editor. There are good ideas, and the storytelling is okay, but to make a really good book, the authors should have regarded this version as the first draft to be thrown away – and rewritten the book completely. There is really no unity in the story, and several good themes worthy of exploration are just skimmed. It is obvious that Ringo did not contribute much prose to this book: the bad politics rants are conspicuosly absent. I think I would have enjoyed the book more had Ringo actually written more of the book, even if it meant suffering through new pro-Bush rhetorics. I suppose this book could work standalone, that is, it does not depend on the reader having read the previous books. On the other hand, there is very little that speaks for reading this book at all, except that it continues the story started in the four-book trilogy. I appreciated the story as a continuation of Cally’s arc, and some of the sex scenes were fun to read, but otherwise it left me wanting. I rate this book 4/10.

Adam Rosi-Kessel: randomplay 0.49 released

I know I said I was swamped until December, but there’s always a few minutes to release a new version of a package, right? It’s kind of like dessert—there’s always room. I’ve released randomplay 0.49. The new version adds a keystroke to pause playing and a keystroke to display the available keystrokes, and the ability to configure UTF-8 display of tags on or off. I’ve also improved the documentation and filled in the sample rc file to give all available options. By the way, Clint Adams, I would be happy to add Audioscrobbler support. Unfortunately, there is not yet any Net::AudioScrobbler perl module. I contacted the guy who is working on it and he said it’s not yet fit for public consumption, but will let me know when it is.

23 November 2005

Antti-Juhani Kaijanaho: Safety is the beginning of wisdom, not its end

I wrote a couple of days ago about safety in programming languages. A certain comment reminded me that people (even programmers) misinterpret technical terms from the area of programming languages. It reminds me of that old joke about the C programmer who is very hurt when somebody claims that C is not a functional programming language - of course it is functional, our hero says, as it functions perfectly. It also reminds me of a quote Christopher Strachey has been said to have written in the 1960's:
It has long been my personal view that the separation of practical and theoretical work is artificial and injurious. Much of the practical work done in computing, both in software and in hardware design, is unsound and clumsy because the people who do it have not any clear understanding of the fundamental design principles of their work. Most of the abstract mathematical and theoretical work is sterile because it has no point of contact with real computing.
In programming languages jargon, safety is the property of a language that all well-formed programs have a well-defined semantics. That is, in a safe language, programs that the compiler does not reject, do not go beserk (corrupt the stack or heap or otherwise invoke nasal demons). A well-defined semantics might be a forcible halt of the program, which is often not the ideal way of dealing with problems (sometimes it is even harmful), but it is beyond the scope of safety to specify a programmer-friendly semantics for such occurrences. Safety is the minimum requirement, not by any means sufficient for all contingencies. There is a related slogan attributed to Robin Milner:
Well-typed programs do not go wrong.
(Wrong, in this case, is an abstraction denoting nasal demons, heap corruption and other such nasty things.)

Antti-Juhani Kaijanaho: Requiem et Kyrie

Requiem aeternam dona eis, Domine, et lux perpetua luceat eis
Te decet hymnus, Deus, in Sion, et tibi reddetur
votum in Jerusalem: exaudi orationem meam, ad
te omnis caro veniet.
No, I am not that religious, and certainly not Catholic, but I do find comfort in the classic renderings of the Requiem Mass, especially Verdi's Messa da Requiem. Kyrie eleison.
Christe eleison.
Kyrie eleison.
Eternal rest grant them... (+)

Antti-Juhani Kaijanaho: ID6

As I start to write this, it's the last minute of my country's 87th birthday (the Finnish Independence Day). It got me thinking about nation-states and independence and whatnot. And I came to a threefold conclusion: First, there is some value in independence. Getting rid of the status of a Grand Duchy in personal union with Russia was certainly a good step for Finland, in light of the rough road the Russians themselves have since travelled. For the same reason, the two wars Finland fought against the USSR were quite worthwhile. Similarly, if Finland were to be threatened by a neighbour again, armed defense would certainly be justifiable. Second, there is no intrinsic value in independence. If a humanly life (including freedom and local government) can be guaranteed even if there is no Finnish state in itself, I see no reason to hold on to the old-fashioned concept of a nation state. Third, I am in favour, as a long-term goal, of a world government. Of course, a single government becomes a single point of failure in case of a coup, for example, but if the global state is arranged properly, the danger of a successful coup is minimal. On the other hand, a world government is in far better position to institute necessary policies to combat the global problems of poverty, climate change and other such issues than the current system of competing and cooperating nation-states. In the current system, the big issues are easily put aside in name of local opportunism. Finland is by no means immune to that problem. The great crises of the 20th Century were its devastating wars. Fortunately, we have overcome them to a sufficient degree. The great crisis of the 21st Century is not terrorism - though it is a symptom. The great crisis is caused by the limits of growth, and we are already feeling quite concretely the nearness of those limits. If something is not done, our current civilization will crash spectacularly. The human race will probably survive - but do we really want to live through another Dark Age? Long Live the Earth!

22 November 2005

Andrew Pollock: [life/americania] My kingdom for a bayonet light bulb

So, they're obviously very proud of the fact that Thomas Edison invented the light bulb, as they're all Edison Screw over here. Nary a bayonet to be found anywhere. Difference illustrated here. On Sunday we went to Home Depot (the one we walked into at Milpitas could have been Bunnings at Fyshwick if it were green instead of orange), and when I asked someone about light bulbs with bayonet fittings, he made noises about auto shops and stuff, which suggests that they just don't do house lighting with them at all. Why do I want a bayonet light bulb so badly? I have a lamp that was made by my late grandfather, which is one of the few non-dual voltage items I didn't jettison (probably the only one actually), and I was rather keen to actually use it. I don't expect the bulb that was in it to survive the shipping process, and even if it did, if it didn't instantly blow up at 110V, I suspect it would be a bit dim. If anyone knows of any bayonet-to-edison adapters, please let me know. Update: Google is my friend

21 November 2005

Sam Hocevar: Finding a specific instance of a given day in the month in PHP

Andrew: to work out the fourth Thursday of the month, use this instead:
function nth_day($instance, $dow, $month, $year)

  $first_dom = date("w", mktime(0, 0, 0, $month, 1, $year));
  return 1 + ((7 + $dow - $first_dom) % 7) + 7 * ($instance - 1);
Or, using Zeller s rule and avoiding function calls:
function nth_day($instance, $dow, $month, $year)

  if($month < 3) $year--; $D = $year % 100; $C = (int)($year / 100); $m = 1 + (($month + 9) % 12);
  $f = 1 + (int)((13 * $m - 1) / 5) + $D + (int)($D / 4) + (int)($C / 4) - 2 * $C;
  $first_dom = $f % 7;
  return 1 + ((7 + $dow - $first_dom) % 7) + 7 * ($instance - 1);
Update: thanks to Andrew for spotting the error in the second version. Due to my misunderstanding of a hack in Zeller s rule, I had forgotten to decrease the year when the month was January or February. Also, PHP was not doing proper integer divisions and I had to cast results back to int despite all operands being ints.

Brett Parker: Hmm... It appears that I have a random quirk...

Maybe it's not just me, though... Does anyone else get upset with people that don't put DVDs/CDs back in there cases after use? The usual list of excuses being "I didn't know where the case was", or "Erm, yeah, I was going to do that". I don't mind them being left in players/drives, that's fine, you can generally find them, and they're not in danger of having coffee/tea spilt on them, or randomly getting lost... what really winds me up, though, is them being left on the corner of units, or put back in different boxes. OK - so having read that, definately I'm weird :)

Ian Murdock: Untangling the web

Dave Winer: “So we need some way to share subscriptions between different applications, between vendors — we need an way to do that that works when the lists are small, and one that works when the lists grow large. Most important, it needs to be open, and in order to be really open it has to be simple, so that no vendor can use their large size as a way of keeping smaller competitors out of the market. We’ve seen that when this happens innovation stops. Let’s learn from our past mistakes, and not make it so easy to dominate a market. Compatibility should never be a reason to choose one product over another. Let performance, features and price drive the market, not the obscurity of the wires connecting the apps together.”

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!

Next.

Previous.