Skip to content

Instantly share code, notes, and snippets.

@brianewing
brianewing / DUP
Created February 10, 2019 19:53
NI Assembly Salary Plus Expenditure by Party (Aptril 2017 - March 2018)
# Name - Salary - Expenditure - Total
[["Bradley, Maurice", 49500.0, 60580.37, 110080.37],
["Bradley, Paula", 49500.0, 66747.0, 116247.0],
["Buchanan, Keith", 49500.0, 61202.03, 110702.03],
["Buchanan, Thomas", 49500.0, 76984.56, 126484.56],
["Buckley, Jonathan", 49500.0, 11482.8, 60982.8],
["Bunting, Joanne", 49500.0, 63381.17, 112881.17],
["Cameron, Pam", 49500.0, 76676.94, 126176.94],
["Clarke, Trevor", 37537.5, 65933.83, 103471.33],
@brianewing
brianewing / animator.go
Created October 3, 2017 09:37
redshift server types
type Animator struct {
Strip *strip.LEDStrip
Effects []effects.Effect
Running bool
}
func (a *Animator) Run(interval time.Duration) {}
func (a *Animator) Render() {
@brianewing
brianewing / gist:7103939
Created October 22, 2013 16:41
Lock your Mac by pressing power button
Install "PowerBlock" (freeware) from this site: http://www.irradiatedsoftware.com/labs/
Choose "Run AppleScript when power button is pressed"
Make it run this AppleScript:
do shell script "open /System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/ScreenSaverEngine.app"
@brianewing
brianewing / fix.sh
Created September 19, 2013 21:41
fix postgres for @tommypalm
# stop postgres
pg_ctl -D /usr/local/var/postgres stop &&
# obliterate old postgres data
rm -Rf /usr/local/var/postgres &&
# fresh start..
initdb /usr/local/var/postgres -E utf8 &&
# start postgres
pg_ctl -D /usr/local/var/postgres start
@brianewing
brianewing / git-old
Created August 9, 2013 13:41
Git command for opening files from previous commits / other branches in your editor
#!/usr/bin/env ruby
unless ARGV.length >= 2
STDERR.puts "git old <commit/refspec> <file> [file2] ..."
Kernel.exit(1)
end
ref = ARGV.shift
ARGV.each { |f| `git show #{ref}:#{f} | $EDITOR` }
@brianewing
brianewing / gist:5735832
Created June 8, 2013 16:47
RSpec testing the parsing of various YML config options taking advantage of Ruby heredoc syntax with a block
# helper
def with_stubbed_yml_config(yml, &block)
# stub, yield, unstub
end
# in examples..
with_stubbed_yml_config(<<-YML) { url.should == 'http://test:5984' }
test:
@brianewing
brianewing / gist:3986912
Created October 31, 2012 13:04
Ruby bucket
# sometimes I just want a quick-and-dirty thing to shove attributes onto without caring.
class Bucket
def method_missing(*args)
prop = args.first.to_s.sub(/\=$/, '').to_sym
self.class.send :attr_accessor, prop
send *args
end
end
@brianewing
brianewing / extensions.coffee
Created April 28, 2012 13:05
CoffeeScript helpers
window?.exports = window # allows more conventional client-side 'exporting'
# nicer timeouts/intervals in coffeescript
exports.timeout = (ms, fn) -> setTimeout(fn, ms)
exports.interval = (ms, fn) -> setInterval(fn, ms)
@brianewing
brianewing / gist:2300335
Created April 4, 2012 10:50
Javascript symbol-to-proc
String.prototype.__defineGetter__('proc', function() {
var prop = this;
return function(obj) {
if(typeof obj[prop] == 'function')
return obj[prop]();
return obj[prop];
}
});
@brianewing
brianewing / timer.js
Created January 1, 2012 23:36
Timer - utility class for controlling intervals
function Timer(func, delay, start) {
this.func = func;
this.delay = delay;
this.running = false;
if(start) this.start();
}
Timer.prototype.start = function(delay) {
this.running = true;
return this.interval = setInterval(this.func, (delay || this.delay));