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 m | |
| def m | |
| puts "bar" | |
| end | |
| puts "foo" | |
| end | |
| m #=> prints "foo\n" | |
| m #=> prints "bar\n" |
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 Meta_Buffer | |
| def save | |
| puts "no modifications" | |
| end | |
| def read | |
| "" | |
| 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
| #birthday.rb | |
| birthdays_taken = [] | |
| doubles = false | |
| while( !doubles ) do | |
| if birthdays_taken.include?(y=rand(365)) | |
| doubles = true | |
| end | |
| birthdays_taken << y | |
| 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
| require 'console_splash' | |
| splsh = ConsoleSplash.new() | |
| colorSchemes = [{:bg=>:black}, {:bg=>:white}] | |
| (0..splsh.lines-1).each do |line| | |
| (0..splsh.columns-1).each do |column| | |
| splsh.write_pixel(line, column, ' ', colorSchemes[0]) | |
| colorSchemes.reverse! | |
| end | |
| colorSchemes.reverse! |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 mult(a, b) | |
| (a.to_s(b)+"0").to_i(b) | |
| 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
| public class Herp { | |
| Herp cur; | |
| public Herp() { | |
| cur = this; | |
| } | |
| /* Doesn't work... :( | |
| public void test() { | |
| System.out.println(this.this.this); |
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 BlankSlate | |
| # BlankSlate provides a class with only the bare-bones recommended methods | |
| # without, you know, breaking ruby really really bad... | |
| # go through every method | |
| instance_methods.each do |func| | |
| # if it's a reserved method, don't remove it << these methods actually | |
| # prompt a warning if you try to remove them! | |
| if !func.match(/^(__|instance_eval|object_id)/) |
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
| print "Enter Name: " | |
| name = gets.chomp | |
| Greeter = Class.new do | |
| puts "Hold up a second #{name}, Greeter is starting up..." | |
| define_method :greet do | |
| puts "#{['hey', 'hello', 'howdy', 'yo'].shuffle[0]} #{name}" | |
| 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
| var cap = -Math.log(0); | |
| var ultimateSwitchCase = "switch(x.toString())\n{"; | |
| for( var i=0; i < cap; i++ ) { | |
| ultimateSwitchCase += "\tcase "+i+":\n\t\treturn \""+['even','odd'][i%2]+"\";\n"; | |
| } | |
| ultimateSwitchCase += "}"; | |
| eval(ultimateSwitchCase); |
OlderNewer