This file contains hidden or 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 | |
current_branch = `git symbolic-ref --short HEAD`.chomp | |
if current_branch != "master" | |
if $?.exitstatus == 0 | |
puts "WARNING: You are on branch #{current_branch}, NOT master." | |
else | |
puts "WARNING: You are not on a branch" | |
end | |
puts |
This file contains hidden or 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 'delegate' | |
class BasicDecorator < SimpleDelegator | |
def self.decorate(objects) | |
case objects | |
when Array | |
objects.map { |object| new(object) } | |
when ActiveRecord::Relation, DecoratedListProxy, ActiveRecord::Associations::CollectionProxy | |
DecoratedListProxy.new(self, objects) | |
else |
This file contains hidden or 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 ThisWorks | |
def self.const_missing(*args) | |
p "yay!" | |
end | |
NonExistingConstant | |
end | |
this_does_not_work = Class.new do | |
def self.const_missing(*args) |
This file contains hidden or 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 'integration/spec_helper' | |
class Article | |
include Virtus | |
attribute :title, String | |
def title | |
super || '<unknown>' | |
end |
This file contains hidden or 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 Screencast | |
attr_accessor :versions | |
def initialize(params) | |
params.each {|key, value| self.send "#{key}=", value } | |
end | |
end | |
class ScreencastCategories | |
def self.by_tool(screencasts) |
This file contains hidden or 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
# .gitconfig | |
[format] | |
pretty = %C(yellow)%h%Creset%C(green)%d%Creset %s %C(red)[%an]%Creset %C(cyan)[%cr]%Creset | |
# .bashrc / .zshrc | |
alias gg='git log --graph' |
This file contains hidden or 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
# Routes | |
# To prevent too deep nesting, we make the show, edit, update and destroy actions not nested under the category. We have a lot of models nested inside the product. | |
resources :category do | |
resources :products, :only => [:new, :create, :index] | |
end | |
resources :products, :only => [:show, :edit, :update, :destroy] | |
# ProductController | |
# We need to expose :category, :products and :product |
This file contains hidden or 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
# Hook to save the html page of every failed scenario into the temp | |
# file directory taht it can be checked after cucumber has finished running. | |
require 'fileutils' | |
require 'capybara/util/save_and_open_page' | |
FAILED_SCENARIO_PAGES_PATH = File.join Rails.root, 'tmp', 'failed_scenarios' | |
FileUtils.rm_rf FAILED_SCENARIO_PAGES_PATH | |
After do |scenario| | |
if scenario.failed? |
This file contains hidden or 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
alias g='git' | |
alias gm='git merge' | |
alias gmf='git merge --ff-only' | |
alias gs='git status' | |
alias gl='git pull' | |
alias glr='git pull --rebase' | |
alias gf='git fetch' | |
alias gp='git push' | |
alias gd='git diff' | |
alias gc='git commit -v' |
This file contains hidden or 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
GC.disable | |
objects = ObjectSpace.count_objects | |
start = objects[:TOTAL] | |
puts "objects: #{start}" # => 9811 | |
1_000_000.times do | |
"I am a lonly" + " concatenated" + " string" + "." | |
end | |
end_objects = ObjectSpace.count_objects(objects)[:TOTAL] | |
puts "objects: #{end_objects}" | |
puts "difference: #{end_objects - start}" |