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 Hash subclass stores keys in a case-insensitive manner. | |
class CaseInsensitiveHash < Hash | |
## | |
# @see Hash#[] | |
def [](key) | |
return super(key.downcase) | |
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
>> "///".gsub(%r{/*$}, ".") | |
=> ".." | |
>> "//".gsub(%r{/*$}, ".") | |
=> ".." | |
>> "/".gsub(%r{/*$}, ".") | |
=> ".." | |
>> "".gsub(%r{/*$}, ".") | |
=> "." |
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
# BAD: | |
foo.bar = 25 | |
foo.biz = 'Hello World' | |
foo.bazzle = 42 | |
# GOOD: | |
foo.bar = 25 | |
foo.biz = 'Hello World' | |
foo.bazzle = 42 | |
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
# Author: Cyril Rohr | |
# This has been gemified into the cacheability gem (http://github.com/cryx/cacheability/tree/master) | |
require 'rubygems' | |
require 'rest_client' # sudo gem install rest-client | |
require 'rack/cache' # sudo gem install rack-cache | |
require 'addressable/uri' # sudo gem install addressable | |
module RestClient | |
# this is a quick hack to show how you can use rack-cache as a powerful client cache. |
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 "sync" | |
require "blankslate" | |
class Channel < BlankSlate | |
def initialize | |
@sync = Sync.new | |
@queue = [] | |
end | |
def queue |
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
package com.sporkmonger.rmud.swt.custom; | |
import java.util.ArrayList; | |
import java.util.regex.Matcher; | |
import java.util.regex.Pattern; | |
import org.eclipse.swt.SWT; | |
import org.eclipse.swt.custom.LineStyleEvent; | |
import org.eclipse.swt.custom.LineStyleListener; | |
import org.eclipse.swt.custom.StyleRange; |
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
package com.sporkmonger.util; | |
import java.net.URL; | |
import java.util.ArrayList; | |
public class HydraLoader extends ClassLoader { | |
private ArrayList<ClassLoader> childLoaders = new ArrayList<ClassLoader>(); | |
public HydraLoader() { | |
super(); |
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
let double x = 2 * x;; | |
let sum x y = x + y;; | |
(* How do you get a function 2(x + y) from this? *) | |
let foo = double sum;; (* Obviously doesn't work *) |
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
type expr = | |
Noop | |
| Int of int | |
| Float of float | |
| Seq of expr list | |
| Call of expr * string * expr (* * params *) | |
let print_ast ast = | |
let rec print_ast_internal = function | |
Noop -> "Noop" |
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 "datamapper" | |
class CrawledURI | |
include DataMapper::Resource | |
STORAGE_NAME = "crawled_uris" | |
property :id, Integer, :serial => true | |
# Data | |
property :uri, String, :length => 1024 |