Skip to content

Instantly share code, notes, and snippets.

View adambird's full-sized avatar

Adam Bird adambird

View GitHub Profile
@adambird
adambird / apis_berlin_schedule.csv
Created April 25, 2015 12:31
Speedhack Berlin 2015
Thursday Apr. 23 total left
5pm-7pm? Birds of a Feather Location TBD venue space is not available Keynotes 7 4 we could really add more keynotes and less fireside chats or the opposite
7:30 - ?? Speakers Dinner Location TBD Panels 3
Fireside chats 2 1
Friday Apr. 24 Type Session speakers 27
08.15-9.00 Coffee & Registration 1.5h Workshops 4 (looking if we can make it 6)
9-9.10 Opening Remarks Main Stage
9.10-9.35 Keynote 1 Main Stage Sebastian Ceve / Guardian Topic idea
9.35-10.00 Keynote 2 Main Stage eCommerce
10.00-10.25 Keynote 3 Main Stage Mandy Whaite / Google embeded systems
@adambird
adambird / gist:5867426
Created June 26, 2013 13:37
Code to add user email as custom variable to analytics
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'analytics-profile-id']);
<% if current_user %>
_gaq.push(['_setCustomVar', 1, 'UserEmail', '<%= current_user.email %>']);
<% end %>
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
@adambird
adambird / random.rb
Created May 15, 2013 07:49
Methods for generating randomised variables for testing purposes
def random_string
(0...24).map{ ('a'..'z').to_a[rand(26)] }.join
end
def random_symbol
random_string.to_sym
end
def random_integer
rand(9999)
@adambird
adambird / gist:5509602
Created May 3, 2013 14:53
Example class method to generate boiler plate methods for a complex attribute of an object. Primary use case is for use by a web form.
module ClassMethods
def address_attribute(name)
define_method(name) { instance_variable_get("@#{name}") }
define_method("#{name}=") { |value| instance_variable_set("@#{name}", value) }
define_method("_get_init_#{name}") { instance_variable_get("@#{name}") || instance_variable_set("@#{name}", BunchCore::Address.new) }
[:street_one, :street_two, :town, :county, :country, :post_code].each do |m|
define_method("#{name}_#{m}") { send(name) ? send(name).send(m) : nil }
@adambird
adambird / fizzbuzz.rb
Created March 18, 2013 20:30
After hearing today that we using Fizz Buzz in our dev interview process I thought I'd better have a go. Here's my attempt at finding the first 100 Fizz Buzz numbers with tests. So should I get through this stage?
class FizzBuzzNumber
def initialize(value)
@value = value
end
def to_s
out = []
out << "fizz" if @value % 3 == 0
out << "buzz" if @value % 5 == 0
out.length > 0 ? out.join(" ") : @value.to_s
-----BEGIN CERTIFICATE-----
MIIFMzCCBBugAwIBAgIDCOaNMA0GCSqGSIb3DQEBBQUAMDwxCzAJBgNVBAYTAlVTMRcwFQYDVQQKEw5HZW9UcnVzdCwgSW5jLjEUMBIGA1UEAxMLUmFwaWRTU0wgQ0EwHhcNMTIxMDI1MDc0NzIzWhcNMTMxMDI4MTQyNzMyWjCBvjEpMCcGA1UEBRMgaDZkdnRhSDY2OWd2THhYVzJRM1Y5SlJ0U3BmRHh0OC0xEzARBgNVBAsTCkdUNzg3MzgwMjExMTAvBgNVBAsTKFNlZSB3d3cucmFwaWRzc2wuY29tL3Jlc291cmNlcy9jcHMgKGMpMTIxLzAtBgNVBAsTJkRvbWFpbiBDb250cm9sIFZhbGlkYXRlZCAtIFJhcGlkU1NMKFIpMRgwFgYDVQQDDA8qLmV2ZW5pdHJvbi5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC8HJOXhGKT6OYeIjRMCZGgrmpRyX1sqrNFJrph12Emv7Dmdw0M4ptQ1RgkB9EFYOt8UcxfnNg3MQ3/+wt1p6IUuQAHW2gyD16HxutXiIF93an4w7SCPMunjRtRwzgqyMt1vyA2vmtotlVTeTZDP5A6V/n3dyK88tsvvZtFIEleT7B+7mikF3jH00SvbvVBo6Fn8oUpb6zTF0WyQfvCkQaqroV2ol20Pv6xNi/Ob9L9s7hUN41jwmcJAQuCLLgCZVnFZ80rQWD1dMgmPmLAwCNi8wOYLVB3nbO31cR9bqKvh1z5CaHxXFjtEcWtvAGUYr4HwJDhB+AJP9OTHYzrs8jfAgMBAAGjggG5MIIBtTAfBgNVHSMEGDAWgBRraT1qGEJK3Y8CZTn9NSSGeJEWMDAOBgNVHQ8BAf8EBAMCBaAwHQYDVR0lBBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMCMCkGA1UdEQQiMCCCDyouZXZlbml0cm9uLmNvbYINZXZlbml0cm9uLmNvbTBD
@adambird
adambird / throttle.rb
Created October 10, 2012 11:05
Describing a throttling approach for inbound messages
class WorkAllocator
BUCKET_SIZE_SECS = 5
def allocate_task_to_bucket(system_id, task, received_at)
if bucket = get_bucket_for_task(system_id, received_at)
bucket.put task
else
# discard task
end
@adambird
adambird / gist:3734038
Created September 16, 2012 19:35
Simple one-liner to pipe out Heroku app config for copying to another app
heroku config --shell | grep '<filtering pattern>' | tr '\n' ' '