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 valid_ruby?(str) | |
| catch(:valid) { | |
| eval("BEGIN{throw :valid,true};#{str}") | |
| } | |
| rescue SyntaxError | |
| false | |
| end | |
| p valid_ruby?("123") | |
| p valid_ruby?("'") |
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 Parser | |
| def force; self end | |
| def |(other) | |
| DisjunctiveParser.new(self, other) | |
| end | |
| def >>(other) | |
| SequentialParser.new(self, other) | |
| 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
| // app.js | |
| NoBug = true; | |
| // test/bug-test.js | |
| buster.testCase('Buster', { | |
| 'should not be buggy': function() { | |
| assert(NoBug); | |
| } | |
| }); |
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
| diff --git a/ci_environment/perlbrew/attributes/default.rb b/ci_environment/perlbrew/attributes/default.rb | |
| new file mode 100644 | |
| index 0000000..e69de29 | |
| diff --git a/ci_environment/perlbrew/attributes/multi.rb b/ci_environment/perlbrew/attributes/multi.rb | |
| new file mode 100644 | |
| index 0000000..2c9dad4 | |
| --- /dev/null | |
| +++ b/ci_environment/perlbrew/attributes/multi.rb | |
| @@ -0,0 +1,5 @@ | |
| +default[:perlbrew][:notests] = true |
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 'ffi' | |
| class Object | |
| def memory_location | |
| object_id * 2 | |
| end | |
| def to_pointer | |
| FFI::Pointer.new(memory_location) | |
| 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
| # Place this in test/ | |
| # | |
| # Run your tests with: | |
| # | |
| # prove -e 'ruby -Ilib:test' -v t/*.rb | |
| # | |
| # See the bottom for usage. | |
| require 'minitest/unit' |
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 Register < Struct.new(:name) | |
| BASIC = %w[A B C X Y Z I J].map(&:to_sym) | |
| SPECIAL = %w[POP PEEK PUSH SP PC O].map(&:to_sym) | |
| ALL = BASIC + SPECIAL | |
| attr_accessor :plus | |
| def value | |
| case name | |
| when *BASIC |
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
| ; Printing stuff to the screen | |
| ; by Markus Persson | |
| #macro clear(color) { | |
| push(a) | |
| set a, color | |
| shl a, 8 | |
| bor a, 0x20 | |
| mem_fill(0x8000, 0x180, a) | |
| set [screen_p], 0 |
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
| Some free books from Amazon, some blog posts, some textbooks, some poetry. | |
| Wool | |
| Howey, Hugh | |
| Liars and Outliers: Enabling the Trust that Society Needs to Thrive | |
| Schneier, Bruce | |
| Brainstorming Doesn’t Really Work : The New Yorker |
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 Symbol | |
| def | other | |
| -> arg { other.to_proc[arg.send(self)] } | |
| end | |
| def call(*args) | |
| -> arg { arg.send(self, *args) } | |
| end | |
| end |