My first local conference, right here in Boulder. I had a lot of fun. Thanks Marty for a great conf.
Mountain.rb
October 20th, 2010R2 Droid 2 Unboxing
October 19th, 2010Why Not YAML?
October 17th, 2010I enjoyed Joe O’Brien’s recent post Why Yml?. He asked why we use external config files when we have an dynamic language like Ruby. Yeah, Ruby is more expressive and it would be simpler to use only one language, but to me it makes sense to use YAML for config data. And I think YAML is used a lot because it can represent config data more clearly.
So, why would you store data outside of code when Ruby is so
freaking expressive?
- Interoperability — When you have applications in different languages that use the same configuration, then having a separate file makes a lot of sense. For example, when writing a JRuby on Rails app that has bits of Java code (i.e. servlets w/ JDBC) that share the DB, you want to centralize your DB config to avoid having to do something nasty like generating properties files from database.yml.
- Security — Keeping config details, like DB login information out of the source is a good idea. It’s more secure because you often have a lot of sensitive information in your config files. The less places that information appears, the better. They should, ideally, not be checked into source control. For some reason, I feel more uncomfortable with the idea of not checking in source files than I do yaml files.
- Convention — Rail’s database.yml has a very stable structure. Keeping it as a YAML file encourages developers to not muck about with it. Why do this? There are times when having less expressivity is better because it’s harder to shoot yourself in the foot that way. It makes adding unnecessary behaviors more awkward. For database connections, this makes a lot of sense because they should not usually have a lot of logic around configuring them.
I generally agree with Joe on the ugly use of ERB in yml files, at least for things like data store configuration. When I see that or find myself doing it, I have a little a sense of “you’re doing it wrong!” Code smell, indeed.
I also think that the YAML vs XML vs JSON discussion is important here, because YAML as a language has some interesting properties that make it well suited to config type situations. In particular, I’m thinking of the ability to name chunks of the document and substitute them in other parts of the document in an override-able manner.
For example, in YAML, a set of configurations where one inherits from another might look like
development: &default adapter: foo_store port: 1337 database: base_development production: <<: *default database: base_production
The equivalent in Ruby could be represented something like
#using 1.9 syntax, so it looks more yamlish
config_hash = {
development: {
adapter: 'foo_store',
port: 1337,
database: 'base_development'}
}
config_hash['production'] = config_hash['development'].merge(
database: 'base_production'
)
Which I don’t think is quite as easy to scan.
I guess my point is that while Ruby is very expressive and powerful, sometimes a more constrained language can better express config information in a declarative manner.
Right Scale API gem
October 10th, 2010I was frustrated with the client libraries available for the RightScale API, so I wrote my own. It’s reasonably complete, but doesn’t currently have tests.
Mostly it arose out of a need to automate things and my desire to make something pretty clean.
I didn’t like the API’s of the existing libraries much, so I wrote my own.
It is fairly bare bones at this point, but I have been using it for a few months and it works for me.
Check it out:
github.com/baroquebobcat/right-scale-api
Further reading/References(Others’ Right Scale API gems & libraries):
github.com/robertcarr/RightAPI — not a gem yet
github.com/moneypools/right_api — little in the way of docs, feels pretty raw
github.com/joshuabates/rightscaler – pretty neat, activeresource based, have not tested though
github.com/dmichael/rightscale-api — uses httparty, missing most of the objects available
github.com/ktheory/rightscale_api_wrapper — not gemified, not great
github.com/stewartmckee/Rightscale-API-Gem — fuller implementation, but since it doesn’t use httparty, restclient, or activeresource, the source is really verbose
Mountain.rb
October 7th, 2010Today and tomorrow I’m going to be hanging out at the mountain.rb conference.
First up today is Jim Weirich doing a talk called To Infinity and Beyond. It should be fairly epic.
In other news I got a smart phone finally. It’s R2D2.
A New Gem For People Who Can’t Use HTTP Methods Other Than POST
September 28th, 2010Itch:
I needed to be able to look at query params in the URL for the _method parameter Rails uses to fake different types of POST-like requests. Rails currently doesn’t do this for you as it uses Rack::MethodOverride, and that doesn’t look at GET parameters. It only looks at the X-Http-Method-Override header and POST form params. Some Rails users filed a ticket awhile ago about it, and it is an ongoing concern(see #2289).
Scratch:
Being a go getter, active, knows his way around a gemspec sort of person, I whipped up a library so if you run into this problem, you can fix it easily. Rack::MethodOverrideWithParams is the result. It is a drop-in replacement for Rack::MethodOverride, so all you have to do is replace Rack::MethodOverride in your stack with it and you’ll be rocking query param method overriding goodness.
“How easily”, you might ask. Let me show you. It’s just a couple of code additions:
Gemfile
gem "rack-methodoverride-with-params", "~> 1"
config/environment.rb
config.middleware.swap Rack::MethodOverride, Rack::MethodOverrideWithParams
Done.
What do you think?
Links
github.com/baroquebobcat/rack-methodoverride-with-params
Wildfire near Boulder
September 8th, 2010Speaking at Ruby|Web Conference on Friday
September 8th, 2010On Friday morning I am speaking at the Ruby|Web Conference at Snowbird in Utah. I’ll be giving a talk entitled “Extreme Performance with Mirah and Dubious“. I’ll be talking about a project I’ve been helping out with called Dubious, which is a web framework written in Mirah.
Check out the source:
Ada Lovelace Day
March 25th, 2010Hey it’s Ada Lovelace day. I found out about it from 2d goggles, a web comic that follows the awesome adventures of Ada Lovelace and Charles Babbage.
Ada Lovelace Day is an international day of blogging (videologging, podcasting, comic drawing etc.!) to draw attention to the achievements of women in technology and science.
Women’s contributions often go unacknowledged, their innovations seldom mentioned, their faces rarely recognised. We want you to tell the world about these unsung heroines, whatever they do. It doesn’t matter how new or old your blog is, what gender you are, what language you blog in, or what you normally blog about – everyone is invited.
The two women I thought of are Rear Admiral Grace Hopper and Barbara Liskov without whom computing would not be where it is today. They rock.
I use concepts they came up with every day. e.g. The Liskov Substitution Principle: If it looks like a duck, quacks like a duck and needs batteries, it’s probably not a duck. Or for Grace Hopper, compilers and the idea that computing machines could be used for things other than arithmetic (read calculating bomb trajectories).
Some Quotes
I had a running compiler and nobody would touch it. … they carefully told me, computers could only do arithmetic; they could not do programs.
– Grace Hopper [more]
It’s much better to go for the thing that’s exciting. But the question of how you know what’s worth working on and what’s not separates someone who’s going to be really good at research and someone who’s not. There’s no prescription. It comes from your own intuition and judgment.
– Barbara Liskov [src]
Check out some of the other posts for Ada Lovelace day at findingada.com
Mountain West Ruby Conf Rocked This Year
March 22nd, 2010Mountain West Ruby Conf this year was awesome. I totally had a blast.
It was the third time I’ve gone to it. It was my first conference and still is my favorite. I got to meet Matz, I gave a lightning talk, I met all sorts of interesting people and I learned a bunch of new things. To quote Matz, MountainWest RubyConfはすばらしかった。
Things to revisit
- Rack(1.1.0 in particular)
- Chef(looks better than the last time I poked at it)
New things(to me)
- RVM(rvm looks pretty handy, especially for cross vm library development)
- Hubris(this might be a neat way to get into Haskell development)
- Mucking about with the binary interfaces(because it is awesome.)
My lightning talk






