Archive for the 'ruby' Category

Did You Miss Me? I’ve Been Camping

Sunday, April 1st, 2007

Not literally mind you, it was rather an excursion into the Salvador Dali-esque microframework of everyone’s favorite purveyor of chunky bacon and freelance professorship, why the lucky stiff.

Hence, I present to the world ScratchyPad, 390ish lines of tasty Ruby scratching my personal itch for a Pastie-style pastebin. (I’m sure there’s creams for that kind of thing, but I found camping far more pleasant, and hygenic too.)

ScratchyPad supports tags, syntax highlighting and textile markup, as well as RSS feeds.

Sorry, no screenshots yet, stay tuned for a later post with those.

Required gems are camping (duh!), coderay (syntax highlighting), redcloth (textile markup), mime-types. It also uses the date_helper from action view, so rails might help there.

Get the tarball here.

Edit: Caveat Downloader… I just flipped over to Safari, and the CSS is a bit sad in a few places :-( Needs more cross-browser QA…

Ruby Cheap Tricks – Monkeypatching unit conversion

Thursday, February 22nd, 2007

A little something I cooked up, inspired by Rails’ ActiveSupport Numeric::Bytes and friends.
(more…)

Ruby Cheap Tricks – Stats

Thursday, February 22nd, 2007

For when it’s just as quick to roll your own …
(more…)

Getting off my lazy butt and doing something…

Wednesday, November 15th, 2006

Err, yeah. I remember, once upon a time, I used to have time to blog. That was before we built this:
New House

Oh, and before he was born:

Warren and Liam

So despite the fact that I’m lying on the couch there, I’ve been far from idle.

My yard still looks like this:

New House - yard

so it’s not as though i don’t have enough to do! However, I *am* committing to finishing up, in the very near future, the Ruby Web Spider I began to write about some 5-6 months ago.

Consider this, a dusting off of the cobwebs kinda post…

How to calculate standard deviation

Monday, March 13th, 2006

When I started this blog last month, I thought “Standard Deviation” was a snappy title. Of course, I also knew about standard deviation as a statistical tool, however I didn’t expect that this overlap would cause Google search to drive 50+ visitors a month here looking for implementations of the standard deviation formula.

So as a “public service”, here is some code to figure standard deviation in Ruby and Java.

(disclaimer: no warranties as to correctness, particularly to the nth decimal place, don’t use this to run your home made nuclear reactor or air traffic control system, blah blah, etc, etc :-) )

(more…)

Ruby web spider Part 1: The scheduler

Wednesday, March 8th, 2006

This is the second part of a series of posts covering the development of my web spider in Ruby. You can read about the initial idea here, and the architecture in Part 0: Concept.

You may also recognise some of the code in Scheduler#run from a short post I made to check that the syntax highlighting was working :-)

First I want to recap the goal of the scheduler before getting into the code itself. Simply put, the scheduler exists to mangage the list of URIs (web pages, RSS feeds) that need to be spidered, and to manage the spiders themselves. In particular, we want to be able to limit the number of spiders working at any one time, out of politeness if nothing else.

I’m not going to make this a tutorial in Ruby syntax by explaining things line by line, if you haven’t used Ruby before and find something you don’t understand, the PragProg book, Programming in Ruby is the place to go look.

So let’s take a peek at some code!

(more…)

Ruby web spider Part 0: concept

Friday, March 3rd, 2006

(I should probably mention that I have never written a spider or worked on a search engine before, so this is a learning process… I don’t pretend to be an expert on this – I picked this partly because it is far enough from my “day” job that I’m not going to inadvertently end up in a conflict of interest. The closest I’ve come in the past was working on a natural language interface to search engine queries, way back in 2001 while I was in my final year at UTas.)

So how did I start?

(more…)

The expressiveness of ruby…

Tuesday, February 28th, 2006

The web spider writeup continues. I am no longer best friends with red wine after the weekend however.

Speaking of things that are red, I *love* the expressiveness of Ruby. The following is the run method of my Scheduler class, Ruby makes it a piece of cake to understand what is going on here, even without the full context, I think the following is fairly intuitive…

(more…)

Ruby web spider – watch this space

Friday, February 24th, 2006

I mentioned before that I’ve been busy this last week, one of the things I’ve been working on in my own time is a web spider (written in Ruby) that can trawl both HTML pages and RSS feeds. I won’t say much about what I’m using it for, other than to say I’m testing some ideas out right now :-)

Anyway, I’m almost at a point where I’m happy to share this code (probably under GPL) as it’s not exactly rocket science (and I’ve only invested a week or so of evenings into it), but it has a couple of neat tricks that made it a good exercise in Ruby. A short laundry list of features:

(more…)

“So I can extract all your knowledge…”

Friday, February 10th, 2006

I was just jokingly informed by my ten year old stepson that he intends to build “some kind of mind reading device, so I can extract all your knowledge about computers and rule the world!”

Hmmm, evil genius in training. After discussing whether we should inform his mother of his plans for world domination, he informed me that the reason *I* did not rule the world was because I don’t have a “master plan for world domination.” apparently, HE does. :-o

(more…)