Search Results: "Decklin Foster"

29 December 2005

Decklin Foster: Seriously

(01:20:56) ***Decklin blinks
(01:21:03) Decklin: Depends: libqt4-sql
(01:21:14) Decklin: libqt4-*sql*??!?!?!!!!!?!??!!!
(01:21:28) Decklin: somebody needs to put down the crack
(01:26:32) Aslynn: ?
(01:29:33) Decklin: a gui toolkit library
(01:29:41) Decklin: depends on an SQL database.
(01:29:45) Decklin: that's completely insane.
(01:30:08) Aslynn: uh...huh...
(01:30:20) Decklin: it's sort of like... a car requiring a hard drive.
(01:31:01) Aslynn: ah.
(01:31:05) ***Decklin downloads 20mb of source packages to recompile overnight
(01:31:15) Aslynn: wanna play literati? :)
(01:31:49) Decklin: i'm already installing one overbloated and hideous software support system, i have no time for java
(01:31:58) Aslynn: Psh. JAVA HAS NO TIME FOR YOU.
(In Soviet Russia, Qt builds you!) No offense meant to pyro; I m sure someone has a very good reason for needing this. (Please don't tell me what it is. Ignorance is bliss.)

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: Useful tip

If you are stuck on a Windows machine using PuTTY, and have saved you@foo.example.com in the interactive dialog as foo , you only need to type foo:target in the DOS box when running PSCP. I discovered this entirely by accident.

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.

9 December 2005

Decklin Foster: Permalinks Fixed

I had a very silly typo in my Atom 1.0 flavor (flavour?). Permalinks should work again. If this causes everything to rehash and thus flood the planet, sorry. Once PyBlosxom 1.3 is out, Atom will be native and I won t have to worry about not catching thinkos like this for months...

Jesus Climent: Timeline

08:02am: Decklin Foster mentions dropping FreeDB in favour of MusicBrainz, and abcde in favour of jack. 09:48am: I wonder if adding MusicBrainz support on abcde would be a bad idea. 05:20pm: Decklin Foster points me to a python script which provides the needed interface. 2 years later: I add MusicBrainz to abcde. No. Just joking. I will work on it during the next few days. Or in debconf-es2. Cheers!

8 December 2005

Decklin Foster: Really Bad Joke

I think #342502 would have read better in poem format:
this is just to say

i have recompiled
the bonnie++
which was linked
against libstdc++5

and which
you were probably
saving
until etch freezes

forgive me
g++-3.4 has a new ABI
so portable
and so fast
Somebody shoot me for doing that, please.

Jesus Climent: MusicBrainz

Decklin Foster: Why not writing an abstraction of a MusicBrainz plugin for jack and we can use it also in abcde?

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.