Faster RubyGems (GEMS 早くになりました)

Posted by – February 20, 2008

Last night at Nerd Club, Eric and I hacked a patch of mine in to RubyGems. We made gems use net/http rather than open-uri for downloading gem information. I configured net/http to use a persistent connection, and now those little dots should move a lot faster in the next release of RubyGems. Eric was also able to pull open-uri out of gems. Yay!

I hope that gets released soon. Those slow dots irritate me so much!

king of teh intarwebs

Posted by – February 18, 2008

I made a new website for icanhasaudio. You can has website view here.

Feel free to get your encoding/decoding on.

betabrite version 1.0.1 has been released!

Posted by – February 15, 2008

Provides a Ruby interface to BetaBrite LED signs.

Changes:

### 1.0.1

* 2 Minor Enhancements:

* Works with ruby 1.9
* Added more string codes

* 1 bugfix:

* Fixing bug in memory allocation

*
*
*

icanhasaudio version 0.1.0 has been released!

Posted by – February 15, 2008

Hai! icanhasaudio? is an interface to lame for decoding ur MP3s. I iz in ur
computer. Decodin ur mp3s. Whatevs! I also decodin ur OGGz! I kin also
encodin’ ur WAV and AIFF to mp3z!

## SYNOPSYS ROFLOL

  require 'icanhasaudio'

  reader = Audio::MPEG::Decoder.new
  File.open(ARGV[0], 'rb') { |input_lol|
    File.open(ARGV[1], 'wb') { |output_lol|
      reader.decode(input_lol, output_lol)
    }
  }

Changes:

### 0.1.0

* 1 major enhancement
* Added MPEG Encoder

*

I’m going to Japan.

Posted by – February 15, 2008

Last week I bought my plane tickets to Japan! I’m leaving June 18th, and returning July 5th. I’ll be there in time for the Japanese Ruby Conference. I submitted a talk proposal on RKelly, and hopefully that will get accepted. I know I’m going to be staying in Tokyo for a while, but I’m not sure where else I’ll travel. I’d like to go to Kyoto because it looks very interesting. I’m most excited about getting to visit Daisuke, and speaking Japanese. I’m trying hard to hone my language skillz before I go so that I can communicate!

One thing I’ve noticed about the Japanese language that differs from English and kind of annoys me is the timing of words in sentences. In English when I quote someone, the listener knows much sooner that it is a quote than in Japanese. For example:

Pam said “blah blah”.

In Japanese:

Pam は blah blah と言っていました。

You don’t know until the end of the sentence that “blah blah” is what Pam said. If you died or something before the end of that sentence, the listener wouldn’t know it was a quote! There might be ways to get around that, but I don’t know them yet……

Autotest and BetaBrite

Posted by – February 11, 2008

I’ve finally added USB betabrite support to my Betabrite library, and released version 1.0.0.

Version 1.0.0 also includes an autotest module so that you can see your autotest output on the sign. Here is what mine looks like:

Betabrite Autotest

The sign shows errors too, but it scrolls, so I couldn’t get it in one picture. Anyway, if you’ve got the USB sign, all you have to do to get it working with autotest is add this to your .autotest file:

require 'betabrite/autotest'
require 'usb'

Autotest::BetaBrite.hook(BetaBrite::USB)

The hook method takes a block, and you can modify your messages before they are sent to the sign. For example, I wanted my failures to be blue, so my .autotest file looks like this:

require 'betabrite/autotest'
require 'usb'

Autotest::BetaBrite.hook(BetaBrite::USB) do |failures, erorrs|
  failures.rgb('0000FF') if failures.green?
end

betabrite version 1.0.0 has been released!

Posted by – February 11, 2008

Provides a Ruby interface to BetaBrite LED signs.

Changes:

### 1.0.0

* 3 Major Enhancements:

* Adding support for USB betabrite signs (Thanks Thought Hammer)
* Added an autotest hook
* Changed API to use more DSL type interface

*
*
*

Pointcut Your Javascript

Posted by – January 24, 2008

Sorry for all of the RKelly updates, but thats what I’ve been doing in my free time. I mean, besides J-School. But I don’t think anyone wants to read my poor Japanese!

I wanted to make my ASTs easily searchable, so I added an AOP style interface to my AST. The AST will now let you pointcut your javascript and give you back a list of all of the points it finds. Take this javascript for example:

try {
  Element.update('another_id',"blah blah blah");
  Element.update(10,"blah blah blah");
} catch (e) { }

Lets say you wanted to find every place that Element.update() was called with 2 arguments, and mess with those arguments. You can pointcut the ast, then modify the arguments by giving the AST a pattern to match on like so:

parser = RKelly::Parser.new
ast = parser.parse(DATA.read)
ast.pointcut("Element.update(Object, Object)").matches.each do |m|
  m.arguments.value.each { |x|
    x.value = rand(20)
  }
end

puts ast.to_ecma

But lets say you only want to update the call that was made with a number as the first parameter. No problem! Just change your pattern to use a number, like so:

parser = RKelly::Parser.new
ast = parser.parse(DATA.read)
ast.pointcut("Element.update(Number, Object)").matches.each do |m|
  m.arguments.value.each { |x|
    x.value = rand(20)
  }
end

puts ast.to_ecma

You can even get more specific and match the arguments exactly. For example, matching just the function call where the first argument is ‘another_id’:

parser = RKelly::Parser.new
ast = parser.parse(DATA.read)
ast.pointcut("Element.update('another_id', Object)").matches.each do |m|
  m.arguments.value.each { |x|
    x.value = rand(20)
  }
end

Maybe you don’t care the update is being called on an Element, but you want to match all places that update is being called on something. The pointcut will match on node type too, so this is a perfectly valid pattern:

parser = RKelly::Parser.new
ast = parser.parse(DATA.read)
ast.pointcut("ResolveNode.update('another_id', Object)").matches.each do |m|
  m.arguments.value.each { |x|
    x.value = rand(20)
  }
end

Hopefully you get the picture. This feature isn’t full tested yet, but I think I might do my first RKelly release after I finish testing.

Clean it up! RKelly::Nodes::Node#to_ecma

Posted by – January 23, 2008

Last night at Nerd Club, I decided to add a “to_ecma” method to RKelly. This means you can turn your ECMA AST back in to ECMAScript, with the added bonus of properly indenting your code. For example:

require 'rkelly'

parser = RKelly::Parser.new
puts parser.parse(DATA.read).to_ecma

__END__
function yo(a,b,a) { this.be.some(); if(nasty) { code();} }

will output this:

function yo(a, b, a){
  this.be.some();
  if(nasty) {
    code();
  }
}

Now you should be able to modify your AST and generate javascript. Next I want to add finders to easily find nodes in the tree.

パンツないな興奮 – Javascript stuff

Posted by – January 19, 2008

While writing RKelly (a pure ruby javascript interpreter), I’ve run across weird cases in the ECMA spec that I didn’t know about before. For example, when coercing an object into a number, first the “valueOf” property is checked. That seemed to make sense to me. But then the spec says that if there is no “valueOf” property, to check the “toString” property and try to coerce that in to a number.

So, this bit of code:

var x = new Object;
x.valueOf = function() { return 11; };
x++;

is equivalent to this bit of code:

var x = new Object;
x.stringValue = function() { return "11"; }
x++;

That is some underpants-free excitement.