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 'rack' | |
require 'rubygems' | |
require 'rack' | |
class Object | |
def webapp | |
def call(env) | |
func, *attrs = env['PATH_INFO'].split('/').reject(&: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
require 'rubygems' | |
require 'zmq' | |
z = ZMQ::Context.new | |
s = z.socket(ZMQ::UPSTREAM) | |
s.connect "tcp://127.0.0.1:5555" | |
while true | |
puts s.recv | |
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
--- a/load.c 2010-10-23 05:36:38.000000000 -0400 | |
+++ b/patchload.c 2011-06-05 08:58:00.000000000 -0400 | |
@@ -40,14 +40,6 @@ | |
VALUE ary; | |
long i; | |
- for (i = 0; i < RARRAY_LEN(load_path); ++i) { | |
- VALUE str = rb_check_string_type(RARRAY_PTR(load_path)[i]); | |
- if (NIL_P(str) || !rb_is_absolute_path(RSTRING_PTR(str))) | |
- goto relative_path_found; |
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
$ cd /usr/src | |
$ wget http://nginx.org/download/nginx-0.8.52.tar.gz | |
$ tar xzvf ./nginx-0.8.52.tar.gz | |
$ rm ./nginx-0.8.52.tar.gz | |
$ gem install s3sync capistrano capistrano-ext passenger --no-ri --no-rdoc | |
$ passenger-install-nginx-module | |
# Automatically download and install Nginx? 2. No: I want to customize my Nginx installation | |
# Where is your Nginx source code located?: /usr/src/nginx-0.8.52 | |
# Where do you want to install Nginx to?: /opt/nginx |
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 |
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
# 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
# | |
# 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
$stack, $draws = [], {} | |
def method_missing *args | |
return if args[0][/^to_/] | |
$stack << args.map { |a| a or $stack.pop } | |
$draws[$stack.pop(2)[0][0]] = args[1] if args[0] == :< | |
end | |
class Array | |
def +@ |
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 | |
require './dancer' | |
require './gangnam_style' | |
dancer = Dancer.new('PSY', GangnamStyle.new) | |
dancer.dance! |
OlderNewer