Josh McArthur
Temporary PostgreSQL Database with Docker

Every now and then I need to restore an old database backup to grab some data out of. I use Postgres containers for every app I work on, so I don’t really want to go polluting those. Here’s how I start a postgres container, restore a DB into it, do...

Totara Flats, Tararuas

A little while ago, I blogged about the trip to Powell Hut. This post decribes an alternative trip into the Tararuas, from the Waiohine road-end into Totara Flats Hut. I found this trip much more challenging than the trip up the Gentle Annie track to Powell Hut, but at the...

Powell Hut, Tararuas

The Tararua ranges have a fearsome reputation in New Zealand. Frequently cloudy, snowy, rainy, misty, almost always windy, and very occasionally, sunny (though not to be trusted). Despite this bad rap, they are accessible, scenic, and have a broad range of trip options - from short dawdles through the bush...

Simple Ember CLI deploys

Note: I can’t vouch as to the best-practise compliance of this technique, but it’s worked well for me. One of the neat things about using a Javascript framework such as Ember.js is that you can host it just about anywhere you like - it’s just static files after all. My...

Walking the Waikaremoana

The Waikaremoana track is one of the Department of Conservation’s nine great walks, and is located in the Te Urewara area of the North Island, inland from the East Cape of the North Island of New Zealand. Recently, Te Urewera was one of New Zealand’s many National Parks, however a...

Multistep form validations with Rails and Wicked

Note: This blog post was originally posted at the Rabid Brains blog (my employer’s blog). Multistep forms are the bane of the developer’s existence. No matter how you cut it, the fact that multiple request/response cycles are required to create a single resource goes against the grain of a whole...

Coming or Going? The North American P-82

By United States Air Force [Public domain], via Wikimedia Commons This aircraft is literally two P-51 Mustangs banged together. I entirely appreciate the thinking behind taking a very successful platform together and doubling the awesome, but I can’t help imagining a number of entertaining scenarios in which a pilot in...

IFTTT, Grabaseat, and You: Getting the flights you deserve.

This guide covers setting up If This Then That to check for flights on Air New Zealand’s Grab a Seat service. If you’re not at all interested in cheap NZ air travel, this might not be for you. Grabaseat, Air NZ’s discount flights service, has got to be one of...

Sshhh...Secrets in Rails 4.1

With the recent release of Rails 4.1, has come a feature that I’ve really been looking forward to. That feature is automatic support for storing your application’s secrets in a YAML file. Whenever you have a repository of code, it’s a great idea to always work under the assumption that...

Keeping secrets in an Android Application

As a (mainly) Rails developer, I’m pretty accustomed to the need for secret keeping within a server-based application, and how it gets done (typically, config.yml’s and/or ENV variables). Getting into Android though, I’ve had the need to integrate with Parse to retrieve some simple data that I don’t want to...

I’m a minimalist. When it comes to web design, I value white space, typography and function. People come to your site for the writing, which is why a focus on these elements will almost always result in a good user experience. Adding non-essential elements to a page reduces signal and creates noise. — Sam Solomon

Very much inline with how I feel about design and UX in general.

Source controlling my toolkit

This morning, I created a new repository on Github called toolkit. I’m using it to keep track of the tools I use every day, in order to benefit others who are interested in how I work, and for my own benefit, to be able to easily refer to documentation, source...

Finding records by ID with Ransack

Ransack is one of my go-to Rubygems, especially for admin applications. It provides a really simple interface to building up complex filtering and ‘searching’ of many records. Check out the README for more information about how it all works - this post covers a specific problem case of Ransack. In...

The curses of proprietary technologies

As a web developer, I’ve got a pretty good pick of websites - I know what companies are prepared to stick with tried and tested technologies, and combine it with just enough new stuff to make browsing their site pleasant and easy to do. Every now and then though, I’m...

HTML5 Notifications

On the Spot is a pet project that I tend to develop with bleeding-edge features in mind - something a bit more volatile than Latter, which is used heavily enough to justify a more cautious development process. In this post, I’m going to detail how I added HTML5 notifications to...

Secret Keeping with Rails

Ever needed to store some secrets in Rails that you don’t want to share with the world? Yeah, same! In this post, I’m going to outline a really simple way to store your application’s secrets in a file called config/secrets.yml. Rails configuration and you First of all, let’s discuss exactly...

Redesigning for readability - a retrospective

I’ll be the first to admit that I’m not that great at design, especially typography and detailed elements. I’m just one of those people who can see what they want in their heads just fine, but something just goes…wrong…between the head and the page. In this post, I’m going to...

Process configuration management with Foreman

Often in the Rails projects I build, I have a need to store configuration that I don’t really want to have in my code. The most obvious way to do this is to either store the configuration in a YAML file (e.g. config/settings.yml), or in environment variables. Foreman is Heroku’s...

Building On-The-Spot: A Spotify play queue

About the Application The idea behind On the Spot was to allow everyone in the office at work to control the playlist, so that there was some semblence of fairness about what we listen to. Probably the simplest way of showing you what it is is to see some pictures,...

VirtualBox Debians with additional adapters

I get stung by this one all the time, and I can never remember how I fix it. I’m noting it down here, in the hope that next time I’m googling for a fix I’ll stumble across my own blog post. Adding network adapters (or refreshing the MAC address) of...

Whakamāori te Latter

Introduction I’ve spent the last week translating Latter (really badly) into Māori using Rails’ I18n support. Since this is the first time I’ve done a full site translation, I wanted to detail how I did this here. First, I’ll quickly explain how Rails I18n support works. Essentially, it’s a key-value...

Compiling with Homebrew without XCode

I’m a big fan of not installing XCode on new Macs. I just don’t think it’s necessary, unless you’re genuinely building OS X or iOS applications. Instead, I prefer to download the [Apple Command Line Tools] straight from Apple’s Developer Center, and install everything else I need to with Homebrew....

Sublime Text 2: Do not reopen files

For quite some time now, I’ve been using alloy’s fork of Macvim as my primary editor, along with janus, and it’s been working out really well. I’ve just started trying out Sublime Text 2 though, and it’s been pretty nice (although I still have reservations). Something I can’t stand in...

Document your code with Tomdoc

Documentation in Ruby on Rails apps tends to be somewhat of a hit-and-miss affair, particularly within non-product organizations. In this blog post, I’ll run through how Tomdoc has helped my code become clearer and easier to maintain, with very little overhead. First, a small explanation about Tomdoc. It is effectively...

Import Trello cards from a CSV file

This morning I wrote a quick script that I found quite handy - it takes a CSV file, and adds cards to Trello from it’s contents. At 3months, we quite regularly get long spreadsheets with requirements, so this script saves us a lot of time when we need to import...

Jekyll Content Liquid Tags

For the last week after deploying my new blog to joshmcarthur.com instead of a ‘blog’ subdomain, and implementing a new design and back-to-basics blogging engine, I’ve noticed that my markdown wasn’t being parsed properly (/at all). Originally this was hard to spot - my posts had been migrated from Blogger,...

Bootstrap Tablesorter Styles

When Twitter Bootstrap first shipped, it came with a couple of handy integrations with external jQuery plugins. Once of the more popular of these integrations was styles that were compatible with the classes, elements and attributes added by jQuery Tablesorter. Recently, however, these integrations have been removed from Bootstrap, as...

Git-browse for Quick Repo Viewing

Last night I quickly patched together a command called git-browse - it’s a small but handy extension to git that looks at the remotes you have set up inside a repository, and opens up the first Github repository it finds - to give an example: -> git remote -v origin...

Treatme Lite: Part One - the Backend

The Backend This article first is in a series of three blog posts documenting how I created TreatMe Lite, an HTMl5 web app using Zepto.js, Coffeescript, and a range of other frameworks and tools, all backed by an Express JS web service. See my previous post for more information about...

Treatme Lite: Adventures in Javascript

For a long time, I’ve been looking to move into the NodeJS trend that’s been taking the development community by storm. The problem is that coming from a Rails development background, and my inability to follow callbacks through more than 2 levels, has lead to my previous efforts to end...

Upcoming: RateMyCourses

Tonight I’d like to talk about a project I’ve been working on in my spare time for the last few months. I’m super excited to see it coming together, and it’s nearly ready to go live. The application is called RateMyCourses - put simply, it’s a way for University students...

Add jQuery to Any Page Really, Really Easily

When I’m working on a site, or analysing somebody else’s, I often wish that jQuery was loaded into that page - it’s an unbeatable tool for really digging into the site’s source to debug something or work out how something has been done. To help out with this, I’ve put...

Generating 'Gem Install' Commands From 'Gem List'

Here at 3Months, we have a couple of monolithic projects that have been around for yonks - because of this, they don’t have bundler set up, and many of them have incomplete or out-of-date gem requirements. Yesterday I needed to get one of these projects set up locally for the...

A Fun Little Bookmarklet

I’m sure this has been done before, but after noticing 1-day’s ‘Look Busy’ feature, I just had to write a bookmarklet to load this up on any site! If you just want to try it out, here’s the link Look Busy Bookmarklet - either right-click on the link and ‘Copy...

Safely Start and Stop VirtualBox VMs with init.d

Recently I’ve rolled out a virtual machine host box to run headless VMs (headless means that there is no display, keyboard etc plugged into it), as these make great test and experiment machines for trying new things out. As part of this rollout, I mashed a couple of blogs and...

Action Mailer Interceptors

ActionMailer Interceptors are a great way to test the full stack of your mailing in Rails from the generation from data through to receiving the email in your client. They are similar to ActiveRecord’s before_x-type callbacks, and let you change something about the message being sent right before it’s actually...

Overriding Action Caches

Recently, I have been working on a web application that is quite media rich, and is expected to run into quite a bit of traffic. I’ve been working on building an API for a front end system, using JSON to handle passing this data back and forth. Obviously with this...

Howto: Database Backup and Restore

An inherent part of developing web applications is managing your datastores - typically, a relational database such as MySQL or PostgreSQL. Today, I’m going to quickly cover off how to backup and restore for both of these databases. What you’ll need Either PostgreSQL or MySQL Access to a database (preferably...

Introducing Blog Broadcaster

I’ve just completed a Blog Broadcaster for this blog. It had a couple of interesting technical things, and I needed to test it properly, so here’s this post! I recently migrated this blog from Tumblr, and while Tumblr was pretty awesome and easy to use, it didn’t have great support...

Select Anything From Everything with Select

I was recently called upon to make a horrible select input for a Ruby on Rails project - essentially, there was this model, let’s call it a Snafu, and one Snafu could share an attachment to any number of models. This select was difficult because I couldn’t just have a...

Capistrano rvm-shell: command not found error

I’ve just come across this problem, and I had to share it here - I can’t find anywhere else on the the Internet where the solution is specifically stated - it’s just alluded towards. If you are using RVM’s Capistrano integration, you may come across a CommandNotFoundError to do with...

Achievements on Coderwall

Well, it’s taken weeks for Coderwall to finally get it’s crawler to hit my Github Profile, but I’ve finally got more badges. I’ve been moving some old PHP stuff of mine onto Github for people to use, so that’s where I’ve gotten the PHP badge from. As part of my...

Arbitrary Ordering in PostgreSQL when Rails + ENUM = No.

I’ve recently had to do a custom sort for a work project that has required a sort on something that is not naturally sortable correctly (For example, alphabetical or numerical sorting). While searching for a completely different solution, I came across this post that outlined a nice technique. Basically, when...

Quick: Clear Gemset

If you’re finding that you have to change something fairly significant in your bundler dependencies, it’s usually a good idea to get rid of what you’ve got loaded in an RVM gemset so that you don’t end up with different versions of gems fighting with each other. To do this,...

The Dictionary of New Zealand Sign Language

The Dictionary of New Zealand Sign Language went live on Friday - it’s a project that I have worked on with Daniel, Chris and James R, at 3Months. I attended a launch event at Victoria University on the Friday, and it really was quite a humbling experience - this dictionary...

'Password' or 'Passphrase'

So apparently pass phrases are the new ‘secure password’ - kinda the step you get to when you finally accept that your users are going to use something like ‘password’ for their account password. The natural step here is to reinforce a secure password strategy by requiring x numbers, x...

Rails HABTM relationships on a non-standard connection

Recently, I’ve been implementing an admin interface for a system that I want to make more secure than the main application. The way I’ve chosen to do this is to run some models that relate solely to the admin application (Authentication and Authorization in particular), on a different database -...

Quick: .rvmrc

This post is probably something more experienced RVM users will already know, but I wanted to post this as it’s definitely my discovery of the week. When throwing an .rvmrc file into a project, it’s a nice thing to do to write the script correctly so that it will just...

Ubuntu: Quick ImageMagick Install

This is cross-posted from a tweet I posted a while back - I think it’s a nice bit of advice, and I wanted to store it in a more persistent form Installing ImageMagick is one of the things that Rails developers need to do reasonably often when provisioning new servers...

Integration tests with Devise and RSpec

RSpec 2 has supported integration tests for a while now, and I’ve chosen to use these for a project I’m working on at the moment instead of Cucumber (I don’t feel that I need the verbosity and English-like structure Cucumber provides given that it a more complex process to write tests)....

Quick: Get random record efficiently in Rails

You could use SQL’s random function (RAND() or RANDOM() depending on database engine) - but this isn’t database agnostic, so isn’t really very quick. Instead you can use @nzkoz’s suggested method: Widget.first(:offset => Widget.count) …. the count() method is fast, and the first() method will limit it to the first...

ImageMagick: Cropping then Resizing a PNG

I’ve been working on an image processor class for work, and recently ran into this issue. I thought I would post it up here as normally I need to be quite desperate before I start trawling through email mirrors - hopefully somebody comes across this post first. If you use...

Using setInterval to handle scroll() events

I’ve just added a nice unobtrusive scroll to top feature to my blog, and learnt an interesting tip in the process I thought I would share, originating from one of the many problems Twitter has had with it’s jQuery fanciness. The scroll to top stuff isn’t overly complicated - just...

Accessing controller instance variables in model (Urgh?)

I can tell that this title alone will irritate a lot of developers out there. It irritated me as well, until I figured out that sometimes, doing things the ‘wrong’ way is the best/only way. But let me get on with things. Every now and then, you will come across...

I18n ALWAYS escapes dots in chained backends :-(

Just a quick tip I’ve come across while browsing through the comments on a Railscast_I’ve_been_watching. It looks like the I18n gems that get automatically installed with Rails 3 have a teensy bug. When storing a translation to the backend (be it YAML, Redis, whatever), there is an :escape option that...

Spree Hosted Gateway

Spree Hosted Gateway is my second ‘big’ extension - one of the ones that isn’t just adding one or two bits of nice functionality, but actually and end-to-end solution to add something that I think would be useful to a broad range of Spree developers (My first was spree-import-products, see...

Running Rake tasks with Cron (RVM)

Recently I’ve had to deal with a strange problem with rake tasks being run using Cron, a UNIX tool for running commands on a scheduled basis. The problem was basically the server being slowly strangled of resources across a forty to fifty minute time period, as each time the rake...

OK, So I Was Wrong

OK,_So_I_Was_Wrong So I was just flipping through my archives of blog posts, when I found this_one - my first ever post to Tumblr, where I vowed to stop posting enormously long essays on silly ideas I have to change the world. Oops. Sorry everyone!

Dynamically Serving Inline Images with Rack

Following an insanely interesting presentation by Steve Souders at Webstock, I began thinking about ways to simplify (i.e. automate) certain processes to optimize performance of sites. Something that immediately jumped out at me from early on in Steve’s workshop (So early, I was able to start coding in the halfway...

Creating a Scalable Academic Signup System

While working at 3Months as a developer, I am also completing a Bachelor of Business Information Systems at Victoria University. One of the things that rolls around twice a year and always causes students headaches is the signups system - it’s one of the bragging points of the School of Information...

Radiant as a Service-delivery Platform

Tonight I’ve been playing round with Radiant - it looks really impressive as a content-management system, and I’ve been thinking about ways I can change it round to support vendors - that is, one person or organization offering Radiant as a service to multiple clients - basically, it would be...

So I decided this evening to devote a couple of hours to giv...

So I decided this evening to devote a couple of hours to giving back to Spree, after using the framework for a couple of work projects, and appreciating it for it’s flexibility and extensibility.  I’ve developed an extension for Spree called Import Products. The source is based on a few...

RVM, Ruby-Debug, and hours of frustration

Every now and then, you run into one of THOSE problems - inexplicable, and something it seems no one else has solved before you. This afternoon, I hit one of these. Basically, I had just installed RVM, Ruby_1.8.7 and Rails_2.3.8 - everything was working great - I could run a...

Rubbish Domain Names

Finding appropriate domain names is a chore. There are so many rubbish parking sites out there that just … shouldn’t be. I dare sayjoshmcarthur.me could be considered one of them, since I could easily offload this onto Tumblr, but I enjoy having the unlimited capabilities a hosted site allows. I...

Time Problems

Fixing time problems is probably one of the most satisfying things to fix programmatically for me. It is one of those things where you may spend ages stabbing in the dark with different time zones, formats, etc etc. - but there it really is satisfying when you do get it...

Interesting Ideas

As part of my research for my last-minute essay rewrite, I happened to pick up an article covering an interview with David_Heinemeier_Hansson, partner at 37signals.com and inventor of Ruby_on_Rails. Hansson had some very interesting ideas, including the concept of reducing working hours in favour of creative quality, and the value...

A handy tip

Just FYI… See 2 posts ago - I am modifying this theme to make it work a bit nicer. Part of this included wanting to change some images. I was trying to just link to the images in CSS, but I found a much nicer way of doing it. If...

My new look...

Do you like my revamped theme? I think it’s totally cool to have this type of timeline in a microblog like Tumblr - it makes things really easy to flip through… don’t you want to keep pressing the arrows? It’s this_theme, but I tweaked the CSS a bit and added...

Here's how this works...

Right team, listen up. See, I’m quite a lazy blogger - it’s just too much effort, and it never seems to be shiny enough (Just check out my old_blog out for proof. I’m going to make this easy for all of us - I’ll find cool stuff on the Internet,...