Ruby-Tricks

Skype-Style Firewall Busting with Ruby and UDP

Skype and Google Talk are pretty clever in the way that they still work even if all of its users are behind firewalls (or NAT systems) that block incoming connections. The way they enable two-way connections is by using a 'firewall busting' technique. Simply, a central server does nothing but share IP addresses (and port numbers) and clients can then 'punch' holes through their firewalls and trick their firewalls and routers to route incoming packets back to them if they have certain source host and port numbers.

Read more →

Making The Existing Ruby Interpreter Faster

A lot of people seem to want to reinvent the wheel where Ruby is concerned, and I wish them all luck, but Tomasz Węgrzanowski has taken the unique step of trying to make the existing C-based Ruby interpreter faster instead, with intriguing results.. He even goes as far as to hack Ruby's source code to remove inefficiencies in how Fixnum objects are compared. I totally dig this and would love to support further efforts to implement non-damaging optimizations to the existing interpreter.

Read more →

WordPress Plugin for Ruby Syntax Highlighting

Syntaxhighlighter
SyntaxHighlighter is a WordPress plugin that provides code presentation and syntax highlighting features for your blog (if it's WordPress powered, naturally!). It supports a plethora of languages such as C, C++, C#, HTML, and PHP, as well as Ruby. On my blogs so far I've tended to use a homebrew approach with the Syntax gem, but this WordPress plugin should make it a whole lot easier in the future. If you're a WordPress powered blogger who likes to post code snippets, check it out.

Read more →

Retrieve Google PageRank From Ruby

Vsevolod Balashov has taken a PHP PageRank decoder and rewritten it in Ruby. It works and it's fast. Simply, it retrieves the PageRank value for a supplied URL from Google and decodes it back to the PageRank value between 0 and 10. Each page indexed by Google has one of these numbers, and have historically represented how well linked a Web site is and how well it will rank in Google. The usefulness of PageRank has dropped a lot in the past year or two, but it can still be a useful indicator of how significant a Web site is.

Read more →

Simple File Upload to Amazon S3 From Ruby

There's more about Amazon S3 and Marcel Molina's hot new library coming as the first day of the Ruby Advent Calendar (this Friday!), so I don't want to say too much about it yet. For anyone already enjoying this library, however, I put together a scrappy program that lets me copy files up to S3 from the command line easily:

Read more →

Recursive Descent Parser for Ruby

Sometimes strange things happen. I've been developing a small, basic recursive descent parser for Ruby called RDParse. Just before writing this post I decided to Google that name, and lo and behold the first result is a Ruby recursive descent parser called RDParse, created by Dennis Ranke, that I posted to Code Snippets for posterity several months ago. Since both of these libraries are unlikely to be used at once and that Dennis doesn't seem to be maintaining his version, I've decided to stick with RDParse as the name of mine for now.

Read more →

JRuby + SWT = Future Cross Platform Ruby Desktop App Development?

Rubyswt

(Disclaimer: I'm no Java wiz, so if I get anything wrong about Java or its libraries, post comments!)

The SWT (Standard Widget Toolkit) is a GUI widget toolkit for the Java platform. Unlike AWT and Swing, it uses the local operating system's own controls. This means you can develop Java apps that 'look native' on multiple platforms. The popular Eclipse IDE uses SWT to work and looks graphically native on multiple platforms (as does Azureus). SWT is also, reputedly, faster than the other alternatives. Sounds great for developers, right? Java developers.. sure.

Read more →