Skip to content

Instantly share code, notes, and snippets.

View mattheworiordan's full-sized avatar
💭
V. busy with Ably, building a great team 🚀

Matthew O'Riordan mattheworiordan

💭
V. busy with Ably, building a great team 🚀
View GitHub Profile
@mattheworiordan
mattheworiordan / capybara_webkit_screenshot_env.rb
Created August 19, 2011 12:26
Cucumber and Capybara-Webkit automatic screenshots on failure
def screen_shot_and_save_page
require 'capybara/util/save_and_open_page'
path = "/#{Time.now.strftime('%Y-%m-%d-%H-%M-%S')}"
Capybara.save_page body, "#{path}.html"
page.driver.render Rails.root.join "#{Capybara.save_and_open_page_path}" "#{path}.png"
end
begin
After do |scenario|
screen_shot_and_save_page if scenario.failed?
@mattheworiordan
mattheworiordan / corporate-cla.txt
Created June 18, 2018 08:57 — forked from open-sdsp-leader/corporate-cla.txt
Individual and Corporate CLA
Thank you for your interest in Open SDSP (the
"Open Specification") and Ably Real-time Ltd (the "Project Sponsor").
In order to clarify the intellectual property license granted with
Contributions from any person or entity, the Project Sponsor
must have a Contributor License Agreement (CLA) on file that has been
signed by each Contributor, indicating agreement to the license terms
below. This license is for your protection as a Contributor as well
as the protection of the Project Sponsor and its users; it does not
change your rights to use your own Contributions for any other purpose.
@mattheworiordan
mattheworiordan / by-country.csv
Created November 21, 2015 18:27
Ably realtime message - global pub/sub message latency in milliseconds (Nov 2015)
country min (ms) max (ms)
United Arab Emirates 128 207
Argentina 159 224.5
Austria 17 70
Australia 5 230
Belgium 15 73
Brazil 10 180
Canada 13 73.5
Switzerland 17 91
China, People's Republic of 80 244
@mattheworiordan
mattheworiordan / swipe_detection_example.js
Created July 20, 2011 10:24
swipe detection example for Titanium
var movementHistory = {
pointAndTimeHistory: [],
set: function(point) {
// add this point into the point and time history for velocity calculations based on time & distance
this.pointAndTimeHistory.push({
time: new Date().getTime(),
x: point.x,
y: point.y
});
@mattheworiordan
mattheworiordan / application.rb
Last active October 24, 2017 06:41
Cloudflare Middleware for Rails
# insert within your Application
config.middleware.insert_before(0, Rack::CloudFlareFixup)
@javascript
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"
@mattheworiordan
mattheworiordan / assign_locals_helper.rb
Last active June 30, 2017 16:55
Allow testing of locals when rendering Controllers
def assigns_local(key)
controller.instance_variable_get('@patched_locals')[key]
end
def patch_controller_render_to_support_locals(controller)
def controller.render(options = nil, extra_options = {}, &block)
[options, extra_options].select { |o| o.kind_of?(Hash) }.each do |option_hash|
if option_hash.include?(:locals)
@patched_locals = option_hash[:locals]
end
@mattheworiordan
mattheworiordan / consume-bunny.rb
Created February 3, 2017 04:23
Consume Reactor Queues from Ruby
require "bunny"
require "json"
require "securerandom"
QUEUE = "appId:queue"
VHOST = 'shared'
def consume
consumer_conn = Bunny.new(
hostname: "us-east-1-a-queue.ably.io",
@mattheworiordan
mattheworiordan / rabbitmqadmin.py
Created February 1, 2017 00:40
Rabbit MQ admin tool
#!/usr/bin/env python
# The contents of this file are subject to the Mozilla Public License
# Version 1.1 (the "License"); you may not use this file except in
# compliance with the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
# License for the specific language governing rights and limitations
Europe - Andorra
Asia - Dubai
Asia - Kabul
America - Antigua
America - Anguilla
Europe - Tirane
Asia - Yerevan
Africa - Luanda
Antarctica - McMurdo
Antarctica - Casey