From RedHanded, 1 year ago,
0 comments
class Symbol def hash; to_s.hash; end end
Someone explain why not.
From RedHanded, 1 year ago,
0 comments

From RedHanded, 1 year ago,
0 comments

From RedHanded, 1 year ago,
0 comments

From RedHanded, 1 year ago,
0 comments
From RedHanded, 1 year ago,
0 comments
From RedHanded, 1 year ago,
0 comments
So we’re all glued to the Cheese on Toast saga and we all have our opinions. This can get heated real quickly, but before anyone else says anything, I have to say: muenster cheese. Don’t be wreckless, just go to the deli and have them slice it at a 5.
Again, DO NOT TRY THIS HOME! Go to a skate park late at night when the bowl is empty. Or rent a small storage space or something.
Polly Appleholtz has e-mailed in to remind me that it’s not called “Cheese on Toast,” but rather just “Cheesetoast.” Oh, that’s right!
From RedHanded, 1 year ago,
0 comments
If you’re running JRuby from trunk, try this:
$ gem install hpricot --source http://code.whytheluckystiff.net Select which gem to install for your platform (java) 1. hpricot 0.5.110 (jruby) 2. hpricot 0.5.110 (mswin32) 3. hpricot 0.5.110 (ruby) > 1 Successfully installed hpricot-0.5.110-jruby Installing ri documentation for hpricot-0.5.110-jruby... Installing RDoc documentation for hpricot-0.5.110-jruby...
But how is this possible given that Hpricot’s parser is written in C?? Because Ragel can generate Java code! Ola goes into it.
From RedHanded, 1 year ago,
0 comments
With the help and goodwill of the RedCloth mailing list, it has been decided that RedCloth 4 will end up being the polished finished code for SuperRedCloth. There is still a little ways to go, but I think it could happen within February. If, that is, you help goof around with Super.
gem install superredcloth --source http://code.whytheluckystiff.net
And to use it, do:
require 'superredcloth'
p SuperRedCloth.new("h1. The Legend of Zu").to_html
All textile syntax should work. Options like :hard_breaks and :filter_html are still underway.
From RedHanded, 1 year ago,
0 comments
Bram Cohen: Clearly, digital computers test great. In application however, they have a ton of challenges.
A guy who’s into business trends versus a guy who’s into logic puzzles. Gee, I wonder who is better equipped for this!!
From RedHanded, 1 year ago,
0 comments
While bunking inside Ragel, I’m starting to see the handiness of its lookahead operator. The bird beak :>, which gives a high priority to the next token in the machine.
In SuperRedCloth, this rule here was a flimsy way of matching a bit of text in parens:
title = ( '(' [^)]+ ')' );
It turns out I was able to cut down the generated grammer by something like fifty K by using this instead:
title = ( '(' chars+ :> ')' ) ;
The beak is great for any rule that’s getting too greedy and concludes with an exact character. Be warned, it may increase the complexity of the machine depending on how ambiguous your other rules are.
If I could offer one other bit of advice: stay away from the question mark, if you can. It seems like anything which uses the empty token can be expensive.
From RedHanded, 1 year ago,
0 comments
Ach. Prih. Kott! With much, much, much.

Now with these little pulps and these more splatters. And, more recently:
Search text node with predicates like a[text()="Click Me!"] and h3[text()*="space"] and the like. Colons in tag searches are OK. XPath indices. (BEEP BEEP: they start with 1, not 0!!) Vexed? HpricotChallenge is for the stumped.The gem is undergoing a brief mirroring dungeon quest on Rubyforge, but can meanwhilst be slurped from the still:
gem install hpricot --source http://code.whytheluckystiff.net/
And, tarball too: hpricot-0.5.tgz.
I have a sneaking suspicion that a 0.5.1 will be needed. But I’m at peace with that!! Thankyou for letting this sticky stuff drip down your chin, fine people.
From RedHanded, 1 year ago,
0 comments
I’m sick of RedCloth being my most nauseating library!! All those treacherous regexps…
$ svn co http://code.whytheluckystiff.net/svn/redcloth/branches/superredcloth $ cd superredcloth $ rake
You’ll need the latest ragel installed. This will be ten times faster.
From RedHanded, 1 year ago,
0 comments
What’s up with this job posting which demands a Gemini, Leo, Libra, Sagittarius or Aquarius?
The most ambitious Ruby on Rails project calls for a Rail’s guru to lead team as Co-founderThis is a wonderful entrepreneurial position for the humanitarian keen on facilitating emotional fulfilment for humanity.
*Birthday must fall between;
January 20 and February 18
May 21 and June 20
July 23 and August 22
Sept. 23 and Oct. 22
November 23 and December 21
Is this a phenomenon common to Germany? I’m sorry, the stars just aren’t aligned for you to code for us today. (Seen on onslaught.)
From RedHanded, 1 year ago,
0 comments
I had previously been using rb_iterate and a call to Proc.new to build a block in C. But that takes two function calls while the undocumented rb_proc_new is just one.
require 'rubygems'
require 'inline'
module Kernel
inline do |ext|
ext.prefix %{
static VALUE sum(VALUE args)
{
return rb_funcall(rb_ary_entry(args, 0), rb_intern("+"), 1,
rb_ary_entry(args, 1));
return Qnil;
}
}
ext.c %{
VALUE sum_block()
{
return rb_proc_new(sum, 0);
}
}
end
end
p sum_block[13, 2]
p (0..20).inject(0, &sum_block)
Most of the time rb_iterate is what you need. But, you know, in case you actually want a Proc object.