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
require 'pathname' | |
def count_lines(pathname) | |
count = 0 | |
pathname.each_child do |child| | |
if child.directory? | |
count = count + count_lines(child) |
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
require 'formula' | |
class Libcxx < Formula | |
homepage 'http://llvm.org/' | |
url 'http://llvm.org/releases/3.3/libcxx-3.3.src.tar.gz' | |
sha1 '7bea00bc1031bf3bf6c248e57c1f4e0874c18c04' | |
def install | |
cd './lib' 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
x = 5 | |
y = 10 | |
add = (x, y) => | |
x + y | |
end | |
z = add x, y | |
times = (i, fn) => | |
iteration = (j) => | |
switch j < 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
require 'parslet' | |
require 'pp' | |
class Parser < Parslet::Parser | |
rule(:lparen) { str('(') >> space? } | |
rule(:rparen) { str(')') >> space? } | |
rule(:space) { match('\s').repeat(1) } | |
rule(:space?) { space.maybe } | |
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 DoNotation | |
class DSL | |
def initialize(&block) | |
@first_lets = [] | |
@proc_sources = [] | |
@variables = Hash[] |
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
#include <vector> | |
#include <iostream> | |
#include <type_traits> | |
#include <boost/preprocessor.hpp> | |
#define GET_TYPE(n, array) \ | |
BOOST_PP_TUPLE_ELEM(2, 0, BOOST_PP_ARRAY_ELEM(n, array)) | |
#define GET_ARG(n, array) \ | |
BOOST_PP_TUPLE_ELEM(2, 1, BOOST_PP_ARRAY_ELEM(n, array)) |
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
#include <type_traits> | |
#include <vector> | |
#include <iostream> | |
#include <cstdlib> | |
#include <ctime> | |
#include <cmath> | |
template <typename TImpl> | |
class Enumerator | |
{ |
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 get_ssid | |
airport = '/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I' | |
`#{airport}`.split("\n").each do |line| | |
words = line.split | |
if words[0] == 'SSID:' | |
return words[1] | |
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
require 'benchmark' | |
class Test | |
mcount = 1000 | |
mcount.times do |i| | |
class_eval "def method#{i}; 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
tbl = table do | |
:foo | :bar | :baz | |
1 | 2 | 3 | |
1 | 3 | 5 | |
end # => [{:foo=>1, :bar=>2, :baz=>3}, {:foo=>1, :bar=>3, :baz=>5}] | |
tbl2 = table :horizontal do | |
:foo | 1 | 1 | |
:bar | 2 | 3 | |
:baz | 3 | 5 |
OlderNewer