Skip to content

Instantly share code, notes, and snippets.

View carllerche's full-sized avatar
😎
working

Carl Lerche carllerche

😎
working
View GitHub Profile
# sudo gem install rack nokogiri mongrel --no-rdoc --no-ri
# curl http://gist.github.com/raw/258378/31dc0cc39faf8328cc6b5b5e2fa2a973153f174d/gistfile1.txt > hello_world.rb
# ruby hello_world.rb
require 'rubygems'
require 'rack'
require 'nokogiri'
require 'open-uri'
class HelloWorld
package main
import "os";
import "fmt";
var foo = os.Args[1:];
func main() {
fmt.Println(foo);
}
Carl-Lerches-MacBook-Pro:~ carllerche$ rvm remove 1.9.1-head ; rvm install 1.9.1-head --trace
<i> Removing /Users/carllerche/.rvm/src/ruby-1.9.1-head... </i>
<i> it seems that /Users/carllerche/.rvm/ruby-1.9.1-head is already non existent. </i>
install 1.9.1-head --trace
+ [[ -z install ]]
+ [[ ! -z '' ]]
+ [[ ! -z '' ]]
+ [[ 0 -gt 0 ]]
+ [[ 0 -gt 0 ]]
+ [[ ! -z '' ]]
Carl-Lerches-MacBook-Pro:~ carllerche$ rvm remove 1.9.1-head ; rvm install 1.9.1-head --trace
<i> Removing /Users/carllerche/.rvm/src/ruby-1.9.1-head... </i>
<i> it seems that /Users/carllerche/.rvm/ruby-1.9.1-head is already non existent. </i>
install 1.9.1-head --trace
+ [[ -z install ]]
+ [[ ! -z '' ]]
+ [[ ! -z '' ]]
+ [[ 0 -gt 0 ]]
+ [[ 0 -gt 0 ]]
+ [[ ! -z '' ]]
class Array
def /(n)
arr = []
size = length / n
size += 1 if length % n > 0
n.times do |i|
arr << self[i*size, size]
end
arr
end
# This is pretty evil, yeah... I know
class Module
alias old_append_features append_features
def append_features(base)
return false if base < self
(@_needed || []).each { |mod| base.send(:include, mod) }
(@_class_methods || []).each do |blk|
(class << base ; self ; end).class_eval(&blk)
end
old_append_features(base)
def matching(prop)
@matching ||= inject({}) do |hash, p|
(hash[p.root] ||= []) << p
hash
end[prop.root] || []
end
def matching(prop)
@matching ||= begin
map = {}
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe "Koios::Relationship" do
model :Owner do |sql|
has n, :things, :model => 'Thing', :on => :owner_id
end
model :Thing do |sql|
property :owner_id, Integer
gem_env do
gem "merb"
gem "json", :namespace => "pure"
end
# This is pretty evil, yeah... I know
class Module
alias old_append_features append_features
def append_features(base)
return false if base < self
(@_needed || []).each { |mod| base.send(:include, mod) }
(class << base ; self ; end).class_eval(&@_class_methods) if @_class_methods
old_append_features(base)
end