Skip to content

Instantly share code, notes, and snippets.

V. busy with Ably, building a great team 🚀

Matthew O'Riordan mattheworiordan

V. busy with Ably, building a great team 🚀
View GitHub Profile
mattheworiordan /
Created Aug 19, 2017
Heroku scheduled restarts
# Set up the Heroku scheduler to run this command every hour. See example setup at
# Requires env vars to be set in Heroku with `heroku config:set`:
# - HEROKU_APP_NAME: this is just the app name in Heroku, i.e. `heroku apps` will list all apps you have access to
# - HEROKU_CLI_USER: Once Heroku CLI is authenticated (, check `cat .netrc` (or `_netrc` on Windows),
# look for `login` under `machine`
# - HEROKU_CLI_TOKEN: As above, but use the `password` field
mattheworiordan / gist:1037984
Created Jun 21, 2011
Backbone patch to defer update method requests when new create requests are not complete on a model
View gist:1037984
(function() {
Backbone.Model.prototype._save =; = function(attrs, options) {
var that = this;
if (!options) { options = {}; }
if (this.savingNewRecord) {
// store or replace last PUT request with the latest version, we can safely replace old PUT requests with new ones
// but if there are callbacks from a previous PUT request, we need to make sure they are all called as well
_(['success','error']).each(function(event) {
// convert all callbacks to a single array of callbacks)
mattheworiordan / cli.rb
Created Jan 9, 2015
Thor with subcommands that work correctly with help
View cli.rb
#!/usr/bin/env ruby
require 'thor'
class SubCommandBase < Thor
def self.banner(command, namespace = nil, subcommand = false)
"#{basename} #{subcommand_prefix} #{command.usage}"
def self.subcommand_prefix
mattheworiordan / application.rb
Created Mar 28, 2014
CloudFlare IP Middleware for Rails to ensure HTTP_CF_CONNECTING_IP is used and the clients IP is correct within Rails
View application.rb
module RailsAppName
class Application < Rails::Application
# .... your settings
require "#{Rails.root}/lib/cloud_flare_middleware"
config.middleware.insert_before(0, Rack::CloudFlareMiddleware)
# ... your settings
mattheworiordan / Gemfile
Created Sep 7, 2011
Test PDF within Cucumber and Capybara
View Gemfile
# normal Gem dependancy declarations
# ...
group :test, :cucumber do
gem 'pdf-reader'
mattheworiordan / publish-with-idempotency-for-retries.js
Created Apr 18, 2019
Ably Idempotency for automatic retries by our SDKs
View publish-with-idempotency-for-retries.js
var rest = new Ably.Rest(key: ablyApiKey, idempotentRestPublishing: true);
var channel = rest.channels.get('example-channel');
channel.publish([{ data: 'payload' }]);
mattheworiordan / publish-with-client-supplied-id.js
Last active Apr 18, 2019
Ably Idempotency with client supplied message ID
View publish-with-client-supplied-id.js
var rest = new Ably.Rest(ablyApiKey);
var channel = rest.channels.get('example-channel');
channel.publish([{ data: 'payload', id: 'unique123' }]);
mattheworiordan / rate_limit.js
Created Jul 15, 2011
Rate limiting function calls with JavaScript and Underscore.js
View rate_limit.js
/* Extend the Underscore object with the following methods */
// Rate limit ensures a function is never called more than every [rate]ms
// Unlike underscore's _.throttle function, function calls are queued so that
// requests are never lost and simply deferred until some other time
// Parameters
// * func - function to rate limit
// * rate - minimum time to wait between function calls
// * async - if async is true, we won't wait (rate) for the function to complete before queueing the next request
mattheworiordan /
Last active Nov 26, 2018
Recommend a distributed system engineer we employ and earn yourself $3,000

Unfortunately we're finding it really hard to find good distributed systems engineers at Ably, a distributed realtime data delivery platform.

We know a lot of you out there probably know great people who love solving truly hard distributed problems with a distributed team of superb engineers.

If you know anyone who fits the bill, wants to work remotely and is based in Europe (or wants to work on-site in London), we'll give you $3,000 simply for the referral if we end up employing them.

Follow these steps to earn $3,000 for one minute of your time:

  1. Contact the people you think are suitable for our Distributed Systems Engineer role and tell them to apply on that page
  2. Email us at with the name or
mattheworiordan / drag.js
Created Jul 9, 2011
Drag and drop example for Titanium
View drag.js
var circle = Titanium.UI.createView({