Discover gists
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
Epsilon = 1e-10 | |
def d_dx(&f) # :yields: x | |
Proc.new do |x| | |
(f[x + Epsilon] - f[x])/Epsilon | |
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
$logger = Object.new { | |
#now I want to override stuff in here | |
def foo | |
"bar" | |
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
square x = x * x |
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
while true { | |
program_logic(); | |
cout << "Do you want to play again?"; | |
}; | |
bool b_keepPlaying = true; | |
while b_keepPlaying { | |
program_logic(); | |
cout << "Do you want to play again?"; |
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
$s = Time.now | |
$logger = Object.new | |
def $logger.method_missing(sym, *args) | |
puts "[%s, %.3f] %s" % [sym.to_s.upcase, Time.now - $s, args.join(' ')] | |
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
##-- makedate: 日付文字列の作成 | |
sub makedate { | |
my($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=(localtime); | |
sprintf( "%04.4d%02.2d%02.2d%02.2d%02.2d%02.2d", | |
1900+$year,$mon+1,$mday,$hour,$min,$sec); | |
} |
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
<? | |
// a comment | |
foreach ($things as $thing) { | |
echo $thing; | |
} | |
?> |
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
FART |
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
i love porn |