Skip to content

Instantly share code, notes, and snippets.

@francescoagati
francescoagati / bacon.rb
Last active December 30, 2015 02:09
wrapping Bacon.js Streams with Opal
Bacon = Native `Bacon`
class ProxyStream
def initialize(wrapped)
@wrapped = wrapped
end
def method_missing(method,*args)
@francescoagati
francescoagati / slim.php
Last active December 28, 2015 08:29
pratphall and slim
<?php
$app = new Slim\Slim();
$app->get('/hello/:name', function ($name) {
echo('Hello' . $name);
});
$app->run();
@francescoagati
francescoagati / meta.coffee
Created September 29, 2013 00:27
metaprogramming for coffeescript
meta = (context,fn) ->
def =
accessors: (names...) -> @accessor(name) for name in names
accessor: (name) ->
context["get_#{name}"] = -> @[name]
context["set_#{name}"] = (v) -> @[name] = v
fn(def)
class Pippa
@francescoagati
francescoagati / app.coffee
Created July 3, 2013 23:08
node.js + express.js + bacon.js -> wrap express.js in functional reactive programming
express = require("express")
Bacon = require("baconjs")
app = express()
route = (app) -> (path) ->
bus = new Bacon.Bus()
app.get path, (req,res) ->
bus.push
req: -> req
@francescoagati
francescoagati / move.coffee
Created February 1, 2013 18:19
play with async.js e move.js for sequence animations
$(document).ready ->
wait = (n) -> (next) -> setTimeout (-> next(null) ), n
waitFor = (fn) -> (next) -> fn(next)
moveGenerator =
(action) ->
(selector,args...) ->
@francescoagati
francescoagati / setup.sh
Last active December 10, 2015 16:29 — forked from mrsweaters/setup.sh
#!/usr/bin/env bash
# login as root and run this script via bash & curl:
apt-get update
apt-get install -y build-essential bison openssl libreadline5 libreadline5-dev curl \
git-core zlib1g zlib1g-dev libopenssl-ruby libcurl4-openssl-dev libssl-dev \
libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libmysqlclient-dev \
mysql-client mysql-server
@francescoagati
francescoagati / benchmark.rb
Created December 9, 2012 00:38
simple sort benchmarking between jruby 1.7.1 and ruby 1.9.3
require 'benchmark'
array = (1..100000).map { rand }
Benchmark.bmbm do |x|
x.report("sort!") { (0..20).each { array.dup.sort! } }
x.report("sort") { (0..20).each { array.dup.sort! } }
end
@francescoagati
francescoagati / process.rb
Created December 8, 2012 22:17
benchmarking parallel gem with ruby 1.9.3, jruby 1.71 - process vs thread
require 'benchmark'
require 'parallel'
array = (1..100000).map { rand }
Benchmark.bmbm do |x|
x.report("sort!") { Parallel.map((0..20), :in_process=>8) { array.dup.sort! } }
x.report("sort") { Parallel.map((0..20), :in_process=>8) { array.dup.sort! } }
end
@francescoagati
francescoagati / main.hx
Created November 22, 2012 21:23
haxe-continuation: how normal functions are converted to cps functions
import com.dongxiguo.continuation.Continuation;
@:build(com.dongxiguo.continuation.Continuation.cpsByMeta("cps"))
class Sample
{
static function delay(n:Dynamic,handler:Dynamic->Dynamic):Void {
var fn=function() {
handler(n);