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
# | |
# Paperclip convert id => id_partition | |
# | |
require 'fileutils' | |
class PaperclipExtend | |
def self.obtain_class | |
class_name = ENV['CLASS'] || ENV['class'] | |
uploads_path = ENV['UPLOADS_PATH'] || ENV['uploads_path'] | |
raise "Must specify CLASS" unless class_name |
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
# download and build nginx from sources | |
https://gist.github.com/3083579 |
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
echo "Install Ruby..." | |
sudo apt-get update | |
sudo apt-get install build-essential libssl-dev zlib1g-dev libreadline-dev | |
export ruby_version=1.9.3-p194 | |
cd /usr/src | |
sudo wget "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-$ruby_version.tar.bz2" | |
sudo tar xf "./ruby-$ruby_version.tar.bz2" | |
sudo rm "./ruby-$ruby_version.tar.bz2" |
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 User < ActiveRecord::Base | |
end | |
class Book < ActiveRecord::Base | |
end | |
module CustomerRole | |
end | |
class AddToCartContext |
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
# nginx | |
description "nginx http daemon" | |
author "George Shammas <[email protected]>" | |
start on (filesystem and net-device-up IFACE=lo) | |
stop on runlevel [!2345] | |
env DAEMON=/usr/sbin/nginx | |
env PID=/var/run/nginx.pid |
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
Rails::Rack::Logger.class_eval do | |
def call_app(request, env) | |
path = request.filtered_path | |
unless path.index("/assets/") == 0 | |
# Put some space between requests in development logs. | |
if development? | |
logger.debug '' | |
logger.debug '' | |
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
module ActiveSupport | |
module StringInquirerPatch | |
def self.included klass | |
klass.send :remove_method, :method_missing | |
end | |
def method_missing method_name, *arguments | |
if method_name.to_s[-1,1] == "?" | |
is_eql_to_self = (self == method_name.to_s[0..-2]) |
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 'rubygems' | |
require 'nokogiri' | |
require 'eeepub' | |
DOC_TITLE = 'Ruby on Rails Guides' | |
def get_pages(src_dir) | |
index_file = File.join(src_dir, 'index.html') | |
section = nil | |
pages = [{ :section => section, :title => DOC_TITLE, :path => index_file }] |
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/local/lib/node/.npm/socket.io/0.8.4/package/lib/manager.js:610 | |
transport.payload(this.closed[data.id]); | |
^ | |
TypeError: Object #<WebSocket> has no method 'payload' | |
at Manager.handleClient (/usr/local/lib/node/.npm/socket.io/0.8.4/package/lib/manager.js:610:19) | |
at Manager.handleUpgrade (/usr/local/lib/node/.npm/socket.io/0.8.4/package/lib/manager.js:564:8) | |
at HTTPServer.<anonymous> (/usr/local/lib/node/.npm/socket.io/0.8.4/package/lib/manager.js:100:10) | |
at HTTPServer.emit (events.js:81:20) | |
at Socket.<anonymous> (http.js:1035:14) | |
at Socket._onReadable (net.js:683:27) |
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
# Date.parse() with Ruby 1.9 is now defaulting to the European date style where the format is DD/MM/YYYY, not MM/DD/YYYY | |
# patch it to use US format by default | |
if RUBY_VERSION >= '1.9' | |
class String | |
def to_date | |
if self.blank? | |
nil | |
elsif self =~ /(\d{1,2})\/(\d{1,2})\/(\d{4})/ | |
::Date.civil($3.to_i, $1.to_i, $2.to_i) | |
else |