Skip to content

Instantly share code, notes, and snippets.

Let's make a list of Sinatra-based apps!
Apps:
- http://github.com/cschneid/irclogger "Sinatra based irclogger.com"
- http://github.com/rtomayko/wink "minimalist blogging engine"
- http://github.com/foca/integrity "The easy and fun Continuous Integration server"
- http://github.com/sr/git-wiki "git-powered wiki"
- http://github.com/entp/seinfeld "Seinfeld-inspired productivity calendar to track your public github commits."
- http://github.com/karmi/marley "Marley, the blog engine without <textareas>."
- http://github.com/ichverstehe/gaze "Serve up your Markdown files with this tiny Sinatra app!"
@zaach
zaach / gist:221544
Created October 29, 2009 15:58 — forked from teeler/gist:205407
(* a simple echo server in ocaml
* -----------------------------
* uses a high level networking function, similar to SocketServer
* in python, called 'establish_server', see here:
* http://caml.inria.fr/pub/docs/manual-ocaml/libref/Unix.html#VALestablish_server
*)
(*
our echo function
in -> out -> unit
@zaach
zaach / workflow.md
Created January 26, 2010 21:10 — forked from gstark/workflow.md

Semantic Versioning

Details:

Versions are denoted using a standard triplet of integers: MAJOR.MINOR.PATCH. The basic intent is that MAJOR versions are incompatible, large-scale upgrades of the API. MINOR versions retain source and binary compatibility with older minor versions, and changes in the PATCH level are perfectly compatible, forwards and backwards.

@zaach
zaach / Gemfile
Created February 19, 2010 05:27 — forked from indirect/Gemfile
# include at least one source and the rails gem
source :gemcutter
gem "rails", "~> 2.3.5", :require => nil
gem "sqlite3-ruby", :require => "sqlite3"
group :development do
# bundler requires these gems in development
gem 'rails-footnotes'
end
import scala.collection.mutable._
// I want these std functions to be implicit:
implicit def tupled[a1, a2, b] = Function.tupled[a1, a2, b](_)
implicit def untupled[a1, a2, b] = Function.untupled[a1, a2, b](_)
class Connection
class ConnectionPool(size: Int) {
def withConnection[A](f: Connection => A) = f(new Connection)
APACHE:
$ ab -k -c 50 -n 20000 http://127.0.0.1/statread.js 2>&1 | grep "Requests per second"
Requests per second: 12370.69 [#/sec] (mean)
NGINX:
$ ab -k -c 50 -n 20000 http://127.0.0.1/statread.js 2>&1 | grep "Requests per second"
Requests per second: 20262.73 [#/sec] (mean)
NODE:
$ ab -k -c 50 -n 20000 http://127.0.0.1:8000/statread.js 2>&1 | grep "Requests per second"

Tests to do:

Create an environment with 4 (at least >2) servers each running a single process with 40 writing threads. Each writing thread should insert a new document at some prescribed rate (maybe make the threads and the document insertion a configuration parameter?)

Have each of these servers writing to one or more of the nosql "servers" (depending on architecture) -- maybe run one test where all the writes are going to one server, and another where they are spread.

Then lets see how long it takes for each of the servers in a cluster to "catch up" (e.g. what is the lag time average and std dev -- if thats even possible to compute) before a new document is replicated around.

Once we have a feel for this, lets repeat the test but pull one server out of the replication environment. We should do this test twice, once where we remove the server gracefully and once violently. In both cases we'll leave the server "offline" for several tens-of-minutes or hours. Then lets compute the number of documents th

// Map/Reduce with Promises on Narwhal+Node
var SYSTEM = require("system");
var EL = require("event-loop");
var Q = require("narwhal/promise");
var UTIL = require("narwhal/util");
// to simulate a long latency, promise-returning API
var delay = function (timeout) {
var deferred = Q.Deferred();

2010 Modularity Olympics

This is a contest, open to programming languages from all nations, to write modular and extensible code to solve the following problem: Implement a service that can run queries on a database.

The Challenge

Sounds simple right? Wrong! A programmer without control over the source-code of that service must be able to later add enhancements such as statistics collecting, timeouts, memoization, and so forth. There are a few more requirements:

  1. the “enhancements” must be specified in a configuration object which is consumed at run-time (e.g., it could be based on user-input).
  2. The enhancements are ordered (stats collecting wraps timeouts, not the other way around) but it must be possible to reverse the order of the enhancements at run-time.
  3. The enhancements must be “surgical” and not “global”. That is, it must be possible to simultaneously have two query services, one reversed and one not reversed, and even have a query service without any enhancements.
var JAKE = require("jake");
var FILE = require("file");
var narcissusPath = FILE.path(require("packages").catalog.narcissus.directory);
JAKE.task("default", function() {
var script = exports.bundle([
{ id : "narcissus/defs", path : narcissusPath.join("lib", "narcissus", "defs.js") },
{ id : "narcissus/parse", path : narcissusPath.join("lib", "narcissus", "parse.js") },
{ id : "narcissus/format", path : narcissusPath.join("lib", "narcissus", "format.js") }