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
# Fast nested constant implementation | |
class FastNestedConstant : Fancy AST NestedConstant { | |
def initialize: @line string: @string { | |
names = @string split: "::" | |
@toplevel = false | |
if: (@string =~ /^::/) then: { @toplevel = true; names shift } | |
@names = names map: |n| { n to_sym } | |
} | |
def bytecode: g { |
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 Module { | |
forwards_unary_ruby_methods | |
def [constant_name] { | |
""" | |
@constant_name Name (@String@) of constant's name. | |
@return @constant_name's value. | |
Returns the value of the constant with the given name in @self. | |
""" |
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 StateMachine | |
def initialize | |
@transitions = {} | |
end | |
def transition(opts, &block) | |
from = opts[:from] | |
to = opts[:to] | |
@transitions[from] ||= {} | |
@transitions[from][to] = block | |
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
#!/usr/bin/env ruby | |
version = `wget -O - -q http://commondatastorage.googleapis.com/chromium-browser-continuous/Mac/LAST_CHANGE`.strip | |
puts "Downloading Chromium continuous build version: #{version}" | |
STDOUT.flush | |
`wget -O "chromium-mac-continuous-#{version}.zip" http://commondatastorage.googleapis.com/chromium-browser-continuous/Mac/#{version}/chrome-mac.zip` |
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
config.gem "toml", :version => "0.0.4" | |
class BlankSlate | |
class << self | |
# Hide the method named +name+ in the BlankSlate class. Don't | |
# hide +instance_eval+ or any method beginning with "__". | |
def hide(name) | |
# CHANGED: if instance_methods.include?(name.to_s) and | |
if instance_methods.include?(name.to_sym) and | |
name !~ /^(__|instance_eval)/ | |
@hidden_methods ||= {} |
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
use std; | |
use time; | |
import result::{ok, err}; | |
import to_str::*; | |
// Count the number of live neighbors for a given cell. | |
// Neighbors are cells adjacent vertically, horizontally, or diagonally. | |
fn live_neighbors(board: [[bool]], row: int, column: int) -> int { |
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
syntax = r''' | |
<ts> := [ \t]* | |
# Variable delcarations | |
local_var := [a-z], [a-z0-9_]* | |
global_var := [A-Z], [a-z0-9_]+ | |
# The chain of indexes and properties for objects | |
tail := (index/property/func_call)+ | |
index := "[", expression, "]" |
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
// Copyright (C) 2011 by Dirk Gadsden | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy | |
// of this software and associated documentation files (the "Software"), to deal | |
// in the Software without restriction, including without limitation the rights | |
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
// copies of the Software, and to permit persons to whom the Software is | |
// furnished to do so, subject to the following conditions: | |
// | |
// The above copyright notice and this permission notice shall be included in |
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 SpitefulStore | |
# A very mean cache store that loses everything you give it. | |
def read(key) | |
nil | |
end | |
def write(key, value) | |
value | |
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
# This is a light-hearted riposte to rkh's great almost-sinatra (https://github.com/rkh/almost-sinatra) project. | |
%w{rubygems sinatra}.each {|g| require g } | |
get '/' do '<html><head><title>Definitely Sinatra</title></head><body>Hello World</body></html>'; end |