Skip to content

Instantly share code, notes, and snippets.

View simongregory's full-sized avatar

Simon Gregory simongregory

View GitHub Profile
@simongregory
simongregory / promised-event-with-timeout.js
Created June 21, 2017 13:37
Wrap a Javascript event in a Promise with a time out.
function waitForEventWithTimeout(emitter, eventName, timeout) {
return new Promise((resolve, reject) => {
let timer;
function listener(data) {
clearTimeout(timer);
emitter.removeEventListener(eventName, listener);
resolve(data);
}
@simongregory
simongregory / chmodattr.sh
Created November 24, 2016 11:19
chmod extended attributes on os x
# Use -e to describe
ls -el
#ie:
#-rw-r--r--+ 1 simon staff 25063 14 Nov 20:32 index.html
# 0: group:everyone deny delete
# 1: group:admin allow read,readattr,readextattr,readsecurity
# Then recursively remove with
chmod -R -a "group:everyone deny delete" .
@simongregory
simongregory / build-electron-projects.sh
Last active April 13, 2016 17:09
Building Electron and it's upstream projects with widevine support
#!/usr/bin/env bash
echo 'WARNING: This script for documentation. Follow the steps it details as some are manual.'
exit 0;
# Before you start fork libchromiumcontent, brightray and electron. Brightray isn't strictly
# necessary as we patch it manually, but at some point it will need to be addressed.
GITHUB_USER=simongregory
#!/usr/bin/env ruby -wKU
file = ARGV[0]
unless File.exist?(file)
puts "Where's the list of films?"
exit
end
df = IO.readlines(file)
@simongregory
simongregory / gist:5773922
Last active December 18, 2015 11:09
bump plugin spec
var mp = $('#player').player({
product: 'iplayer',
playerProfile: 'smp',
playlist: 'http://www.bbc.co.uk/iplayer/playlist/p00dxtxf',
responsive: true,
mediator : {
'host' : 'open.live.bbc.co.uk'
},
plugins : { toLoad : [ { swf:"swf/tip.swf"} ] } }
});
@simongregory
simongregory / stub_server.rb
Created November 6, 2012 15:26
A quick stub server using Webrick
require 'webrick'
stats_calls = 0
#http://microjet.ath.cx/webrickguide/html/
s = WEBrick::HTTPServer.new(
:Port => '4579',
:BindAddress => 'localhost',
:Logger => WEBrick::Log.new('/dev/null', WEBrick::BasicLog::DEBUG),
:AccessLog => [nil,nil]
@simongregory
simongregory / gist:3859469
Created October 9, 2012 15:18
yielding a mock to a block
should "configure the Application with a consumer key and secret" do
credentials = {'consumer_key' => 'skeleton', 'consumer_secret' => 'closet'}
config = mock()
config.expects(:consumer_key=).with('skeleton').once
config.expects(:consumer_secret=).with('closet').once
service = mock()
service.stubs(:configure).yields(config)
@simongregory
simongregory / tm2_rvm_as3.md
Created August 16, 2012 10:30
TextMate 2, rvm, and the ActionScript 3 bundle playing together

Get TextMate 2, the ActionScript 3 bundle and RVM playing together

For full completion functionality - where swcs are included when searching for the completions results - you need to have the 'nokogiri' and 'rubyzip' gems installed. The default ruby shipping on OS X is 1.8.7 so the easiest solution is to switch to the system default ruby and install the nokogiri and rubyzip gems there.

However the following should also work....

Assuming that

TextMate 2, rvm (with ruby 1.9.3 installed) and the AS3 bundle are installed on your machine and when you try to autocomplete an error gets thrown.

@simongregory
simongregory / SignalGuard
Created April 27, 2012 08:40
fluidly building a signal guard
package bbc.core.guard
{
public class SignalGuard
{
public function fire(signal:ISignal):SignalGuard
{
_destination = signal
return build()
}
@simongregory
simongregory / .tm_properties
Created January 3, 2012 13:42
home ~/.tm_properties settings
fontName = "Andale Mono"
fontSize = 12
spellingLanguage = 'en_GB'
[ .git/COMMIT_EDITMSG ]
spellChecking = true
spellingLanguage = 'en_GB'
[ *.{icns,ico,jpg,jpeg,m4v,nib,pdf,png,psd,pyc,rtf,tif,tiff,xib,giff,mp4,swf,fla} ]