Description and usage:
require ''
.new
Install the rspec gem
| function Metronome(interval, executions, func, context) { | |
| if (interval < 1) { | |
| throw "Interval must be a integer"; | |
| } | |
| if (executions == 0) { | |
| throw "Number of executions must be a positive integer"; | |
| } | |
| // Initialize mutable private members. | |
| var executionsLeft = executions; |
| // Because callbacks are hard. | |
| synchronously = {}; | |
| synchronously.Mutex = function() { | |
| this.locked_ = false; | |
| }; | |
| synchronously.Mutex.prototype.lock = function() { | |
| this.locked_ = true; |
| // Statically serve the content of a directory. By default it picks up the | |
| // current working directory but you can also pass the path using the --path | |
| // command-line flag. | |
| package main | |
| import ( | |
| "flag" | |
| "fmt" | |
| "log" |
| class Enum | |
| include Enumerable | |
| def initialize(input) | |
| @hash = {} | |
| method = input.is_a?(Array) ? :each_with_index : :each | |
| input.send(method) do |key, value| | |
| @hash[key] = value | |
| self.class.send(:define_method, key.to_sym) { value } |
| package main | |
| import "fmt" | |
| type SetNone struct{} | |
| type Set map[interface{}]SetNone | |
| func (s Set) Add(el interface{}) { | |
| s[el] = SetNone{} | |
| } |
| package main | |
| import ( | |
| "fmt" | |
| "regexp" | |
| ) | |
| func GetNamedMatches(exp *regexp.Regexp, | |
| src string, limit int) map[string][]interface{} { | |
| result := make(map[string][]interface{}) |
| # Go upwards the path until the basename is equal | |
| # to your argument. | |
| function cdp { | |
| CURRENT=$(basename $PWD) | |
| until [ $CURRENT == "$*" ]; do | |
| cd .. | |
| CURRENT=$(basename $PWD) | |
| done | |
| } |
| #!/usr/bin/env ruby | |
| =begin | |
| The concept here is to print out the current working | |
| directory (pwd) following i-nodes only. | |
| =end | |
| def pwd | |
| path = [] | |
| loop do |
| require 'test/unit' | |
| Hash::class_eval do | |
| # Flip the Hash so that former keys become values and | |
| # former values become keys. The difference however is | |
| # that if one value is assigned to multiple keys, then | |
| # in the reversed Hash you get an array of values under | |
| # that key. | |
| def reverse |