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
~/code/go/master-worker % ./master-worker | |
Sat Dec 17 19:43:08 PST 2011 | |
Sat Dec 17 19:43:08 PST 2011 | |
Sat Dec 17 19:43:08 PST 2011 | |
Sat Dec 17 19:43:08 PST 2011 | |
Sat Dec 17 19:43:08 PST 2011 | |
Sat Dec 17 19:43:08 PST 2011 | |
Sat Dec 17 19:43:08 PST 2011 | |
Sat Dec 17 19:43:08 PST 2011 | |
Sat Dec 17 19:43:08 PST 2011 |
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
~/code/go/master-worker % ls -l | |
total 16 | |
-rw-r--r-- 1 mikewadhera staff 106 Dec 17 17:55 Makefile | |
-rw-r--r-- 1 mikewadhera staff 83 Dec 17 17:34 master-worker.go | |
~/code/go/master-worker % more Makefile | |
include $(GOROOT)/src/Make.inc | |
TARG=master-worker | |
GOFILES=master-worker.go | |
include $(GOROOT)/src/Make.pkg |
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 Emitter | |
def initialize(&block) | |
@block = block | |
end | |
def run(nodes, &block) | |
nodes.each do |id, node| | |
block.call(Fiber.new { | |
@block.call(id, node, 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 Proc | |
def curry(*args) | |
if args.size < self.arity | |
args_string = ('a'..'z').take(self.arity-args.size).join(',') | |
given_args = [] | |
args.size.times {|i| given_args << "args[#{i}]"} | |
given_args = given_args.join(", ") | |
eval "lambda {|#{args_string}| self.call(#{given_args}, #{args_string})}" | |
elsif args.size > self.arity | |
raise ArgumentError, "Wrong # of arguments to curried function(#{args.size} for #{self.arity.size})" |
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 'fiber' | |
# lazy_reduce([1,2,3], 0) { |o,m| o + m } # => 6 | |
def lazy_reduce(enumerable, memo, &block) | |
generator = Fiber.new { enumerable.each { |o| Fiber.yield(o) } } | |
loop do | |
if generator.alive? | |
memo = block.call(generator.resume, memo) | |
else |
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
Doing: BitlyProvider | |
mkdir -p /Users/mikewadhera/code/involver-rails/app/models/short_url_provider | |
mv /Users/mikewadhera/code/involver-rails/app/models/url_providers/bitly_provider.rb -> /Users/mikewadhera/code/involver-rails/app/models/short_url_provider/bitly_provider.rb | |
Doing: ShortUrlProvider | |
mkdir -p /Users/mikewadhera/code/involver-rails/app/models | |
mv /Users/mikewadhera/code/involver-rails/app/models/url_providers/short_url_provider.rb -> /Users/mikewadhera/code/involver-rails/app/models/short_url_provider.rb | |
Doing: User | |
mkdir -p /Users/mikewadhera/code/involver-rails/app/models | |
mv /Users/mikewadhera/code/involver-rails/app/models/user.rb -> /Users/mikewadhera/code/involver-rails/app/models/user.rb | |
Doing: UserError |
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 FileOrganizer | |
def initialize(root, home, debug=false) | |
@root = root | |
@home = home | |
@debug = debug | |
end | |
def organize_by_class_lineage(klass, current_path, lineage=[]) | |
case klass.parent |
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
~/code/queueable % file_logging? script/console | |
Loading queueable gem | |
jruby-1.5.2 :001 > RAILS_ROOT = "." | |
=> "." | |
jruby-1.5.2 :002 > class F < Queueable::Tasks | |
jruby-1.5.2 :003?> self.backend = :file | |
jruby-1.5.2 :004?> self.queue = "pending/test.log" | |
jruby-1.5.2 :005?> def echo(arg) |
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
{{ foo }} | |
{% bar baz: "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
// Abstract Types and for loop | |
object Iterables { | |
def filter[T](all: Iterable[T], predicate: T => Boolean) : Iterable[T] = { | |
for { | |
t <- all; | |
if predicate(t) | |
} yield t | |
} |