Skip to content

Instantly share code, notes, and snippets.

;; Monty Hall problem (Let's Make a Deal gameshow)
;; http://www.marilynvossavant.com/articles/gameshow.html
(use '(incanter core stats charts))
;; set a simulation sample size
(def n 10000)
;; generate samples of initial-guesses, prize-doors, and switch decisions
(def initial-guesses (sample [1 2 3] :size n))
(def prize-doors (sample [1 2 3] :size n))
anonymous
anonymous / bm_ets.erl
Created September 13, 2010 17:15
-module(bm_ets).
-export([run/0]).
run() ->
io:format("Testing List~n"),
List = fill_list(),
perftest(1000, fun() -> run_list(List) end),
io:format("Testing ETS~n"),
require 'em-resolv-replace'
require 'em-synchrony/em-http'
require 'fiber_pool'
gem 'em_postgresql'
class Pool
delegate :spawn, to: :@pool
attr_reader :processed, :concurrent
def initialize(size)
@igrigorik
igrigorik / webapp.rb
Created November 13, 2010 21:28
Inspired by @JEG2's talk at Rubyconf... Any ruby object, as a webapp! 'Cause we can. :-)
require 'rubygems'
require 'rack'
class Object
def webapp
class << self
define_method :call do |env|
func, *attrs = env['PATH_INFO'].split('/').reject(&:empty?)
[200, {}, send(func, *attrs)]
end
@mjtko
mjtko / handlebarsTemplateEngine.js
Created May 12, 2011 22:39
knockout template engine for handlebars.js
/*
Handlebars Template Engine for Knockout JavaScript library
*//*!
Copyright (c) 2011 Mark J. Titorenko
License: MIT (http://www.opensource.org/licenses/mit-license.php)
*/
ko.handlebarsTemplateEngine = function () {
// adapted from MooTools.Element
//
// This is necessary to allow us to easily deal with table
@michiakig
michiakig / ants.clj
Created July 19, 2011 22:37
Clojure ant sim from Rich Hickey
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Ant sim ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Copyright (c) Rich Hickey. All rights reserved.
; The use and distribution terms for this software are covered by the
; Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
; which can be found in the file CPL.TXT at the root of this distribution.
; By using this software in any fashion, you are agreeing to be bound by
; the terms of this license.
; You must not remove this notice, or any other, from this software.
;dimensions of square world
@stuartsierra
stuartsierra / test_clj_byte_chunk_seq.clj
Created December 13, 2011 13:43
Clojure chunked binary sequences
(ns test-clj-byte-chunk-seq
(:import (java.io InputStream OutputStream
FileInputStream FileOutputStream)))
(set! *warn-on-reflection* true)
(def ^:const ONE_MEG (* 1024 1024))
(deftype ByteArrayChunk [^bytes array ^int offset ^int end]
clojure.lang.IChunk
@codification
codification / proc.clj
Created March 6, 2012 08:10
Clojure asynchronous process
(ns proc
(:import [java.lang ProcessBuilder])
(:use [clojure.java.io :only [reader writer]]))
(defn spawn [& args]
(let [process (-> (ProcessBuilder. args)
(.start))]
{:out (-> process
(.getInputStream)
(reader))
@piotrga
piotrga / gist:2423885
Created April 19, 2012 20:17
akka-camel producer/consumer
import akka.camel.{Consumer, CamelMessage}
import akka.actor.{Props, ActorSystem}
import akka.util.Timeout
import akka.util.duration._
import akka.pattern.ask
import scaladays2012.{Email, EmailerConfig, Emailer}
class HttpConsumerExample extends Consumer{
def endpointUri = "jetty://http://0.0.0.0:1111/demo"
@butaji
butaji / hack.sh
Created July 31, 2012 20:13 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#