• Random
  • Archive
  • RSS
  • Ask me anything

Ryan Angilly

A business guy who became a really good software developer first by accident

Ruby developers, use Hashie::Mash

    • #ruby
    • #gems
  • 4 months ago
  • 5
  • Comments
  • Permalink
  • Share
    Tweet

Fantastic presentation by @aniero on EventMachine

    • #ruby
    • #eventmachine
    • #presentation
    • #reactor pattern
    • #inversion of control
  • 5 months ago
  • 3
  • Comments
  • Permalink
  • Share
    Tweet

@gruber’s improved regex for matching URLs written in Ruby

There were some minor changes to make this a valid Ruby regexp. Thanks @gruber

    • #regex
    • #url
    • #ruby
    • #regular expression
  • 6 months ago
  • 5
  • Comments
  • Permalink
  • Share
    Tweet

My final gripe w/ Heroku has been solved: Release Management

Anyone that has maintained a “fer realz” web app knows that the release management is nothing to be taken lightly.

The common workflow for deploying goes something like this:

  1. Qualify that master is ready to be deployed
  2. Cut a release branch from master
  3. Deploy that branch to production

Days and weeks will go by, and you will continue to advance master with new feature and bug fixes.  If a critical bug is found in production, the process to fix is simple:

  1. Put the fix in master & verify
  2. Cherry pick that commit into the release branch
  3. Re-deploy release branch to production

Everybody wins.  You get to fix production without pulling your new and possibly not ready features from master into the fold.

In Heroku, you just push your git repo to their remote, and they deploy your app.  When pushing to Heroku, they will deploy whatever is on the master branch.

Sounds great, but the classic release management process breaks if you have a staging app also running on Heroku, because they both want to deploy off of master.  For example:

  1. Deploy master to production
  2. Build new features in a dev branch
  3. Merge them to master so that you can deploy to staging
  4. Find critical bug in production
  5. …?

The problem here is that master is now littered w/ the features that are on staging.  What’s a guy to do?

Well, one my favorite humans (who apparently knows git better than I do) not only figured it out, but wrapped it up in a little Rake script for all our benefit.

Michael Dwan wrote this blog almost a year ago, where he solves the problem of release management in Heroku.  At it’s core, it’s just a git trick.  Instead of:

git push staging # <— staging is your heroku staging remote

git push heroku # <— heroku is your heroku production remote

Michael figured this out:

git push staging +edge:master #<— where edge is some local branch

The +edge:master part says “Hey, staging, I’m gonna trick you into thinking that the branch called edge is really master, so use that instead.”

Now you can pick a production and a staging branch, use any other branch (including master) however you want, and not worry about being stuck in a situation where you cannot fix a critical production bug.

He wrapped all this up in a handy set of rake tasks and even put some provisions in place to prevent you from accidentally deploying the incorrect branch to production.

Brilliant.  Thanks Michael.  You rock.

    • #git
    • #heroku
    • #ruby
    • #deployment
    • #release management
    • #nerdalert
  • 8 months ago
  • 5
  • Comments
  • Permalink
  • Share
    Tweet

mulligan - a Ruby idea for dealing with things that fail frequently

Note: There seems to be some weird style issues with gist on this Tumblr theme. There isn’t enough horizontal padding between keywords.  Sorry.

Twitter fails a lot. It got me thinking about an elegant way to deal with things that fail frequently. This is how I wanted to be able to write code:

Here is how I accomplished it:

I’m gonna tweak it into a gem eventually, but I want some nerd feedback first. I can see a whole bunch of options being added: which exceptions to catch, custom handlers, etc…

What do you think?

    • #ruby
    • #error handling
    • #twitter
    • #mulligan
    • #nerdalert
  • 8 months ago
  • 3
  • Comments
  • Permalink
  • Share
    Tweet

Scoped mass-assignment in Rails3

I’ve fought this beast a few times — I think this is a perfect solution. Via @dpickett

    • #Rails
    • #Ruby
    • #web development
    • #activerecord
  • 8 months ago
  • 2
  • Comments
  • Permalink
  • Share
    Tweet

Ruby 1.9.2 Encodings

An awesome series by James Gray.

    • #ruby
    • #ruby 1.9
    • #encoding
    • #character encoding
    • #nerdalert
  • 9 months ago
  • 7
  • Comments
  • Permalink
  • Share
    Tweet

Stinky Magic

This post was written in response to http://modernsage.wordpress.com/2011/02/05/rails-3-0-arel-acrobatics/.  The original post has code examples that are clearly for illustrative purposes and not from the codebase (code where AR models are not descending from AR::Base, for example), so it’s possible that some important details have been left out.  However, for the sake of conversation (and because sometimes it’s just fun to write a nerdy blog post), I wanted to respond.

In that blog post, my buddy Chris is doing some stuff with Arel/AR that, in my opinion, is backwards. It’s causing some confusion that led him to extend ActiveRecord::Base in a way that I feel is unnecessary, and potentially dangerous down the road.

Chris wants to do stuff like:

  Forum.mine.posts.comments

The intent is that he wants to access all the comments owned by a post owned by a forum owned by a particular user.  Working off the Forum model, he wants to scope things through the ‘mine’ scope, which scopes the Forums to an authenticated user.

Two problems

First, Forum.mine is a backwards way of accessing records belonging to an authenticated user. Normally, a Rails app would authenticate a user and provide helpers at the view and controller level to access that user.  You’ll see this in a lot of apps as the method ‘current_user’.

The problem with Forums.mine is that in order for it to work, there has to be code inside the model that goes back out to the authentication system.  Authentication is the controller’s domain.  It’s an awkward coupling of concerns that causes your code to get all tangled up.

A much more straightforward way to retrieve objects is to have the user be at the root when going left to right.  The common way to get Forums owned by a person at the controller level would be:

  current_user.forums

The second problem is that:

  Forum.mine.posts.comments

just doesn’t make sense.

Posts, as a collection, don’t have comments.  A single Post has comments.  The concept of Comments that belong to many Posts doesn’t exist here.  It’s a confusion I’ve seen in new and experienced ActiveRecord developers alike.

This is much more straightforward:

  current_user.forum_comments

In a github repo, I’ve put an example of how I would write this.  User#forum_comments, in this case, uses a has_many :through relationship to get at the posts, and then does a map and a second query to get the comments.

  class User < ActiveRecord::Base
    has_many :forums
    has_many :posts, :through => :forums

    def forum_comments
      Comment.where(:post_id => posts.map(&:id))
    end
  end

Because Chris didn’t want to do this, he implemented an extension of ActiveRecord::Base that allows it to work:

  Forum.mine.posts.comments

It goes through and creates all the necessary scoping to allow that query to return comments.  Even though I don’t have any examples, I’m pretty this will break down as more complicated relationships are introduced.

Stinky Magic

The last paragraph of Chris’ post says:

You can use it with a single association or with a monster hierarchy of the form A -> B -> C -> D -> E -> F ->DRY, recursive, scalable. Now that’s what I call magic.

In my opinion, this is horribly dangerous.  If you start doing this stuff, and A, B, C, D, and E grow to be a couple million rows (which is not very uncommon at all nowadays) you’re gonna have a very non-scalable join to deal with.

I think a developer should err on the side of verbosity and explicitness when defining relationships.  If you really need to do A -> B -> C -> D -> E -> F a lot, that’s a sign that some de-normalization may be justified.  Assuming that -> denotes has_many, F would have an e_id on it.  In this case, adding an a_id would allow you to go A -> F directly and much faster.

A little bit of CS (read: Kool-Aid)

Another reason to go the “user.forum_comments” route instead of the “Forum.mine.photos.comments” route is that it invites developers to constantly violate the Law of Demeter.  I didn’t go to school for CS, but I’ve come to respect this rule over my years of Ruby development.  It’ll help to keep your code readable, and easier to mock behavior for testing.

    • #ruby
    • #rails
    • #activerecord
    • #arel
    • #activerelation
    • #data modeling
    • #law of demeter
    • #nerdy
  • 12 months ago
  • 8
  • Comments
  • Permalink
  • Share
    Tweet

An open letter to recruiters from developers

I get InMail, tweets, and direct emails all the time from recruiters.  I think I make it pretty clear that I’m not interested in finding a new job right now, but the emails come anyway.  They almost always have the same format:

[generic greeting].  I came across your (twitter profile|profile on LinkedIn|blog).  My organization [generic recruitment firm name] has a [arbitrary list of ‘excitement’ related adjectives] position in Ruby/Rails that I think you’d be perfect for [even though there’s a very good chance I don’t have a clue what your skill set is even after reading your resume/profile because I don’t have a technical background].  If you are interested, please get back to me and I will send you [the job description that for some inane reason I didn’t include in the first place].  If you are not, perhaps there is someone in your network who would be interested.

[generic sign off / apology for wasting time]

* rolls eyes *

Here’s my open letter response to all recruiters:

Dear Recruiters,

Us developers have been getting pretty tired of the “you might not be interested, but maybe you know someone who is” line.  ALL of you recruiters use this line.  I understand you probably think that you are  ”networking”, but it really just seems like you’re trying to get us to do your job.  What ends up happening is that us developers all get together in a bar, have a few beers, and talk about how incompetent tech recruiters are.  Lord help you if you happen to reach out generically with the SAME email on the SAME day to 3 or 4 developers who are friends.  It’s probably not the case that you are incompetent, but it’s definitely a place where we lose some respect for you.

So, cool it.  If you have a good idea, go find people that are actually looking for a job and write them a personalized email telling them about it.  If you’re new and not technical, admit it.  Tell us “hey man I have this Ruby/Rails gig and I saw those keywords on your profile.  It might not be a perfect fit, but would you ever want to chat about it?  I’m trying to learn more about this space.”
Most developers (that I know anyway) react better to requests for help than generic sales pitches.
Be honest.  Be personalized.  Be respectful.  Everybody wins.
$0.02
Love,Developers

EDIT: Shame on me.  The recruiter who reminded me to finally publish this draft responded to me directly about this blog post.  He informed me (very respectfully) that I had not removed ‘looking for new ventures’ or ‘looking for career opportunities’ from my LinkedIn profile.  So apparently I was wrong; I had not made it clear to recruiters that I’m not looking for work.  The rest of the rant stands anyway, though. :)  Happy New Year!

    • #tech recruitment
    • #startups
    • #tech
    • #ruby
    • #rails
    • #rant
    • #open letter
    • #software
    • #software development
  • 1 year ago
  • 1
  • Comments
  • Permalink
  • Share
    Tweet
← Newer • Older →
Page 1 of 3

Portrait/Logo

About

Hi, I'm Ryan, and I build stuff on the internet. I'm currently building Signal Genius.

I blog about my failed startup, MessageSling, at The Day Series.

Things I used to do:

  • Built and launched FourthSegment
  • Hacked at Punchbowl.com.
  • Founded MessageSling.com.
  • Spent several years at EMC

Me, Elsewhere

  • @angilly on Twitter
  • Facebook Profile
  • angilly on Flickr
  • angilly on Foursquare
  • My Skype Info
  • ryana on github

Twitter

loading tweets…

Following

I Dig These Posts

  • Photo via tmills

    A serious bath-taking bear.

    [via]

    Photo via tmills
  • Photo via tmills

    I read this thing on Vice tonight about how girls hate girls even when they’re friends and while all things women are forever hermetically sealed...

    Photo via tmills
  • Link via graysky
    cdixon.org – chris dixon's blog / Best practices for raising a VC round

    (via Instapaper)

    Link via graysky
  • Photo via dancroak

    Puppy.

    Photo via dancroak
See more →
  • RSS
  • Random
  • Archive
  • Ask me anything
  • Mobile

Effector Theme by Carlo Franco.

Powered by Tumblr