Roblog

Recent posts

  • A Caching Analogy

    Explaining caching is hard; here’s an attempt.

  • Ruby regular expressions: the /o modifier

    An explanation of the little-used – but handy-to-know – o modifier to Ruby’s regular expressions.

  • Real progress in long-running command-line scripts

    Sometimes, you write Ruby scripts that take a long time to execute. Here’s how to show progress to your scripts’ users – part two in a series, this time showing how to display real progress to users.

  • Faking progress in long-running command-line scripts

    Sometimes, you write Ruby scripts that take a long time to execute. Here’s how to show progress to your scripts’ users – part one in a series, this time dealing with how to show indeterminate, faked progress to reassure users that something is happening.

  • Persisting data in Ruby with PStore

    Ruby comes with a powerful persistent storage system that’s backed by flat files and handles concurrent access and transactions out of the box – stuff you’d expect to need a database for. It’s criminally underused, and it’s called PStore. Never roll your own file locking code again!

  • Paths aren't strings

    If you find yourself passing around lots of file paths in your Ruby scripts, you should save yourself a headache and use Pathnames, not strings.

  • Nokogiri as a command-line tool

    Most Rubyists are familiar with [Nokogiri][]. It’s a combination XML and HTML parsing tool most commonly used for “screen scraping”: that is, fetching a web page, and searching through it to extract information of interest. When a website you’re interested in doesn’t offer an API, it’s often the only way to extract information from it.

  • Publishing tech books with LeanPub

    My experience writing a book using the fledgling publishing platform LeanPub.

  • Decoding "Almost Sinatra"

    In 2010, Konstantin Haase wrote a golfed version of Sinatra that was just 999 bytes long. What can it teach us about both Sinatra and Ruby?

  • ARGF in Ruby

    Ruby has a construct, inherited from Perl, that makes it easy to write scripts that work with input from both files and standard input. It’s called ARGF, and here’s how to use it.

  • Ruby's -e, -n and -p switches

    Ruby inherits lots of goodness from Perl. One of those things is the ability to invoke it in one-liners from the command line, and when you do so there are three switches that come in handy. Here’s how to use them.

  • Accessing WordPress from Ruby: Part III

    The final article in a series on accessing WordPress data from within Ruby scripts, using ruby-wpdb.

  • Accessing WordPress from Ruby: Part II

    More examples of ways to use ruby-wpdb to access WordPress data from within Ruby scripts.

  • Accessing WordPress from Ruby: Part I

    An introduction to ruby-wpdb, and how to use it to access WordPress data from Ruby.

  • Clarifying lambdas

    Blocks in Ruby are great. But sometimes, using named lambdas can be intention-revealing in a useful way. Here’s how.

  • An introduction to HTTP verbs

    HTTP runs on verbs. Here’s what each of them mean – useful if you’re creating a REST interface.