omg blog!! lol!!

musings and other whatzits from jeremy mcanally 

the ruby hoedown 2009 (you know, the free one) is coming!

Well, thanks partially to the money donated due to my previous blog entry and partially from the incessant e-mails of Hoedown fans (you guys rock, by the way), I've been making a big push to make it happen again this year.  Fortunately, it's paid off!

The Ruby Hoedown 2009 is happening in Nashville, TN at The Gaylord OpryLand Hotel on August 28-29, 2009.  And you can get in for the rock bottom, awesomely cheap, low, low, low price of exactly $0.  If you can't contain yourself, then go ahead and mosey over to http://rubyhoedown.com and click the big, fat register button (and starting Tuesday or Wednesday, you can reserve your room at the OpryLand for only $109!).

Of course, we're looking for people to come speak at the conference.  We're looking for any sort of presentation related to Ruby, so if you've got some sort of ultra cool ninja robot chef project that runs on Ruby or even a cool open source project you hack on, then propose a talk!  We'd love to have you tell us about it.

We're also actively looking for more sponsors.  We already have quite a few lined up, but we're looking for more to join the party!  If you're interested then check out the prospectus and drop me a line.

I'm looking forward to this year's conference, and hopefully we'll see you there!  If you have any questions, feel free to drop a line to us.

Comments [0]

training by the greatest ever team of ruby ninja pirate ringmaster factotum samurai accountant programmers ever known to man or woman

Hello all.  I can't believe I haven't blogged about this yet, but David Black (author of some of the best Ruby books out there), Rick Olson (Rails core.  The technoweenie.  Need I say more?), and myself are conducting some Ruby training in Atlanta on April 1-3, 2009.  We'll be throwing down some Ruby knowledge at the Georgia Tech Conference Center at, obviously, Georgia Tech.

This isn't your normal training, though.  It won't be David or I droning for hours about metawhatzits and eigenthisenthatzens.  Oh, no, my friends, it will be much better.  Imagine pairing with Rick "The Ween" Olson, someone who you could swear, if you look at him at the right angle, might actually be a walking mass of Ruby code.  Because that's what you'll be able to do.  We're going to have plenty of time to pair with us, with one another, and the hotel staff (though they may not be much help with Ruby, they can make sure you get the hook up on towels).

So, if that all sounds fine and dandy to you, slide on over to the information page, or, hey, if you're feeling hasty, why not go ahead and register?

(Psst!  If you use the discount code OMGTRAININGLOL you can get $50 off!)

Comments [0]

help make a free ruby conference a reality

If you attended the Ruby Hoedown last year, then you're aware of my plans for this year, but in case you super lame and skipped it, here's the low down: Nashville, TN.  August 7-8.  And the cost?  $0.  I wanted to run the Hoedown as a community event, and now that there are plenty of high quality conferences out there, I wanted to kick up the community aspect a couple of notches.  Now, if I'd made some cuts from last year (namely a few BIG items that sucked up the great majority of the budget), then I could do what I wanted.  Unfortunately, it looks like my bigger sponsors are unable to support the conference again this year, so it's looking more and more grim for the Hoedown.

But, I still really want to make this happen.  So I'm turning to you.  I'm asking the community (and businesses in the community!) to sponsor this one.  I need a minimum if $15,000 to make this happen.  I really need more if it's going to be done well, but $15,000 will pay the basic costs for a venue, sound, and basic promotional materials.  What's the money going to?  Well, since it will be free, I'm anticipating a large spike in attendance, and once you get above something like 50-75 people, venues start costing a lot.  I've picked out a nice venue in the middle of downtown Nashville that will hold 350 people classroom style, and something like 500 conference style.  I'd like to stick to the downtown area because there's a lot to do (one thing that's sort of plagued the Hoedown for the past 2 years).  Unfortunately, it costs $5,000 a day.  I'm actively looking for alternatives, but many places are actually far more expensive than that and those that are cheaper are not desirable.    

If you're a business and want to chip in some money, e-mail me at jeremymcanally [at] gmail [dot] com and I'll figure out some way to get your name out at the conference on a banner or the bag or lanyards or something (heck if you chip in enough, I'll even add your name to the conference and/or name my first born after you).  If you're an individual, I'll be listing your name in the program, but if you have a message you'd like to put with it, then get it to me somehow.  I'll add it in.  And since I'm opening the funding up, I'm going to open the organization up the community a lot more this year.  I'm taking a note from the GoGaRuCo playbook and setting up talk selections on something like UserVoice.  I'll keep the books wide open on the website.  

If I don't reach my mark, fair enough.  I can't afford to put that much money into it (especially considering I'm still about $3,000 in the hole from last year), so it won't happen this year.  I'll donate whatever money's been put in to Ruby Central to fund other conferences, and enjoy watching those conferences be awesome.  But I really think we can do this.   Here's the Pledgie link:

Ping me on Twitter or e-mail if you have any ideas or comments.  

Comments [8]

router plugin released, hacking, and magic

Today I (finally) released my Rails router implementation as a plugin named krauter (all apologies to any German citizen who may be offended!  I didn't mean to be a racis– er...nationalist?).   Take a look at the code over at my Github account: http://github.com/jeremymcanally/krauter

I'm also hacking on a few other projects you should be looking for soon if you're interested...

  • spartan — My new super simple, super clean blog software in Rails.  Think Mephisto-lite.  I have a repo up on Github already but there's nothing there quite yet (I'm getting close!).
  • urconf — I'm oh so slowly hacking on a conference planning/ticketing app.  The current ones "work" but they don't really fit with my model of conf planning/ticketing (and I don't think I'm alone)
  • microapps — The entp guys have started this whole "app a month" thing so I figure I might as well jump on the bandwagon.  My first app will probably be something related to Twitter...or maybe maps...or maybe something WEB 3.0.

My Scotland on Rails fund drive is...er...coming along.  Thanks a lot to those who've donated so far, but it's not looking good for my being able to hit my goal. :(

Click here to lend your support to: Send Mr. McAnally to Scotland on Rails!

That's OK, though.  Perhaps I'll be able to go next year if I don't make it out this year!

Also, I pushed out a new release of context and a new piece of my testing stack named pending which implements RSpec's pending behavior in Test::Unit (and as a result in context/matchy/etc.).

Oh, and the next issue of the Rubyist is coming real soon now.  I'll be launching a CFP in just a few minutes (check out the site for more info), pushing Issue 1's content to the website on the 14th or 15th, and pushing out the next issue in the middle of next month!

Comments [2]

help send me to scotland on rails!

So I got accepted to speak at Scotland on Rails!  I'm seriously really excited.  I've heard SoR is one of the best if not the best regional Ruby conference anywhere.  Not only will I enjoy the conference, but I plan to certainly take notes for this year's Hoedown.

But there's a problem.  I don't have the cash and nowhere near enough time to save it up.  So, I'm asking you, kind Rubyists and other readers alike, to help me out a bit.  I've setup a Pledgie campaign to take in some donations to help cover flights and hotel costs.

Click here to lend your support to: Send Mr. McAnally to Scotland on Rails!

If you have a few spare bucks, I'd seriously appreciate it!  I'll do my best to release the content of the presentation after the fact (on my blog and hopefully if they have video, then...video :)).

Comments [0]

rejoice! rg is now part of rails

Just over a month ago, I posted a project named rg to my Github account.  It allows you to apply programmatic templates to your Rails applications so you can avoid all that monotonous setup every time you start a new app and avoid keeping it in Git where it tends to SCM rot.  The code came about after discussing the concept with Pratik Naik on more than a few occasions, with both of us deciding that we were essentially too lazy to ever do anything about it.  

Once I got over my laziness through boredom, I hacked out the code in a couple of days and posted it up.  Over its first few weeks, it garnered a good number of watchers, patches, Twitter messages, users, complaints, and general interest from people.  Soon after, Pratik and DHH floated the idea of perhaps integrating its features into core; excited by the prospect, I overcame my sloth and sallied forth to turn rg into a patch for the Rails application generator.  As of today, that patch has been committed and rg is now part of Rails proper.

Awesome.

So, in celebration/honor/whatever of that, I thought it might be prudent to give people a little information about *how* to use it.  It's quite simple really.  Templates have a few core methods for doing things that can be grouped into a few groups: dependencies, file creation, and application actions.

Dependencies

The best part is that your templates can insert of any dependencies you might have.  So, if you need to install a plugin (let's do restful_authentication), you can do something like this:

plugin "restful_authentication", :git => "git://github.com/technoweenie/restful-authentication.git"

Or if it's a gem...

gem "jeremymcanally-context"

This will install and vendor the gem.

File creation

It can also create arbitrary files for you (for example, if you have a config file for a service you always use) using a few methods (depending on where you want the file).  The most primitive of these methods is file, which will 

file "readme.txt", "This is the data!"

The first argument is the filename, the second is a string with the data to be put in the file.  You don't have to do a quote form string; you can also do a heredoc:

file "todo.txt", <

You can also use the return value of a block...

file "readme.txt" do
  puts "Tell me your name:"
  name = gets
  
  "Your project
  by #{name}"
end

Even better, you can create files in specific locations.  For example, initializer will create a new initializer file in config/initializers, vendor will create a file in the vendor/ directory, rakefile will create a new Rake file in lib/tasks, and lib will create a new code library file (or whatever) in the lib/ directory.

Application actions

There are also a few methods to do things to the application itself, such as freeze Rails (freeze!), capify the application (capify!), or generate things:

plugin "restful_authentication", :git => "git://github.com/technoweenie/restful-authentication.git" 
generate :authenticated, "user session"

You can also run arbitrary Rake tasks:

rake "db:migrate"

If you put all this to use, this could save you a huge number of keystrokes and a lot of time every time you start an app.

Other stuff

There are a few other goodies in there if you need them.  There's a git method that'll run a git command (git "pull" or what have you), some SCM interaction classes (only Git and Subversion so far, but I hope to see Hg, Bzr, and others contributed by people who use them), and some methods to interact with users:

name = ask("What is your name?")

# Must respond with "y" or "yes" or any capitalized variation thereof (e.g., "YeS")
`touch #{name}.txt` if yes?("Is #{name} really your name?")

# Must not respond with "y" or "yes"
`rm #{name}.txt` unless no?("Did you lie in the previous question?")

Those should satisfy 90% of user interaction needs; anything outside of that you need can be written in plain Ruby code.

Where do we go from here?

Well, to actually use your template, you need to supply the -m/--template parameter when generating an application:

rails yourapp -m /path/to/my/template.rb
rails newapp --template=http://gist.github.com/31208.txt    

I'd really like to see a solid app template library be built, so to spur that effort, I've started a new repos on Github for that purpose:  http://github.com/jeremymcanally/rails-templates

I've already put a few of the previously built in templates in there.  If you have your own that you think people would be interested in, then fork it, merge yours in, and send me a pull request.  If I think it's nifty enough, I'll merge it right in!

Otherwise, enjoy.

 

Comments [6]

slimming down actionpack: ending the pissing match

 

So, in recent days there has been a lot of really stupid drama among Rails and Merb.  I appreciate the addresses of both sides of the issue, and I hope this dialogue and competition continues in this healthy manner.  But my interest was piqued when the question of lines of code came up, and Yehuda offered some metrics.  

Now, these were very unfair because, like most Merb vs. Rails comparisons, there is no parity given to features.  Comparing merb-core to ActionPack is not only unfair, it's basically deceptive.  ActionPack does nearly everything contained in the whole of merb-stack (edit: except the ORM part but you get the idea).  In any event, I got curious: what if I stripped ActionPack down?

So I started tearing out code.  I started in ActionController, un-including modules one by one until it caused Rails to break, re-including it to fix Rails.  I was able to tear out the vast majority of the code in there, but I wasn't able to strip it down to the same feature set as merb-core (f.e., I have to keep all the rendering engines in there).  Even so, at the end of my little trial, ActionPack only had 10,846 lines of code and still did more than merb-core.  If I took out ActionView (merb-core lacks most but not all of its features), it's only 7,000.  The exact same as Merb.  And it still does more!

What am I trying to say?  It doesn't matter.  Who cares?  This is stupid.  It's a useless, unfair comparison.  Don't bring up LOC ever again.  Comparing LOC is as useful as Array#fourth.  Get a job.  Cut your hair.  Take a shower, you unwashed heathen.  However you phrase it, having a pissing match about lines of code in your framework just wastes a lot of time, especially when neither side gives the whole thing a fair shake.

 

Comments [7]

lots of work: a new router for rails

So I've been kicking the idea of writing a new router for Rails for a long time.  I started tinkering with web frameworks last year, and decided that I would write a bunch of components that one could assemble or integrate into their own frameworks.  The yield of the primitive work I actually completed was fleet, and my ultimate goal was to build a router that was API-compatible with Rails and could be extracted into its own gem for others to use.  It never got that far, but I did complete most of the work on the router.

Fast-forward a while and after a conversation with Pratik, I decided to finish it up and release it as a plugin.  I haven't quite reached release stage just yet, but I thought I'd share what I have done.

Regex Inside

The current router operates in a very bizarre manner to me.  You can read all about it on Jamis' blog, but suffice to say that it's a little crazy.  Unfortunately, routing is a bit of a crazy business by nature (much like per-object permissions tends to get messy); routing requests is complex and prone to tons of edge cases.

I'm sure my approach doesn't satisfy all the edge cases, but here's how it works so far.  Routes are read in from the route file (config/routes.rb) and pushed to two structures.  One is an array of Route objects for path recognition (i.e., matching http://blah.com/pages/1 to PagesController#show with an :id of 1) and one is a structured tree (in this case, constructed in a Hash) for path generation (i.e., generating "pages/1" from the right parameters).  This separate structure is important because it lets me exploit the best features of the two types of data structures: arrays rock at ordered recall and hashes are great at direct access in an arbitrary structure.

When all the routes have been read, one big regular expression is constructed.  But here's the trick: I use parentheses to separate the captures.  That doesn't sound tricky, but consider this for a moment.  Each route is in a sequential data structure and the regular expression is built sequentially from this structure.  So you'll end up with a regular expression something like this: /(pages\/)(pages\/new)(pages\/\d+)(pages\/\d+\/edit)/ and so on.  When I run scan, I'm given an array of matches and misses.  So for pages/3, it'd look something like: [nil, nil, "pages/3", nil, nil].  I can then compare the matched index with the index in the routes array to fetch the proper array.  One match and we have our Route object.

Paraming My Meters

Parameters pose a unique challenge, but I use a similar approach.  Route strings look something like this: 'params/:id'.  When I read in the route, I parse out the parameter names into an array (e.g., ['params']).  I then match the params out using a second regular expression that uses the same parentheses trick, match them up into a Hash, and merge in any constant values that may have been provided in the route file.  Then, per what Rails expects, I set the parameters (including controller name and action in the request object) and return the controller class.

One optimization I make here is skipping the whole parameters parsing stuff if the route doesn't have any dynamic segments.  It's a micro-optimization to be sure, but it does help.

Generator to the MAX

Generation is fairly straightforward.  The structure that's generated when the routes are read in looks like this: @route_structure[:request_method][:controller]][:action][:routes_that_match_that].  So for link_to('hello', :controller => 'pages', :action => 'show', :id => 3), it'll look something like: @route_structure['get']['pages']['show'] and the :id will be subbed into the subsequently generated string.

Named routes (when they're implemented) will be generated methods that will simply return a string with the parameters in the right place.  These should be smoking fast when they're done, since they skip the routing system altogether after startup.

Soooo...?

Why do you care?  Well in my ghetto benchmarks (using ab and one resource route set), my router is about 25% faster.  I don't know about RAM usage, but I'd imagine it's better there, too.  Hopefully I can optimize it some more to get more speed and more conservative memory usage out of it, but any improvement is better than nothing!

I'll try to release it as a plugin next week, and hopefully people can start banging on it then.  Once I get it stable and optimized, I want to add a few features to it that aren't Rails-standard.  I'll keep you posted!

Comments [1]

moved to posterous

Thanks to Wordpress's exploitableness (I may have coined a term there), I'm ditching it.  Allowing malicious idiots to inject JavaScript all over the place is not my idea of a good time.

So I switched to this fun little thing called posterous.  We'll see how it goes.  But so far, I like the design and it's not my fault if it breaks, so it seems like a good deal to me.

Comments [1]