think about results, not steps
- First-Class Functions
think about results, not steps
| // $GOPATH/src/foo/foo.go | |
| package foo | |
| import "fmt" | |
| func init() { | |
| fmt.Println("foo init") | |
| } | |
| func init() { |
Having trouble installing the latest stable version of tmux?
Save yourself some time and run this little fellow!
| package main | |
| import ( | |
| "fmt" | |
| "strings" | |
| ) | |
| func WordCount(s string) map[string]int { | |
| words := strings.Fields(s) | |
| counts := make(map[string](int)) |
| def goodPairings(pies: List[Pie], iceCreams: List[IceCream]): List(Serving[Pie, IceCream]) { | |
| for { | |
| p <- pies | |
| i <- iceCreams | |
| var serving = new Serving(p, i) | |
| if (serving.isGood) | |
| } yield { | |
| serving | |
| } | |
| } |
| var srv = sinon.fakeServer.create(); | |
| srv.autoRespond = true; // server should automatically respond after a timeout | |
| srv.autoRespondAfter = 500; // response timeout in milliseconds | |
| srv.xhr.useFitlers = true; // tell Sinon that some requests should not be faked | |
| // add a filter that will tell Sinon to allowa all requests to access the server | |
| // except fitlers defined when calling Server#fake. | |
| srv.xhr.addFilter(function(method, url, async, username, password) { | |
| var fakedRequest = _.find(Server.fakedRequests, function(request) { | |
| return request.method === method && request.regex.test(url); |
| #!/usr/bin/env ruby | |
| # Usage: | |
| # git clog # prints | |
| # git clog -w # writes | |
| # | |
| # https://gist.github.com/2880525 | |
| module Clog | |
| extend self |
| #!/usr/bin/env jruby | |
| %W{rails/command/server rack webrick webrick/https}.each { |lib| require lib } | |
| ENV['HTTPS'] = 'on' | |
| module Rails | |
| class Server < ::Rack::Server | |
| def default_options | |
| super.merge({ |
| require 'mongoid' | |
| class MongoidCloseConnections | |
| def initialize(app) | |
| @app = app | |
| end | |
| def call(env) | |
| path = env['PATH_INFO'] || '' | |
| begin |