This is not a blog

March 19, 2007

ruby modules

Filed under: Ruby — aberant @ 12:24 pm

So found this out the hard way trying to use modules to overload instance methods in classes.

So if you have something like the code listed below, the module will never execute the test method.


module Mixin
def test
puts "i am in the module"
end
end


class Example
include Mixin
def test
puts "i am in the class"
end
end

This is because when you mix in a module, it’s listed as an ancestor. So when ruby looks for the object to answer the message, it first looks in the class, finds the method, and says job done. It never reaches the module.
For example:

>> Example.ancestors
=> [Example, Mixin, Object, Kernel]

This means that to do things like using a module to overload how an object is converted to yaml you have to crack open the meta-class and do your work there.

November 13, 2006

all your database are belong to rails

Filed under: Ruby, RubyOnRails — aberant @ 12:39 pm

just read about DrySQL and thought it was the best thing ever.  It now makes ActiveRecord smart enough to ask the database for associations instead of you.

November 7, 2006

ruby heart ADSI

Filed under: Active Directory, Ruby, Windows — aberant @ 12:11 pm

so i was trying to find an example of how to use win32ole in ruby that does’t involve excel and stumbled across this interesting post about ADSI. so now armed with this and the reference at MSDN, i now have the shoulder mounted missile launcher i need to crack active directory.

require 'win32ole'
domain = WIN32OLE.connect("WinNT://my_domain.com")
user = domain.Create("user", "my_username")
user.FullName = "Foo Bar"
user.Description = "just a lil ol' test of how ruby <3 ADSI"
user.SetPassword = "my_password"
user.SetInfo

now that i’ve been freed of point-n-click-administration hell, i wonder what i’m going to do with all that free time.

August 16, 2006

has it been this long?

Filed under: Firewalls, Gentoo, Ruby — aberant @ 9:45 am

i’ve just been really busy lately with between work and school, but fortunately i’ll be graduating by next summer.

I’ve also been working on a project at work where i’m creating a rails front end to control a gentoo box running firehol so we can rent this out to clients as a cheep firewall.  I’m also working on having it pull down configurations from a central server, so it’s much easier to manage then having to ssh into every box.

I’ve also been working on this MUD DSL using ruby.  Mostly because the guy i work with is really into MUD’s and i thought this would be a good way to practice some tricky meta programming with ruby.

May 12, 2006

link day

Filed under: Ruby, javascript — aberant @ 7:51 am

A terrific breakdown of what this library is capable of

Using prototype.js v1.4.0 – Sergio Pereira

A fast, event driven, easy to use network library in ruby. i now have no excuse not to make that mud…

Ruby/EventMachine

And of course the teaser site for the awesome scrapbooking site that matt and i are creating

scrapease.com

April 13, 2006

Core Wars

Filed under: Algorithms, Ruby — aberant @ 3:38 pm

i just found out about this today, and i’m absolutely fascinated by it. i’m especially amazed by this article that i read some of the AI experiements using it. i’ve been mentally working on a mars simulator in ruby, so i’ll keep you posted if i come up with anything interesting. Mutations, parasites, programming.. what could be more fun?

March 23, 2006

Mogilefs for Ruby

Filed under: Ruby — aberant @ 6:52 pm

was rummaging around on the internet and found this out about Mogilefs for Ruby. seems like it’s perfect for a redundant storage system for ruby projects…

Blog at WordPress.com.