This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
def create_module(representation, &block) | |
parts = representation.split("::") | |
(0...parts.size).each do |idx| | |
const = parts[(0..idx)].join("::") | |
eval "::#{const} = Module.new unless defined?(::#{const})" | |
end | |
if block_given? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "ostruct" | |
class Bar | |
attr_reader :num | |
def initialize(num) | |
@num = num | |
end | |
def zoo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
render json: Resource.where(something: params[:something]).first_or_create do |r| | |
r.enabled = params[:enabled] | |
r.foo = params[:foo] | |
r.bar = params[:bar] | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main(int argc, char* argv[]) { | |
int a = 1; | |
a++; | |
printf("%d\n", a); | |
} | |
# => 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Message | |
MAX_LENGTH = 240 | |
... | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
migrate () { | |
local zeus_command="" | |
if _zeus-installed | |
then | |
zeus_command="zeus" | |
fi | |
$zeus_command rake db:migrate && $zeus_command rake db:rollback && $zeus_command rake db:migrate && $zeus_command rake db:test:prepare | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
trap("INT") { puts "\ncatch'ya later"; exit 0 } | |
output = `git for-each-ref --count=10 --sort=-committerdate refs/heads/ --format='%(refname:short)'` | |
branches = output.split("\n") | |
unless option = ARGV[0] | |
puts <<-MSG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <stdio.h> | |
#define too goto | |
int main( int argc, const char* argv[]) { | |
int times; | |
times = 0; | |
legit: | |
printf(" too legit,"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$cucumber_instance_variables = [] | |
Before do | |
$cucumber_instance_variables = instance_variables | |
end | |
After do | |
test_variables = instance_variables - $cucumber_instance_variables | |
message = "[WARN] the following test variables could be leaking #{leaked_variables.join(', ')}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include ActionDispatch::Routing | |
include Rails.application.routes.url_helpers |