Read about:

Archive for the ‘Programming’ Category

How PostRank Analytics Brought Me To Ruby Kaigi

(Programming)

One of the coolest things about working for PostRank is that I am part of creating a product that I can be very passionate about because I am one of the sorts of people it’s made for. In short, I eat our dog food. So I wanted to dedicate today’s post to sharing a small anecdote about one of the killer features of PostRank Analytics, the Activity Stream. Read the rest of this entry »

RSpec Matchers: More Than Just Assertions

(Programming)

I recently read a post from Carbon Five about RSpec best practices. The most delightful thing about it was reading it after I’d been writing a spec at work and noticing that how I was doing it was close to what was being described. It was a little bit of validation, a pat on the back for all of the reading, practicing, and thinking about BDD that I’d done to that point. But then Carbon Five asks “so what else?” Read the rest of this entry »

Introducing gabriel

(Programming)

If you’re running a large-scale Ruby project, chances are that god is monitoring your long-running, background processes. I’ve had some encounters with god and I decided that I was fed up with not having tab completion for it.

So I created gabriel. gabriel helps you communicate with god by offering completions for subcommands, options, tasks, and group names for your bash shell. Installing it is pretty simple:

$ gem install gabriel
$ gabriel-install
(From there, follow the on-screen instructions)

To ensure you get completions in every session, confirm that your .bashrc is sourced in your .bash_profile (or .profile, if you’re a bit more old-school).

This is my first foray into shell scripting and into publishing a ruby gem, so check out the source and if you can make gabriel even better, please do contribute your patches.

May god watch kindly over all of your processes.

Context Switching

(Miscellaneous, Programming)

One of the reasons this blog is called “Live & Code” is because Computer Science (and by extension programming) is one of the lenses through which I view the world. There are often parallels between the way we think and the way computers work. I don’t think that this is an accident; the term “computer” used to refer to a human being whose profession was computing values. These people would sit and work through algorithms to calculate values that would be used in scientific research.

One of these parallels between humans and computers is the way that we multitask. Computers only seem to multitask by switching between tasks rapidly, with the exception of new multi-core and multi-processor systems, which can run as many tasks in parallel as there are cores or processors. So it was interesting to read recently that the prevailing theory is that humans multitask in precisely the same way!

Read the rest of this entry »

Life advice in code

(Personal Development, Programming)

Live & Code has been largely about programming and life lessons. So, you can imagine that I was incredibly delighted to see these two combined in a small exchange on Facebook started by Reginald “raganwald” Braithwaite.

Life Advice in Code (raganwald)

Self-esteem expressed in Ruby

It’s a valuable life lesson made incredibly concise in my favourite programming language, Ruby. I leave the interpretation to the reader. It relates to some themes that I’ve already written about before and will probably write more about in the future.

LDAP-based RBAC with ActiveLdap and declarative_authorization

(Programming)

If you followed my previous tutorial on implementing pass-through authentication to LDAP with Authlogic, you might be wondering how it can be extended to give different permissions to members of different LDAP groups. ActiveLdap and declarative_authorization make this incredibly simple.
Read the rest of this entry »

Adventures in Ruby: When Constants Aren’t

(Programming)

I just squashed a bug that had me scratching my head for at least a good half-hour or so involving a class constant that kept on getting changed. Here’s the setup (anonymized so that I’m not exposing gooey proprietary secrets):

class WebTransaction
 
  # Base URL for transaction web service
  SERVICE_URL = "http://accountingservice.com/"
 
  def transaction_url
    url = SERVICE_URL
    url < < "VAL1=foo"
    url << "&VAL2=bar"
    url
  end
 
end

The class is meant to represent a transaction being posted against a rather odd web service that actually uses GET rather than POST for posting transactions (bad web service!). In my actual code, the URL parameters appended to the SERVICE_URL base would be determined on a per-object basis but I’ve simplified it here.

Here’s the punchline: SERVICE_URL was changing! Calls to transaction_url would keep on appending more variables to it. If you’re particularly clever with Ruby, you’ve already figured out exactly why. But if you’re scratching your head like I was, here are some hints:

  • In Ruby, constants aren’t. In fact, they’re really no different from variables except for the fact that Ruby detects that variable names in all-caps are probably supposed to stay constant and warns if you try to assign to them.
  • <<, for strings, will append to the end of the string.
  • Ruby strings are mutable. That is, operations on a string variable will usually be done in place, rather than returning a new string. (Method calls, on the other hand, are a different story!)
  • Assigning a String variable to another String variable will assign the reference. That is, the two variables will be pointing at the same object.

Hit the jump to see the solution to this little mystery…
Read the rest of this entry »

“So… what do you do?”

(Personal Development, Programming)

I think that this is a dreaded question for many programmers and others in fields with a scientific or mathematical bent. How do you explain the full extent of what it is that you do and why it’s valuable without being dismissed as just another creepy nerd? How do you fight the stereotype of unkempt basement-dwellers living with their parents, spending most of their time on the Internet because they’re too socially awkward to interact with people in other settings?

About a week ago there was a discussion about this on programming Reddit. The original poster, a programmer, feels a sense of inferiority because while others can succinctly explain the “awesome” in what they’re doing, he cannot. I sympathize with this sentiment. I love what I do but how do I transfer that passion without drowning the other person in the technical details? It feels like without the finer, technical details, my job description becomes distilled to “I make websites.”

Really? That’s it? That’s what I do for a living?

Read the rest of this entry »

LDAP Pass-through Authentication with Authlogic and ActiveLdap

(Programming)

Today, I pushed a branch to my fork of authlogic_example: with-activeldap.

This branch shows a way of implementing pass-through authentication to an LDAP server using ActiveLdap and Authlogic, with just some small changes to the User and UserSession models.

Read the rest of this entry »

Where is why?

(Programming)

“Why The Lucky Stiff”, one of the most influential characters in the Ruby community, has simply vanished. His Twitter account, GitHub account, and most of his websites are gone without a trace.

Why The Lucky Stiff’s contributions to the Ruby community include “Why’s Poignant Guide to Ruby”, a book which many state was the reason they got into Ruby, Shoes, an easy-to-use cross-platform GUI toolkit with innovative online distribution features, and Hpricot, a very slick HTML parser that is also a joy to use.

Some believe that he has decided to move on from software development because his last tweet reads “programming is rather thankless. u see your works become replaced by superior ones in a year. unable to run at all in a few more.” Some believe that his accounts were all hacked. A few others believe that his anonymity has been compromised and that he has decided the destroy the pseudonym.

Wherever Why The Lucky Stiff goes from here, I hope he knows that there are so many of us who looked up to him and have him to thank for knowing the joy that is programming in Ruby. He will be sorely missed.