Skip to content

Instantly share code, notes, and snippets.

@opsb
opsb / gist:3868009
Created October 10, 2012 19:56
Standard database.yml
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
function say(phrase, language){
return function(callback){
console.log("saying " + phrase);
var audio = new Audio("http://tts.lingal.org/?tl=" + language + "&q=" + phrase);
audio.addEventListener('ended', wrapped(callback));
audio.play();
}
}
Lingal.SayItPlayer = Ember.View.extend({
game:null,
didInsertElement:function(){
queue = async.queue(function(job, next){
job(next);
}, 1);
function wrapped(callback){
module Reports
module CauseCumulativeCommission
extend self
def build(name, cause, opts=ReportOptions.new)
{
:name => name,
:columns => [['date', 'Date'], ['number', cause.name]],
:rows => begin
(opts.start_date..opts.end_date).step.inject([]) do |rows, date|
@opsb
opsb / gist:4217071
Created December 5, 2012 16:19
Fizzbuzz golf
(1..100).each do|n|
text = "Fizz" if n % 3 == 0
text = "#{text}Buzz" if n % 5 == 0
puts text || n
end
@opsb
opsb / Bash function to extract regex match or specified group
Last active December 10, 2015 08:38
Capture regex group from each line in STDIN
function regex { gawk 'match($0,/'$1'/, ary) {print ary['${2:-'0'}']}'; }
@opsb
opsb / Bash function to decode STDIN
Created December 29, 2012 20:57
URL decode input
function decode { ruby -e 'require "cgi"; while gets; puts CGI::unescape($_); end;'; }
@opsb
opsb / gist:5214214
Created March 21, 2013 16:02
VCR config for spinach
VCR.config do |c|
c.cassette_library_dir = 'features/vcr_cassettes'
end
Spinach.hooks.before_scenario do |scenario|
cassette_name = "#{scenario.feature.name.parameterize.underscore}/#{scenario.name.parameterize.underscore}"
VCR.insert_cassette(cassette_name, :record => :once)
end
Spinach.hooks.after_scenario do |scenario|
@opsb
opsb / Gemfile
Last active December 23, 2015 11:29
Ruby bing search API
gem 'https://github.com/archiloque/rest-client'
var getData = function(callback){
showLoadingScreen();
$.ajax("http://someurl.com", {
complete: function(data){
hideLoadingScreen();
callback(data);
}
});
};