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 new_with &block | |
self.new.instance_eval { | |
yield | |
} | |
end | |
end | |
$logger = Object.new_with { | |
define_method :foo do |
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
if (results = Parser.new.parse).nil? | |
# parse failure | |
else | |
# displaying help info and exiting is a valid execution method | |
execute_with_options results | |
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 proclol arg | |
{ | |
'a' => proc { true }, | |
'b' => proc { do_something }, | |
'c' => proc { your_money || your_fase } | |
}[arg] | |
end | |
proclol('b').call |
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 self.define_the_methods name | |
(class << self; self; end).instance_eval { | |
define_method name do |account| | |
log 'class' | |
end | |
} | |
define_method name do |account| | |
log 'instance' | |
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
/* goes in ~/Library/KeyBindings */ | |
{ | |
/* page up/down */ | |
"\UF72C" = "pageUp:"; | |
"\UF72D" = "pageDown:"; | |
/* Modifier keys: start with C-m */ | |
"^m" = { | |
"^ " = ("insertText:", "\U2423"); /* C-space space */ | |
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 Lol | |
def where_am_i | |
"within #{self.class.to_s}" | |
end | |
def winproc | |
proc { "lol from #{where_am_i}" } | |
end | |
end | |
def where_am_i |
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
# Where the hell did 'lol' get defined? | |
method_name = "lol" | |
ObjectSpace.each_object.each {|o| puts "#{o.is_a?(Class) ? o.name : o.class}: #{o.methods.grep method_name}" unless o.methods.grep(method_name).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
class Object | |
def metaclass | |
class << self; self; end | |
end | |
end | |
module CannedScopes | |
def self.included base | |
base.send :extend, ClassMethods | |
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
<VirtualHost *:80> | |
ServerName mohole.net | |
ServerAlias www.mohole.net | |
DocumentRoot /home/mohole/current/public | |
<Directory "/home/mohole/current/public/"> | |
Options FollowSymLinks | |
AllowOverride None | |
Order allow,deny | |
Allow from all |
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
rightTriangles = [ (a,b,c) | c <- [1..500], b <- [1..c], a <- [1..b], a^2 + b^2 == c^2] | |
main = print rightTriangles |
OlderNewer