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
| # include this in application controller | |
| module Authentication | |
| protected | |
| # Inclusion hook to make #current_user and #signed_in? | |
| # available as ActionView helper methods. | |
| def self.included(base) | |
| base.send :helper_method, :current_user, :signed_in?, :authorized? if base.respond_to? :helper_method | |
| end | |
| # Returns true or false if the user is signed in. |
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
| module Inline | |
| include Haml::Filters::Base | |
| def self.[](key) | |
| @@data[key.to_s] rescue nil | |
| end | |
| def render(str) | |
| @@data = Hash[*str.split(/^\s*@@\s*(\w+)\s*\n/m)[1..-1]] | |
| return nil |
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
| # collect information about a running process | |
| # ruby debug.rb <pid> | |
| begin | |
| raise ArgumentError unless pid = ARGV[0] | |
| pid = pid.to_i | |
| Process.kill(0,pid) | |
| rescue TypeError, ArgumentError | |
| raise 'pid required' | |
| rescue Errno::ESRCH |
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 | |
| puts "looking for the gems to upgrade..." | |
| gem_info = Struct.new(:name, :version) | |
| to_reinstall = [] | |
| Dir.glob('/Library/Ruby/Gems/**/*.bundle').map do |path| | |
| path =~ /.*1.8\/gems\/(.*)-(.*?)\/.*/ | |
| name, version = $1, $2 | |
| bundle_info = `file path` | |
| to_reinstall << gem_info.new(name, version) unless bundle_info =~ /bundle x86_64/ | |
| 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
| #!/bin/sh | |
| REPO=$1 | |
| git clone $REPO | |
| cd `basename $REPO .git` | |
| for BRANCH in `git branch -r`; do | |
| git co --track \ | |
| -b remote/$BRANCH \ | |
| $BRANCH | |
| done |
NewerOlder