This file contains hidden or 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 MorseEncoder | |
TRANSLATIONS = { | |
:a => "._", | |
:b => "_...", | |
:c => "_._.", | |
:d => "_..", | |
:e => "." | |
} | |
def method_missing(m, *args) |
This file contains hidden or 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
import org.apache.http.client._ | |
import org.apache.http.client.methods._ | |
import org.apache.http.impl.client._ | |
import scala.xml._ | |
object S { | |
def main(args : Array[String]) : Unit = { | |
val root = scala.xml.XML.load((new DefaultHttpClient).execute ( | |
new HttpGet("http://whoismyrepresentative.com/getall_sens_bystate.php?state="+args.head) | |
).getEntity.getContent) |
This file contains hidden or 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
# This is my gist |
This file contains hidden or 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 foo | |
end |
This file contains hidden or 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 foo | |
end |
This file contains hidden or 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
#hello |
This file contains hidden or 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
configuration = configure do |config| | |
config.tail_logs = true | |
config.max_connections = 55 | |
config.admin_password = 'secret' | |
config.app_server do |app_server_config| | |
app_server_config.port = 8808 | |
app_server_config.admin_password = config.admin_password | |
end | |
end | |
This file contains hidden or 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
Around methods: | |
method_missing, method_added, singleton_method_added, method_removed, singleton_method_removed, method_undefined, singleton_method_undefined | |
Around classes and modules | |
inherited, append_features, included, extend_object, extended, initialize_copy, const_missing | |
Marshaling | |
marshal_dump, marshal_load | |
Numbers | |
coerce, induced_from |
This file contains hidden or 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 create_multipler(factor) | |
->param{param * factor} | |
end | |
times_2 = create_multipler(2) | |
p times_2.(4) | |
exit | |
class Foo | |
1_000_000_000.times do |n| | |
define_method("times_#{n}") do |param| |
This file contains hidden or 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 assert_difference(string, expected_difference = 1, &block) | |
before = eval(string, block.binding) | |
block.call | |
after = eval(string, block.binding) | |
fail "Expected a difference of #{expected_difference}" unless after - before == expected_difference | |
end | |
a = 1 | |
assert_difference("a", 1) do | |
a += 1 |