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
#!/bin/bash | |
VERSION="1.1" | |
REEV="http://rubyforge.org/frs/download.php/48623/ruby-enterprise-1.8.6-20081215.tar.gz" | |
REEF="ruby-enterprise-1.8.6-20081215.tar.gz" | |
REEFF=${REEF%".tar.gz"} | |
PASSENGER="2.0.6" | |
echo "#####################################" | |
echo "Welcome, let's get this party rollin'" | |
echo "#####################################" |
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 'rational' | |
class Numeric | |
def to_r(rounding = 10_000) | |
Rational((self * rounding).to_i, rounding) | |
end | |
end | |
class Rational | |
def to_proper |
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
#!/bin/bash | |
# Unattended REE/Passenger installation | |
# Source: http://weblog.brightlight-ict.nl/2008/12/unattended-passenger-ruby-enterprise-installation-on-ubuntu-8/ | |
# 15/03/09 Updated to use latest r.e.e. and passenger 2.1 and rewrote bits thanks to the comments left on my blog. Thanks guys | |
if [ "$(whoami)" != "root" ]; then | |
echo "You need to be root to run this!" | |
exit 2 | |
fi | |
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
class LegislatorsController < ApplicationController | |
layout :choose_layout | |
def search | |
setup_search(legislators_path(:u => params[:u])) | |
end | |
def bm_search | |
setup_search(bm_legislators_path(:u => params[:u])) | |
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
<!DOCTYPE html> | |
<html lang='en'> | |
<head> | |
<title>LiftCalc</title> | |
<meta http-equiv='Content-type' content='text/html;charset=UTF-8'> | |
<meta name='viewport' content='width=device-width'> | |
<meta name='viewport' content='initial-scale=1.6'> | |
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js'></script> | |
<script type='text/javascript'> |
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
# Warning: Loses any scope it may have been called on! | |
def send_all_in_batches(batch_size, method, *args) | |
transaction do | |
start_id = first(:order => 'id ASC').id | |
end_id = first(:order => 'id DESC').id | |
current_id = start_id | |
while current_id <= end_id | |
if time = args.delete(:time) | |
send_at(time, :send_to_batch, current_id, current_id + batch_size, method, *args) | |
else |
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
# Used to graph results from autobench | |
# | |
# Usage: ruby autobench_grapher.rb result_from_autobench.tsv | |
# | |
# This will generate three svg & png graphs | |
require "rubygems" | |
require "scruffy" | |
require 'csv' | |
require 'yaml' |
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
ActionController::Integration::Session.class_eval do | |
def generic_url_rewriter | |
env = { | |
'REQUEST_METHOD' => "GET", | |
'QUERY_STRING' => "", | |
"REQUEST_URI" => "/", | |
"HTTP_HOST" => host, | |
"SERVER_PORT" => https? ? "443" : "80", | |
"HTTPS" => https? ? "on" : "off", | |
"rack.input" => "wtf" |
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
%w(dm-core dm-timestamps dm-validations dm-aggregates).each {|lib| gem lib, '=1.1.0'} | |
%w(dm-core dm-timestamps dm-validations dm-aggregates dm-migrations RMagick aws ./config).each { |lib| require lib} | |
include Magick | |
DataMapper.setup(:default, ENV['DATABASE_URL'] || 'mysql://root:fa1556cm@localhost/monsoc') | |
S3 = Aws::S3Interface.new(S3_CONFIG['AWS_ACCESS_KEY'], S3_CONFIG['AWS_SECRET_KEY'], {:multi_thread => true, :protocol => 'http', :port => 80} ) | |
module Commentable | |
def people_who_likes | |
self.likes.collect { |l| "<a href='/user/#{l.user.nickname}'>#{l.user.formatted_name}</a>" } |
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
class Uri < ActiveRecord::Base | |
belongs_to :job | |
has_many :scrapes | |
def get_request_object options | |
require 'rubygems' | |
require 'typhoeus' | |
request = Typhoeus::Request.new(self.uri, options) |
OlderNewer