This file contains 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
def locals(*only, &block) | |
raise ArgumentError, "must include a block" unless block_given? | |
bndng = block.send(:binding) | |
all_locals = eval("local_variables",bndng) - ['_'] | |
locals_hash = Hash[all_locals.map {|l| [l,eval(l,bndng)]}] | |
Hash[locals_hash.select {|k,v| only.include?(v)}] | |
end | |
hi = "hello world" | |
bye = "goodbye world" |
This file contains 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
(function($){ | |
// Set up the overlay as a DOM node, we'll swap it in and out of the DOM | |
var $overlay = $('<div></div>'); | |
var $overlay_content = $('<div></div>'); | |
$overlay_content.css({ | |
'width' : '25em', | |
'margin' : '100px auto', | |
'border' : '1px solid #000', | |
'padding' : '15px', | |
'text-align': 'center', |
This file contains 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
action: listcustomers | |
<QBXML> | |
<QBXMLMsgsRq onError="stopOnError"> | |
<CustomerQueryRq> | |
<MaxReturned>params[:limit]</MaxReturned> | |
</CustomerQueryRq> | |
</QBXMLMsgsRq> | |
</QBXML> | |
action: show | |
<QBXML> |
This file contains 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 | |
$profiles_path = "#{ENV['HOME']}/Library/Application Support/Google/Chrome" | |
Dir.chdir($profiles_path) | |
if ARGV[0] == 'clone' | |
$clone = true | |
ARGV.shift | |
elsif ARGV[0] == 'list' | |
puts Dir['*'].select {|d| File.directory?(d) && File.exists?("#{d}/.profile_name")}.map {|d| File.read("#{d}/.profile_name").chomp}.join("\n") |
This file contains 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 Kernel | |
def man(obj) | |
publ = obj.public_methods.sort - Object.public_methods - Kernel.public_methods | |
puts "Public:\n#{publ.join(', ')}" | |
priv = obj.private_methods.sort - Object.private_methods - Kernel.private_methods | |
puts "\nProtected:\n#{prot.join(', ')}" unless prot.empty? | |
prot = obj.protected_methods.sort - Object.protected_methods - Kernel.protected_methods | |
puts "\nPrivate:\n#{priv.join(', ')}" unless priv.empty? |
This file contains 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
# Routing | |
map.with_options(:namespace => 'api/', :path_prefix => "/api/:version", :version => /v\d+/) do |api| | |
api.resources :photos | |
end | |
# API Controller superclass | |
class ApiController < ApplicationController | |
append_view_path 'views/api' | |
# this will happen before anything else that cares about |
This file contains 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 | |
# Command: mkgem | |
# Usage: mkgem gemname | |
# mkgem will prompt you for all of the pieces of information | |
# it needs to create a gem using jeweler. | |
# PLEASE FEEL FREE TO FORK AND CONTRIBUTE! |
This file contains 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
# Adjusts Google Calendar ical times for TimeZone ONLY WHEN NECESSARY | |
tzadjust = Time.gcalschema("#{e["DTSTART;TZID=#{self.time_zone_name}"] || "#{e['DTSTART;VALUE=DATE']}T000000"}Z").nil? ? -4*3600 : 0 | |
st = (Time.gcalschema("#{e["DTSTART;TZID=#{self.time_zone_name}"] || "#{e['DTSTART;VALUE=DATE']}T000000"}Z") || Time.gcalschema(e['DTSTART'])) + tzadjust | |
et = (Time.gcalschema("#{e["DTEND;TZID=#{self.time_zone_name}"] || "#{e['DTEND;VALUE=DATE']}T000000"}Z") || Time.gcalschema(e['DTEND'])) + tzadjust |
This file contains 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
curl "http://repo.or.cz/w/git.git?a=blob_plain;f=contrib/completion/git-completion.bash;h=4ea727b14303e397117067993dbda446ed154ea1;hb=HEAD" > ~/.git_bash_completion.sh | |
chmod +x ~/.git_bash_completion.sh | |
echo " source ~/.git_bash_completion.sh | |
#PS1='$PS1' | |
PS1='\\W \$(__git_ps1 \"(%s) \")\\\$ '" >> ~/.profile |
This file contains 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
########### | |
## File: app/controllers/application_controller.rb | |
class ApplicationController < ActionController::Base | |
around_filter :catch_prerequisite | |
private | |
def catch_prerequisite | |
need = catch :prerequisite_unmet do | |
yield |
NewerOlder