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
### Keybase proof | |
I hereby claim: | |
* I am kek on github. | |
* I am karl_eklund (https://keybase.io/karl_eklund) on keybase. | |
* I have a public key ASAEcOPBQyycvkWS6x_PxR6X9b2g9eHICRaDPQqbsEhmrAo | |
To claim this, I am signing this object: |
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
defmodule Main do | |
def f do | |
1 | |
end | |
def run do | |
f = 2 | |
f | |
end | |
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
def rule message, &block | |
@rules ||= [] | |
@rules << Class.new { | |
attr_reader :message | |
def initialize(message, &block) | |
@message = message | |
@block = block | |
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
class Player | |
attr_reader :warrior | |
def play_turn(warrior) | |
@warrior = warrior | |
if warrior.feel(:backward).captive? | |
@has_rescued = true | |
warrior.rescue!(:backward) | |
elsif not @has_rescued |
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 Object | |
def or(els) | |
if block_given? | |
yield (self or els) | |
else | |
els | |
end | |
end | |
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
class Object | |
def chain | |
yield self | |
end | |
end | |
puts 1.chain { |x| x + 1 }.chain { |x| x + 1 } |
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/ruby | |
require 'cgi' | |
require 'erb' | |
cgi = CGI.new('html') | |
template = <<TEMPLATE | |
<html> | |
<head> |
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
\ 2520 is the smallest number that can be divided by each of the | |
\ numbers from 1 to 10 without any remainder. | |
\ What is the smallest positive number that is evenly divisible by all | |
\ of the numbers from 1 to 20? | |
: divisible-by-upto? { n upto -- bool } | |
0 | |
upto 1+ 1 ?do | |
n i mod + |
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 | |
# Gist: https://gist.github.com/222304 | |
# Install Nokogiri, http://nokogiri.rubyforge.org/nokogiri/ | |
require 'rubygems' | |
require 'nokogiri' | |
require 'open-uri' | |
# ~/.eve needs to contain user id, full api key and character id, |