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
# SVN | |
svn annotate app/models/*rb | egrep -i '\* from' | while read rev user code; do echo $user; done | sort | uniq -c | sort -n | |
# GIT | |
for x in app/models/*rb; do git annotate $x; done | sed 's/(//g' | egrep -i '\* from' | while read rev user code; do echo $user; done | sort | uniq -c | sort -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
# Stick this at the bottom of environment.rb | |
# Run through your app, and "require.log.rb" will capture the libs that are loaded after-the-fact | |
# Then you can decide if you wish to load all these libs upfront. | |
# Possibly avoids the infamous "Expected x.rb to define x" errors | |
if ENV['LOAD_REQUIRE_LOG'] && File.exists?("require.log.rb") | |
require "require.log.rb" | |
$stderr.puts "Loaded require.log.rb" | |
end | |
Kernel.class_eval do |
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
# Monkey-patch to Rufus::Tokyo::Cabinet to work with some Array & Hash values | |
Rufus::Tokyo::Cabinet.class_eval do | |
# list of [[count1, value2], [count1, value2], ...] is sorted by count* | |
def append_list(key, object, sort = false, max_length = nil) | |
list = get_object(key) || [] | |
list << object | |
list.sort! {|a,b| b[0] <=> a[0] } if sort | |
list.slice!(max_length..-1) if max_length | |
set_object(key, list) | |
list |
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
# = Environment variable configs: | |
# | |
# HIGHLANDER_PID_PATH | |
# - optional, specify which directory the pid file goes. | |
# - defaults to same location as script | |
# | |
# HIGHLANDER_MAX_SECONDS | |
# - optional, specify how many seconds to wait before interrupting previous process (owner of pidfile) | |
# - defaults to never | |
# |
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
<html><body> | |
<script src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script> | |
<script> | |
(function(search_term, css_selector) { | |
jQuery.getJSON("http://search.twitter.com/search.json?q=" + encodeURIComponent(search_term) + "&callback=?", function(json) { | |
var tweet_html = []; | |
jQuery.each(json.results, function(index, tweet) { | |
tweet_html.push("<li><img style='height: 48px;' src='" + tweet.profile_image_url + "'/>\n<span class='author'>" + tweet.from_user + "</span>\n<span class='tweet'>" + tweet.text + "</span></li>"); | |
}); | |
jQuery(document.body).append("<ol>" + tweet_html.join("") + "</ol>"); |
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
require 'net/http' | |
require 'net/https' | |
def get_url_response(url, headers = {}, cookies = {}, url_stack = []) | |
raise ArgumentError, 'HTTP redirect too deep' if url_stack.length > 20 | |
uri = URI.parse(url) | |
headers.merge!('cookie' => cookies.collect {|k,v| "#{k}=#{v}"}.join('; ')) if not cookies.empty? | |
headers.merge!('referer' => url_stack.last) if url_stack.last | |
req = Net::HTTP::Get.new(uri.request_uri || '/', headers) | |
ses = Net::HTTP.new(uri.host, uri.port) |
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
# this ruby script generates a shell script to reinstall/recompile your gems | |
puts '#!/bin/bash' | |
puts 'export ARCHFLAGS="-arch x86_64"' | |
`gem list`.each do |line| | |
if line =~ /\s*(.+)\s+\((.+)\)/ | |
gem_name, versions = [$1, $2] | |
versions.split(/, /).each do |version| | |
puts "gem install #{gem_name} --version='#{version}'" | |
end | |
end |
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
# this ruby script generates a shell script to reinstall/recompile your gems | |
puts '#!/bin/bash' | |
puts 'export ARCHFLAGS="-arch x86_64"' | |
`gem list`.each do |line| | |
if line =~ /\s*(.+)\s+\((.+)\)/ | |
gem_name, versions = [$1, $2] | |
versions.split(/, /).each do |version| | |
puts "gem install #{gem_name} --version='#{version}'" | |
end | |
end |
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
# this ruby script generates a shell script to reinstall/recompile your gems | |
puts '#!/bin/bash' | |
puts 'export ARCHFLAGS="-arch x86_64"' | |
`gem list`.each do |line| | |
if line =~ /\s*(.+)\s+\((.+)\)/ | |
gem_name, versions = [$1, $2] | |
versions.split(/, /).each do |version| | |
puts "gem install #{gem_name} --version='#{version}'" | |
end | |
end |
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
# Create the "db/seeds" directory, and place the individual seeding scripts there instead. | |
Dir[File.join(File.dirname(__FILE__), "seeds", "*.rb")].sort.each {|path| require path } |