Skip to content

Instantly share code, notes, and snippets.

View ELLIOTTCABLE's full-sized avatar
🐫

ELLIOTTCABLE

🐫
View GitHub Profile
@ELLIOTTCABLE
ELLIOTTCABLE / gist:264034
Created December 26, 2009 20:31 — forked from atg/gist:264032
foo = routine
lookup = routine
# All lookups after foo are put into @
# so 'foo bar baz' would give you @ = (bar baz)
out = @0
# The default implementation does a reduce() with dereferencing, something like this
@.prepend(this)
reduce(@0)
@2(@0[@1])
out(@0)
foo bar
=> foo['bar']
# assignment (no, this is impossible to handle in userspace without breaking/crippling lookup overloading)
... = ...
# methods (this is just syntactic sugar)
foo.bar
fib ↼ function
if({ @x = 0 | @x = 1 }, then: { @last(1) }, else: function)
@last( callee(@1 - 1, ?) + callee(@1 - 2, ?) )
fib(5, { print(@) })
require('http')
.createServer(function(request, response){
response.sendHeader(200, {'Content-Type' : 'text/plain'});
response.sendBody("zoom");
response.finish();
})
.listen(8000);
def summer_monthly_usage
@summer_monthly_usage ||= rates.summer_months_nbr.map{|month| monthly_usage[month - 1]}.inject(0){|sum, v| sum += v}
end
#!/usr/bin/ruby19 -wKu
# Here's the problem: Ruby is playing the part of a deaf grandma. If I
# don't ask her a question in upcase, she can't hear me. If I ask her any
# question in upcase, she'll respond in the same fashion unless I shout BYE
# to her. I need to shout BYE to her 3 times to escape her madness.
puts 'What is it dear?'
question = gets.chomp!
counter = 0
p 'DEBUG: before everything'
require 'wordlist'
# Get evil idea and swap in code words
print "Enter your new idea: "
idea = gets
Decoder::CodeWords.each do |real, code|
idea.gsub!( real, code )
end
# Save the jibberish to a new file
@ELLIOTTCABLE
ELLIOTTCABLE / build_ruby19.sh
Created February 6, 2009 03:55 — forked from postmodern/build_ruby19.sh
This is a script to install both ruby 1.8.7 and 1.9.1, with suffixed binaries and symlinks
# This is a script to install both ruby 1.8.7 and 1.9.1, with suffixed binaries and symlinks
mkdir -p /usr/local/src ; cd /usr/local/src
wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p160.tar.bz2
tar -xjvf ruby-1.8.7-p160.tar.bz2
cd ruby-1.8.7-p160
./configure --prefix=/usr --program-suffix=18 --enable-shared
make && sudo make all install
cd /usr/local/src
def generic_select (item, default, object, method, options = {})
obj = options[:object] || instance_variable_get("@#{object}")
value = options[:value] || (obj.nil? ? obj : obj.send(method))
value = value.to_s
options[:size] = options[:size] || default unless default.blank?
text_field(object, method, options) + '<div class="' + item + '_autocomplete autocomplete"></div>'
end
def generic_tag_select (item, default, name, value = nil, options = {})
value = value.to_s
class String
def to_ascii_encode
old_kcode, $KCODE = $KCODE, 'ascii'
result = inspect[1..-2]
$KCODE = old_kcode
result
end
end