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 Numeric | |
| Q = ["B", "K", "M", "G", "T", "P", "Z"] | |
| def humanize | |
| index = ( (Math.log(self)/Math.log(10-10**-12)).to_i / 3 ).to_i # to_i to round down | |
| return [ self/10.0**(index*3), Q[index] ].join | |
| 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
| Makefile | |
| *.o | |
| *.so | |
| mkmf.log |
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
| a.out |
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
| grammar Foo | |
| rule top | |
| value? { | |
| def to_ruby | |
| elements.to_ruby | |
| end | |
| } | |
| end | |
| rule value | |
| array / object / primitive |
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
| #!/usr/bin/env ruby | |
| $:.unshift(".") | |
| require "treetop" | |
| require "lisp" | |
| require "pp" | |
| pp LispParser.new.parse("1.1").calculate | |
| pp LispParser.new.parse("( )").calculate | |
| pp LispParser.new.parse("(+)").calculate | |
| pp LispParser.new.parse("(-)").calculate |
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
| #!/usr/bin/env ruby | |
| $:.unshift(".") | |
| require "treetop" | |
| require "huml" | |
| require "pp" | |
| class Huml::MultipleID < Exception; end | |
| class Huml::MultipleName < Exception; end | |
| pp HumlParser.new.parse("%html").cons |
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 LINE = require('./line.js'); | |
| var line = new LINE(); | |
| var email = 'your email'; | |
| var password = 'your password'; | |
| line.login(email, password, function(error, result) { | |
| if (error) { | |
| return; | |
| } |
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
| #!/usr/bin/env perl6 | |
| class A { | |
| has $.a is rw; | |
| } | |
| class B { | |
| has $.b is rw; | |
| } |
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
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <sys/types.h> | |
| #include <sys/sysctl.h> | |
| char * | |
| cpu_name() { | |
| size_t buffer_size = 100; | |
| char * buffer = malloc(sizeof(char) * buffer_size); | |
| sysctlbyname("machdep.cpu.brand_string", buffer, &buffer_size, NULL, 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
| #if defined(__APPLE__) && defined(__MACH__) | |
| #define OS "Mac OS X" | |
| #endif | |
| #if defined(__unix__) | |
| #if defined(__linux__) | |
| #define OS "Linux" | |
| #else | |
| #define OS "UNIX"; | |
| #endif |