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
void setup() { | |
size(200, 200); | |
for (var i = 0; i < 10000; i++) { | |
var x = (Math.random() - 0.5) * 150; | |
var y = (Math.random() - 0.5) * 150; | |
if ((Math.sqrt((x * x) + (y * y))) > 75) continue; | |
point(x + 100, y + 100); | |
} |
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
$('p').each(function() { | |
if($(this).html() == '' && $(this).text() == '') { | |
$(this).remove() | |
} | |
}); |
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
# 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 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 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 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 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 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
extension UIColor { | |
enum Error: ErrorType { | |
case Parsing(String) | |
} | |
convenience init(hex input: String) throws { | |
let hex = input.stringByTrimmingCharactersInSet(NSCharacterSet.alphanumericCharacterSet().invertedSet) | |
var int = UInt32() | |
guard NSScanner(string: hex).scanHexInt(&int) else { | |
throw Error.Parsing("Unable to scan hexadecimal integer") |
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
import Foundation | |
// Must use <T> instead of <T: AnyObject> to be able to | |
// convert to structs (value types) like String. | |
func cast<T>(object: AnyObject) -> T? { | |
return object as? T | |
} | |
let string: String? = cast("i'm a string!") |
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 'rubygems' | |
require 'benchmark/ips' | |
require 'ruby-prof' | |
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), 'lib') | |
require 'jbuilder' | |
require 'jbuilder/jbuilder_template' | |
module Rails | |
def self.cache |
NewerOlder