Ruby 2.0.0 was released a few months back and I finally had some time to look into some of the features and changes that came with it. Lazy collections has always been a cool concept for me and so I decided to do a few benchmarks.

Often times, as programmers, we need to check to see if a substring exists in a bigger string. Many programmers will instinctively reach out for Regex matching, but I often wondered if this was really the best way to do things, particularly in Ruby.

One day, in a Ruby-focused Skype group chat, a friend of mine asked the other members to give him a snippet of code that would allow him to take a hostname, check if the substring ‘qa’ was in it and if it did, return ‘qa’, else ‘prod’ (for production). My knee-jerk reaction was the same as the other members: use Regex. But I wondered if it would be better to use compiled Regex, or interpreted Regex, or perhaps maybe even the built in String method include?. So I decided to do some benchmarking.

These days, theres a lot of focus on reducing the load times on your website to make the experience smoother for your users. One way is to make creative use of CSS to style your websites instead of using images. That said, there are times when you have to use images and even the best front-end guys need to reach for images depending on what kind of design they were tasked with implementing.

If you’re using PNGs, likely you’re already choosing to save them in a way that optimises them for the internets, but even then there are savings to be had by employing the use of lossy PNG optimisation.

Finally got a chance to play around with Padrino last week to build a Push to Devices notification server, but ran into a bit of an issue trying to get Resque-web / Resque server UI to show up.

Finally ran into this great blog entry. It’s written in Japanese so I decided to create a short version in English here in case anyone else runs into the same issue

If you already have the following:

config.ru
1
2
3
4
# snip
run Rack::URLMap.new \
  "/"       => Padrino.application,
  "/resque" => Resque::Server.new

in your config.ru and yet don’t see anything when you hit /resque on your local environment, run your server with

$rackup -p 3000

TL;DR If you’re using NodeJS and want to monitor using NewRelic, follow these steps. Additionally if you want to do this on Heroku using the NewRelic account you added through the Heroku API, make sure your package.json has “newrelic” and your newrelic.js points to the NEW_RELIC_LICENSE_KEY environment variable.

Last Friday, I set up a NodeJS push notification server for my current project. Essentially it was mostly inspired by this excellent blog post, but I updated it to use the latest NPM packages and to support sending notifications to all of a user’s open sockets as well as cleaning up on disconnect. That’s another story for another time.

This blog post will cover how to get NodeJS monitoring with NewRelic on Heroku.

TL;DR If you’re using Ruby, want to perform operations on the values of a hash only at specific locations in the hash, check out hash_walker

A while back I worked at a Tokyo-based startup focused on building a crowd-sourced translation platform. The great thing about Gengo was that we (and they still do) offered a translation API that allowed clients to integrate and thus order huge amounts of translations, receive translated content back via callbacks and do whatever it is that clients do with translated materials.

On one of the projects I worked on for a potential client, as part of a trial project, I needed to process a huge amounts (ok, not huge, maybe around 2000 or so) JSON responses and grab the data, throw it over the Gengo API and once it was translated, re-insert the translated content into the JSON responses and send all the JSON responses in text files to the client.