Building Concurrent Primatives in Ruby without a Queue

The number-one, easiest way to make Ruby threads communicate and synchronize is to use the built-in Queue class. You can even see this in the Ruby docs: This class provides a way to synchronize communication between threads.

Unfortunately, a Queue isn’t always what we want. So, how can we build our own primitives that are still nice and thread-safe? Read more on Building Concurrent Primatives in Ruby without a Queue…

Parsing Excel Files with Ruby

In this post, I will review options for parsing Excel files using Ruby. I’ll discuss the different types of Excel files and introduce some of the Ruby libraries that exist for working with them. Note that I focus mostly on reading Excel files in this post, but there is some discussion around writing/updating them as well.
Read more on Parsing Excel Files with Ruby…

Code Generation for Rails Utility Scripts

It seems that on every Rails project I work on, I end up writing utility scripts that make changes to the production data in some way or another. Perhaps it’s pre-loading hundreds of user accounts for a customer that wants to provide a spreadsheet of users, or populating an account with fake data that can be used for a demo, or manually fixing a data integration issue with an external system. Often, this requires parsing and processing a source file (like a CSV file). Read more on Code Generation for Rails Utility Scripts…

Run a Local Rails Script on Heroku

Heroku provides a convenient command line interface for executing snippets of Ruby code remotely. One-liners can easily be piped into the heroku run console command. But what about much longer scripts that you write locally and want to execute in a remote Heroku environment? In this post, I’ll show you how to execute a long Ruby/Rails script in a remote Heroku environment.

Read more on Run a Local Rails Script on Heroku…

Uploading Files in Rails Using Paperclip and Active Admin

I recently came across a situation where I needed to be able to upload a file to a Rails server with Active Admin. I did a quick search on Google and found this post by Job, a fellow Atom.

Our use cases were a little bit different, though. He was storing the file contents directly in the database, whereas I needed to be able to uplaod a firmware image file to the server’s filesystem, parse the file name, and perform some validations on the file. I decided to use the Paperclip gem to manage the file processing and storage. Using Job’s advice on Active Admin file uploads, I expanded his example to incorporate Paperclip.
Read more on Uploading Files in Rails Using Paperclip and Active Admin…

Monadt – Algebraic Data Types and Monads in Ruby, Part 2: Monads

In yesterday’s post, I introduced monadt, a gem that adds algebraic data types (ADTs) and monads to Ruby. Today I’m going to dive into how monadt provides monad support, specifically the imperative-looking syntactical sugar you get in languages like Haskell and F#. Read more on Monadt – Algebraic Data Types and Monads in Ruby, Part 2: Monads…

Monadt – Algebraic Data Types and Monads in Ruby, Part 1: ADTs

Functional programming is elegant and expressive. I’ve written before about my love of partial application, and how the funkify gem can be used to bring the power of partial application to your Ruby code. But partial application is just one of the powerful idioms from functional languages that I’d like to borrow in object-oriented languages. I’m also pretty into algebraic data types and monads.

So, continuing my pattern of adding functional concepts to object-oriented languages whether they like it or not, I recently created the monadt gem which adds support for using algebraic data types and monads to Ruby. Read more on Monadt – Algebraic Data Types and Monads in Ruby, Part 1: ADTs…

Objective-C Value Objects: Code Generation

In my previous post, I talked about using Value Objects in Objective-C projects. I gave an example of a Ruby DSL that could be used to specify the object’s properties so the code could be generated.

In this post, I’ll go through some Ruby code that can turn that DSL into an Objective-C header and implementation file. Read more on Objective-C Value Objects: Code Generation…