RSS RedHanded

http://redhanded.hobix.com

Tuesday February 27th, 2007

5.4

Tell Me the Hashing Dangers

RedHanded From RedHanded, 1 year ago, 0 comments Comment

 class Symbol
 def hash; to_s.hash; end
 end

Someone explain why not.

Thursday February 22nd, 2007

4.6

Okay, Which Browser Will Run This Code and Can You Get It Going?

RedHanded From RedHanded, 1 year ago, 0 comments Comment

Monday February 19th, 2007

6.0

Stream Copy YouTube, Revver, Etc.

RedHanded From RedHanded, 1 year ago, 0 comments Comment

Saturday February 17th, 2007

5.0

Random Number in a Feed (for Pipes Maybe?)

RedHanded From RedHanded, 1 year ago, 0 comments Comment

Thursday February 15th, 2007

2.2

Smoke Of The Soundtrack Page

RedHanded From RedHanded, 1 year ago, 0 comments Comment

Wednesday February 14th, 2007

sshh-hmm-mop!

RedHanded From RedHanded, 1 year ago, 0 comments Comment

Friday February 9th, 2007

The Cheese on Toast Groundswell

RedHanded From RedHanded, 1 year ago, 0 comments Comment

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!

Tuesday February 6th, 2007

Ola's Clever Hpricot Hack

RedHanded From RedHanded, 1 year ago, 0 comments Comment

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.

Sunday February 4th, 2007

SuperRedCloth 1.160 Gems

RedHanded From RedHanded, 1 year ago, 0 comments Comment

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.

Thursday February 1st, 2007

Clearly!

RedHanded From RedHanded, 1 year ago, 0 comments Comment

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!!

When Rageling, Bring a Bird Beak

RedHanded From RedHanded, 1 year ago, 0 comments Comment

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.

And Now, Hpricot 0.5 is Yours

RedHanded From RedHanded, 1 year ago, 0 comments Comment

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.

Monday January 22nd, 2007

SuperRedCloth

RedHanded From RedHanded, 1 year ago, 0 comments Comment

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.

Friday January 19th, 2007

I've Read Your Horoscope and You're No Hacker

RedHanded From RedHanded, 1 year ago, 0 comments Comment

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-founder

This 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.)

Wrapping a C Function as a Block

RedHanded From RedHanded, 1 year ago, 0 comments Comment

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.

« older items