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
View watchr.rb
require 'growl'
require 'open3'
ENV["WATCHR"] = "1"
$spec_cmd = "rspec --tty --drb --colour --format nested"
$cuke_cmd = "cucumber --color --drb --require features/step_definitions --require features/support"
$pass = File.join(File.expand_path(File.dirname(__FILE__)), '.watchr_images', 'pass.png')
$fail = File.join(File.expand_path(File.dirname(__FILE__)), '.watchr_images', 'fail.png')
$pending = File.join(File.expand_path(File.dirname(__FILE__)), '.watchr_images', 'pending.png')
View spec.rb
scenario "have ability to edit profile", :js => true do
@ability.should be_able_to(:edit, @profile)
View example.feature
Scenario: confiming when saving inactive
Given I expect to click "OK" on a confirmation box saying "Are you sure?"
When I press "Save"
Then the confirmation box should have been displayed
And I should see "TV" in the "Campaign Keywords" section
Scenario: alert when form is not valid
Given I expect to click on an alert box saying "Please complete all fields in this form"
When I press "Save"
View Gemfile
gem 'spork', '~> 0.9.0.rc'
View qunit_test.js
test('calculator can perform basic operations', 2, function() {
var calc = new Calculator();
equals (calc.sum(5,10), 15, 'Simple addition');
equals (calc.multiple(5,5), 25, 'Simple multiplication');
test('AJAX addition operation', 2, function() {
stop(5000); // wait for up to 5 seconds
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 / drag.js
Created Jul 9, 2011
Drag and drop example for Titanium
View drag.js
var circle = Titanium.UI.createView({
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 / swipe_detection_example.js
Created Jul 20, 2011
swipe detection example for Titanium
View swipe_detection_example.js
var movementHistory = {
pointAndTimeHistory: [],
set: function(point) {
// add this point into the point and time history for velocity calculations based on time & distance
time: new Date().getTime(),
x: point.x,
y: point.y
mattheworiordan / value_for_undefined_key.js
Created Jul 29, 2011
Use case for valueForUndefinedKey error raised on simple close call to Window
View value_for_undefined_key.js
var win = Titanium.UI.createWindow({
fullscreen: true,
backgroundColor: '#666',
url: 'value_for_undefined_key_subwindow.js'
win.addEventListener('ready', function() {
// win.close causes an error only if called immediately after window is created