Skip to content

Instantly share code, notes, and snippets.

View damon's full-sized avatar

Damon Clinkscales damon

View GitHub Profile
# TableSplitter splits record ids up into ranges to use in SQL
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/environment'
# $ ./splitter.rb 5 2
# break into 5 chunks.
# requesting chunk 2: id >= 74 and id < 144
# For demo purposes, here are all of them:
# requesting chunk 1: id >= 1 and id < 74
@damon
damon / config.ru
Created November 18, 2008 01:12
a fix for Camping/Rack found here - http://jira.codehaus.org/browse/JRUBY-2859
require 'blog'
require 'thin'
require 'rack_fix'
run Rack::Adapter::Camping.new(Blog)
$ curl "http://www.flickr.com/services/oembed/?url=http://flickr.com/photos/digitalnomad/3086168632/"
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
<version>1.0</version>
<type>video</type>
<title>flickr mobile video test, please ignore</title>
<author_name>digitalnomad</author_name>
<author_url>http://www.flickr.com/photos/digitalnomad/</author_url>
<cache_age>3600</cache_age>
<provider_name>Flickr</provider_name>
def whack(objects)
result = {}
objects.each do |o|
result[o.send("table_name")] = o.send("delete_all")
end
result
end
@damon
damon / shared_followers.rb
Created February 5, 2009 06:42
Compute shared followers between two Twitter accounts
#!/usr/bin/env ruby
# Author: Damon Clinkscales
require 'rubygems'
require 'hpricot'
require 'net/http'
require 'yaml'
def get_followers(user)
#!/usr/bin/env ruby
require 'rubygems'
require 'json'
raise "you fail at this" if !ARGV[0]
data=""
File.open(ARGV[0]).each_line do |line|
data << line
end
#!/usr/bin/env ruby
# To install:
# sudo gem sources -a http://gems.github.com # (if needed)
# sudo gem install hayesdavis-grackle
# see http://github.com/hayesdavis/grackle for more info
# To run:
# Set USER and PASS for the account you want to clean.
# ./whack_statuses.rb
# Mongrel
# • Current version: 1.1.5-java
# • Still has request mutex; manually
# remove for better throughput
# in $JRUBY/lib/ruby/gems/1.8/gems/mongrel-1.1.5-java/lib/mongrel/rails.rb
# @guard.synchronize {
@active_request_path = request.params[Mongrel::Const::PATH_INFO]
Dispatcher.dispatch(cgi, ActionController::CgiRequest::...)
@active_request_path = nil
# }
# handy trick for keeping your AR models more manageable
# see http://m.onkey.org/2008/9/15/active-record-tips-and-tricks for info
class << ActiveRecord::Base
def concerned_with(*concerns)
concerns.each do |concern|
require_dependency "#{name.underscore}/#{concern}"
end
end
end
@damon
damon / 0what.md
Created August 24, 2009 02:32 — forked from defunkt/0what.md

Poor Man's Deploy

  • Start a Sinatra server on port 4000
  • GET / to that server triggers a git pull and mod_rails restart
  • Hit port 4000 locally after pushing

Why?