Skip to content

Instantly share code, notes, and snippets.

View amiel's full-sized avatar

Amiel Martin amiel

View GitHub Profile
# ~/.rvm/gemsets/global.gems
rake
bundler
autotest-fsevent
autotest-growl
@amiel
amiel / GetBundles.sh
Created April 14, 2011 20:51
How to get GetBundles to work with rvm
#!/bin/bash
if [ `echo -n "$DIALOG" | tail -c 1` != "2" ]; then
CHECK=$("$DIALOG" -l | egrep -c 'TextMate — GetBundles')
else
CHECK=$("$DIALOG" nib --list | egrep -c 'TextMate — GetBundles')
fi
[[ ! -d ~/Library/Logs ]] && mkdir -p ~/Library/Logs
rm -f ~/Library/Logs/TextMateGetBundles.log
#! /usr/bin/ruby
# data set:
# id | name | score | postal | color
# 1 | john | 14 | 12345 | blue
# 2 | jane | 10 | 12345 | blue
# 3 | jeff | 6 | 12345 | green
# define a simple class for holding the dataset
@amiel
amiel / Use of the ! operator
Created April 28, 2011 21:18
not_operator.rb
# Some values, they are themselves
true # => true
false # => false
"value" # => "value"
0 # => 0
nil # => nil
@amiel
amiel / sweeper.rb
Created May 6, 2011 21:49
DataMapper::Sweeper
module DataMapper
# DataMapper::Sweeper provides an observer to model changes that have access
# to the controller invoking the changes.
#
# The api for DataMapper::Sweeper is similar to DataMapper::Observer, but
# there is one important difference: in DataMapper::Observer .before and
# .after blocks are evaluated in the context of the resource instance.
# However, DataMapper::Sweeper .before and .after blocks are evaluated in the
# context of an instance of your Sweeper class, and missing methods are
@amiel
amiel / helpers.rb
Created October 27, 2011 21:59 — forked from adrianpike/helpers.rb
Page title helper for I18n with to_s for :show!
def page_title()
object_name = controller_name.singularize
if controller.instance_variables.include?(('@' + object_name).to_sym)
locals = {
object_name.to_sym => controller.instance_variable_get('@' + object_name).to_s
}
else
locals = {}
end
@amiel
amiel / README.md
Created October 28, 2011 19:08
post-commit git hook for simple deploys

Put the ruby file in .git/hooks/post-commit

Create a deploy script as .deploy_*

Example:

# File: .deploy_production
scp -R html example.com:public_html

Then use "deploy *" in your commit message.

@amiel
amiel / README.md
Created November 1, 2011 20:36
Can Haz Emoji?

🐻 :octocat: 🐨

class Asset < AR
end
class Alert < AR
belongs_to :asset
has_many :logs
accepts_nested_attributes_for :logs
end
class Log < AR
module ApplicationHelper
def current_user
super.decorator
end
end