Archive for the ‘ruby’ Category

RockyMountainRuby 2013

Wednesday, November 6th, 2013

Rocky Mountain Ruby 2013 was at the end of September this year. I taught a workshop on writing external DSLs that was fun and difficult to put together. You can look through my class notes, if you are interested.

I also gave a short lightning talk on Muskox, a small library I’ve been working on. The talk’s up on Confreaks / YouTube now, which is awesome. The TL;DR is that populating input data structures willy-nilly from some generic language like JSON or especially XML can be dangerous, so you should prevent bad data from entering your system during parsing.

Going to Mountain West Ruby Conf 2012

Tuesday, March 13th, 2012

Tomorrow I’m heading out to Salt Lake City for #mwrc. It was my first Ruby conference and it’s still my favorite. The session line up looks great.

See you there.

mtnwestrubyconf.org

Upgrading from Rails 2.3.8 to 2.3.14: find_or_create_by on associations changed

Monday, January 9th, 2012

Update: I’m not the first one to run into this: lighthouse ticket find_or_create-via-has_many-fails-for-hash-parameters and rails/rails#207.
Between 2.3.8 and 2.3.9 a change was added to ActiveRecord::Associations::AssociationCollection#method_missing that caused find_or_create_by_* to no longer accept hashes as arguments. An app I was upgrading from 2.3.8 ran into this as it passed hashes to a find_or_create_by_* call.

The symptom was that foobar in find_or_create_by_foobar became a serialized hash when saved to the database, instead of the string I was expecting.

The reason it was changed was to ensure that the caches on the collection were updated properly (lighthouse 1108) & (commit fad166c1), which is pretty important, but the fix didn’t take into account dealing w/ two of the cases that find_or_create_by_* accepts when called on an ActiveRecord class:

  • post.comments.find_or_create_by_body :body => 'bar', :type => 'baz'
  • post.comments.find_or_create_by_body 'bar', :type => 'baz'

The new behavior looked like this:

I wrote a patch for it (github.com/rails/rails/pull/4331). Then I found out that 2.3 is only accepting security patches, so I closed it.

If you run into this and you want to use my patch, refer to gist 1586708 which has a monkey patchified version of it. If you want to work around the bug, you can use the optional block to set the attributes you were passing in the hash.

Test ActiveRecord with Reset Transactions Without Rails

Monday, January 9th, 2012

I found myself wanting to use Rails’ test transaction functionality in a Rails-less environment, and couldn’t find a tutorial about it. So I dug into the Rails source to figure out how it worked–just enough to pull it out into a gist. So, if you add this to your test_helper.rb or equivalent, you too can have your ActiveRecord tests wrapped in transactions that rollback after each case. It also lets you use fixtures, but who does that?


Another BugMash This Saturday

Monday, October 24th, 2011

It’s halloween weekend and I’m going to mashing some bugs. Rails has got 557 issues open and we’re going to take a crack at ’em.

If you’ve never contributed to Rails before, or you have a couple commits that have been accepted, we’d love to have you.

If you want to join me, please RSVP at http://plancast.com/p/86c6/rails-bugmash-halloween-special-edition

RubyConf

Tuesday, September 27th, 2011

RubyConf is this week. I’ll be there in my hat and beard. I’ll also be wearing my funny shoes. If anyone’s interested in talking about Mirah, ping me.

Also, my friend Prakash is speaking, so give his talk a look.

Rocky Mountain Ruby Conf

Thursday, September 8th, 2011

I enjoyed the conference last week. Serious props to Marty and the rest of the organizers. I wish I could have gone to more of it.

Mini Code Retreat
The code retreat went pretty well. I think the people who showed up had a good time, and learned a thing or two. We had about 16 people show up initially, with some leaving after the first session.

It was my second time co-facilitating. I still get that, “Do I really know what I’m doing?” feeling, but I’ve gotten better about it. The thing that was hard for me was not asking as many questions. I want to see what people are thinking, and how they are conceptualizing what they are doing.

But, that’s not really necessary. I think my most important role in code retreat is enforcing the structure. Getting people to do more pairing with others that they don’t know, making sure the sessions run on time, that sort of thing. Which I certainly did.

Prakash facilitated with me. It was his first time doing it, and he totally rocked it. Together we had a lot of fun introducing some people to what code retreat is, and hopefully got them thinking about their craft in a way that will affect their day to day coding. Or at least that they had fun.

Conferencing

I could only go to the sessions on Thursday due to some timing issues on Friday, but I really enjoyed the talks I saw.

Mike Gehard encouraged us all to meditate three times a week and tweet about it with the tag #devmed. So far I’ve managed to meditate in the mornings twice. My goal is to meditate for 10 minutes Monday/Wednesday/Friday, but we’ll see how that goes.

Michael Feathers’ keynote was on code blindness. He talked about how organizations who don’t deal directly in software tend to view and manage their software development and the stages they go through as they improve or don’t. There was a lot of good stuff in there. I thought the stages of code blindness/better understanding and management resonated with other things I’d read and experienced.

I came away with a few key things that affected me. One is to plan for your software’s obsolescence. Face it, code has a lifecycle. Another was that metrics are only useful in context. “We’re 5 this week & we were 4 last week”–what does that mean? Also, don’t make metrics into goals, unless you want people to meet them to the exclusion of other, more useful things.

API Design Matters by Anthony Eden really resonated with me. Shipping software the last year or so, I’ve become more aware of the issues inherent in developing an API. I really think Readme Driven Design, and building the client code first, etc are really useful. Those are the sorts of things I think about working on Mirah and the other OSS projects I work on. They help you create an API that is fun and quick to understand. Not to say it’s easy to do though.

REST and Hypermedia by Nick Sutterer. Apparently I’ve been doing it wrong all this time. In short, this is “APIs need links too.” More specifically, clients should never have to construct a URL beyond the initial entry point into your system. Every API response should contain within it links with associated actions s.t. a client can just traverse your system from one point to the next. Kind of like a person with a browser.

Exceptional Ruby by Avdi Grimm. This was awesome. The examples were short and to the point. And, they were easy to understand. Exceptions in Ruby are really nifty. I need to play with hammertime.

Mastering the Ruby Debugger by Jim Weirich. Jim’s a really good speaker. I always enjoy listening to his talks. I don’t really have much experience with Ruby’s debugger. This primer made me feel like if I needed to, I could just drop in and use it. He also introduced us to the pry library, which is a really cool little gem for inspecting object state.

Unconference

I went to the unconference on Thursday evening and sat in on the Diversity Panel, and gave a short talk on Mirah.

We talked about the lack of diversity in our profession and the current dearth of good engineers and what to do about it. At the end, we came up with some things to do to bring more people into our community.

All in all, I enjoyed myself, met a lot of new and interesting people and learned quite a bit.

Mini Code Retreat at Rocky Mountain Ruby

Monday, August 29th, 2011

Tomorrow I’m helping facilitate a mini code retreat–one of the events for Rocky Mountain Ruby Conf.

It’ll be the same format as a full code retreat, only with half the sessions.

See you tomorrow!

Mountain West Ruby Conf

Tuesday, March 22nd, 2011

Badge & Breakfast

Mountain West Ruby Conf last week rocked. It was well organized as always–props to Mike Moore(@blowmage) for putting it together and Confreaks for recording it and all the other people who made it the awesome conf that I like coming to every year(e.g. Jeremy Nicoll-Smashing Photographer).

CHE-UP my friends.

More seriously, Zed’s talk made me think more carefully about my open source contributions in terms of who benefits from my work. Am I just a sucker for working on stuff like Dubious or am I just doing it because I find it interesting and engaging. I think he crafted a really good talk and a good meme(CHE-UP) and made a good point about being aware of the motivations behind projects you contribute to. Now I just need to find some suckers/contributors to help me with my plans for world domination ;).

Mind Monkey Patching

David Brady’s talk about head hacking reminded me that I need to finish Pragmatic Thinking & Learning, a good book I’ve been reading off and on for more than 6 months now. I need to try using that crazy cat picture (the one with too many eyes) to trigger hardware interrupts at interesting times. Might be fun.

“Web” Development

Wayne Seguin’s talk was very topical as MWRC is my favorite conference to meet new and interesting Rubyists. I feel like I did some definite “web” development while I was there. I met new people and spent more time getting to know better some of the people in the community I’d met at other conferences.

I came away from the talk feeling inspired to do more looking at teaching and mentoring, something I looked at a little at RubyConf.

Concurrency

Concurrency was a big theme at the conference with Ilya Grigorick talking about more advanced concurrency models, and Preston Lee presenting about using the GPU and CUDA to solve embarrassingly parallel problems.

Ilya talked about the Actor model, which Erlang uses as well as Pi-Calculus/CSP which is what Go uses. Both deal with concurrency by providing constraints on what you can do within them. Interestingly, their constraints are very similar, but have different abstractions with regard to what is named.

In the Actor model,

  1. Name every process
  2. Every process has a mailbox
  3. Communicate via messages

In the CSP,

  1. Processes are anonymous
  2. Every channel has a name
  3. Processes communicate over channels

He wrote a gem that acts like CSP called agent

 

5K

I ran in the 5k. I slept through it last year and decided that I had to do it this year. There were 13 of us. It was very dramatic.

Rounding the last corner

Rounding the last corner (pic by smashingshots.com)

I think I was last.

Mirah & Dubious

Mirah and Dubious were represented. I did a lightning talk on Dubious Thursday and Joe O’Brien showed off what is going on with Pindah as part of his Ruby on Android talk. I got to introduce a few people to Mirah and Dubious which was pretty cool. It seems like people are getting more interested in Mirah and projects written in it, which I think is pretty awesome.

Some other thoughts

Redis is a pretty cool project that I’d like to look at more than I have.

Wood cuts make for nifty slides.

Figs are killer.

 

Thanks again everybody for a great conference.

 

 

 

It’s That Time of Year Again: Mountain West Ruby Conf Time.

Tuesday, March 15th, 2011

I’m going to Mountain West Ruby Conf again this year. The talks look great, the venue, as always is awesome and this year I might even run the 5k(in my VFFs of course).

I’m hoping to get some hacking done on Dubious and introduce some more people to it. You can do some really cool things with it, even in its current, limited state, and I’d like to see it played with and used more.

If you see me there, I’ll probably be wearing my black fedora and sporting a nice beard. Not as big as last year’s though(exhibit A).

Matz & me at last year's MWRC
Matz & me at last year’s MWRC