Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

function(keys, values, rereduce) {
if (rereduce) {
var result = [];
values.forEach(function(valueGroup){
valueGroup.forEach(function(value){
result.push(value);
});
});
return result;
} else {
#RVM settings
if [[ -s ~/.rvm/scripts/rvm ]] ; then
RPS1="%{$fg[yellow]%}rvm:%{$reset_color%}%{$fg[red]%}\$(~/.rvm/bin/rvm-prompt)%{$reset_color%} $EPS1"
fi
ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[green]%}["
ZSH_THEME_GIT_PROMPT_SUFFIX="]%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}*%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN=""
(defun ruby-send-region (start end)
"Send the current region to the inferior Ruby process."
(interactive "r")
(let (term (file (buffer-file-name)) line)
(save-excursion
(save-restriction
(widen)
(goto-char start)
(setq line (+ start (forward-line (- start)) 1))
(goto-char start)
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}" # => ?
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}"
@senny
senny / gist:736331
Created December 10, 2010 15:25
Terminal Setup
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'
@senny
senny / save_failed_scenarios.rb
Created December 28, 2010 09:02
Cucumber support file to save the source of failed scenarios into the tmp folder
# 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?
# 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
@senny
senny / git konfiguration
Created October 11, 2011 13:37
git configuration
# .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'
@senny
senny / Screencast being a Value.rb
Created January 7, 2012 11:26
0047 - brittle and fragile tests
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)