Get Homebrew installed on your mac if you don't already have it
Install highlight. "brew install highlight". (This brings down Lua and Boost as well)
#!/usr/bin/env zsh | |
# | |
# Works best with blinking text; the last heart will blink | |
# when you have less than 25% of your battery life remaining. | |
BATTERY="$(pmset -g ps | awk 'NR==2' | perl -pe 's/.*?(\d+)%.*/\1/')" | |
if [[ $BATTERY -lt 25 ]]; then | |
echo "\e[5;31m♥\e[0;31m♡♡\e[0m" | |
elif [[ $BATTERY -lt 50 ]]; then |
prune_merged() { | |
# TODO: Test for origin/master vs. master instead. | |
test -n "$1" && prune_merged_remotes $@ || prune_merged_local | |
} | |
prune_merged_local() { | |
git branch --list --merged | | |
grep --invert-match --extended-regexp '\*|master' | | |
xargs -n 1 git branch --delete | |
} |
diff --git a/array.c b/array.c | |
index 64647c3..618d9e3 100644 | |
--- a/array.c | |
+++ b/array.c | |
@@ -255,15 +255,24 @@ rb_ary_modify(VALUE ary) | |
rb_ary_modify_check(ary); | |
if (ARY_SHARED_P(ary)) { | |
long len = RARRAY_LEN(ary); | |
+ VALUE shared = ARY_SHARED(ary); | |
if (len <= RARRAY_EMBED_LEN_MAX) { |
# These two chunks of code are the same, because method have inherent exception scopes | |
def method | |
begin | |
"hello".this_method_doesnt_exist | |
rescue NoMethodError => e | |
puts e | |
end | |
end |
require 'benchmark' | |
@ids = (1..1000).to_a.shuffle | |
@records = [] | |
1000.times do |x| | |
@records << { :id => (x + 1) } | |
end | |
Benchmark.bm do |x| |
if [[ -x /Applications/MacVim.app/Contents/MacOS/Vim ]] | |
then | |
EDITOR="/Applications/MacVim.app/Contents/MacOS/Vim" | |
elif [[ -x $HOME/Applications/MacVim.app/Contents/MacOS/Vim ]] | |
then | |
EDITOR="$HOME/Applications/MacVim.app/Contents/MacOS/Vim" | |
else | |
EDITOR="vim" | |
fi | |
export EDITOR |
Get Homebrew installed on your mac if you don't already have it
Install highlight. "brew install highlight". (This brings down Lua and Boost as well)
hash = { | |
:before => "Hello", | |
:after => "world!", | |
:ref => lambda { hash[:before] << ' ' << hash[:after] } | |
} | |
hash[:ref].call # => "Hello world!" |
$ cat config/database.yml | |
<% puts "Hello from database.yml" %> | |
development: | |
adapter: sqlite3 | |
database: db/development.sqlite3 | |
pool: 5 | |
timeout: 5000 | |
$ rails console | |
Hello from database.yml | |
Loading development environment (Rails 3.2.6) |
ActiveSupport::Inflector.inflections do |inflect| | |
inflect.clear | |
inflect.plural(/$/, 's') | |
inflect.plural(/[sxz]|[cs]h$/i, 'es') | |
inflect.plural(/[^aeiouy]o/i, 'es') | |
inflect.plural(/([^aeiouy])y/i, '\1ies') | |
inflect.singular(/s$/i, '') | |
inflect.singular(/(ss)$/i, '\1') |