Skip to content

Instantly share code, notes, and snippets.

anonymous
anonymous / gist:8712796
Created January 30, 2014 16:39
int dataPin = 2;
int clockPin = 3;
int csPin = 4;
byte chars[] = {
B00011000,
B00111100,
B01100110,
B11000011,
@lackac
lackac / 2_ways.md
Last active August 29, 2015 13:57
2 Ways to Decompose Fat ActiveRecord Models – budapest.rb 03/2014
module HashExtensions
def symbolize_keys
inject({}) do |acc, (k,v)|
key = String === k ? k.to_sym : k
value = Hash === v ? v.symbolize_keys : v
acc[key] = value
acc
end
end
end
@mikegehard
mikegehard / gist:954537
Created May 4, 2011 00:35
Waiting until all jquery ajax calls are done
//Useful if you have a slow CI server...
When /^I wait until all Ajax requests are complete$/ do
wait_until do
page.evaluate_script('$.active') == 0
end
end
@bonyiii
bonyiii / bash ctrl history search
Last active September 26, 2015 08:08
ctrl + up and ctrl + down in history
@rchampourlier
rchampourlier / gist:1079082
Created July 12, 2011 22:01
SystemV service startup script for a Ruby On Rails app with unicorn
#!/bin/bash
#
# app Rails application served through an Unicorn instance
#
# Author Romain Champourlier @ softr.li
#
# chkconfig: - 87 13
#
# description: This a web application developed in Ruby On Rails
# which is served through an Unicorn instance.
en:
errors:
messages:
wrong_content_type: "is the wrong content type"
@zosiu
zosiu / facebook_graph_api.rb
Last active January 10, 2017 16:23
Facebook Graph API w/ Koala
### app access token
graph = Koala::Facebook::OAuth.new APP_ID, APP_SECRET
graph.get_app_access_token # => APP_TOKEN
### create test users with permissions
test_users = Koala::Facebook::TestUsers.new app_id: APP_ID, secret: APP_SECRET
user = test_users.create true, 'email,user_birthday,user_posts', name: 'Bob'
# =>
# { "id" => USER_ID,
# "access_token" => USER_ACCESS_TOKEN,
@natritmeyer
natritmeyer / Usage.txt
Last active January 16, 2017 01:56
JUnit formatter for RSpec
NOTE: I've created a gem based on this: https://github.com/natritmeyer/yarjuf
---------
rspec my_spec.rb -r ./junit.rb -f JUnit -o results.xml
@mudge
mudge / unicorn.conf.rb
Last active February 9, 2017 21:55
Unicorn configuration for Rails 3.2 application to log to a different file per worker (to stop logs interleaving with one another).
after_fork do |server, worker|
# Override the default logger to use a separate log for each Unicorn worker.
# https://github.com/rails/rails/blob/3-2-stable/railties/lib/rails/application/bootstrap.rb#L23-L49
Rails.logger = ActiveRecord::Base.logger = ActionController::Base.logger = begin
path = Rails.configuration.paths["log"].first
f = File.open(path.sub(".log", "-#{worker.nr}.log"), "a")
f.binmode
f.sync = true
logger = ActiveSupport::TaggedLogging.new(ActiveSupport::BufferedLogger.new(f))