Skip to content

Instantly share code, notes, and snippets.

require 'rubygems'
require 'sinatra'
require 'couchrest'
def db
CouchRest.database!('http://127.0.0.1:5984/play')
end
get '/' do
db.get('2')
Data.bind{text_box.text = "#{user.name} (#{user.email})"}
# or
text_box.bind(:text){"#{user.name} (#{user.email})"}
# this would use parseTree
# http://www.igvita.com/2008/12/11/ruby-ast-for-fun-and-profit/
# to get the AST for the block
# and figure out that it needs to invoke the block when
# user.name or user.email has changed, and so registers a property
# change event. You will probably need to build a property change
# event system. Maybe like
@airportyh
airportyh / Modernizr.tutti
Created December 22, 2010 21:10
Loading Modernizr inside Tutti
Connecting...
Welcome to Tutti - interactively run Javascript on multiple browsers!
====================================================================
You can execute any Javascript in the shell below.
Connected browsers: Firefox 3.6, IE 8.0
To connect another browser, just copy-n-paste the current URL into it.
Firefox 3.6 disconnected
// Ratio of Obese (BMI >= 30) in U.S. Adults, CDC 2008
var data = [
, .187, .198, , .133, .175, .151, , .1, .125, .171, , .172, .133, , .108,
.142, .167, .201, .175, .159, .169, .177, .141, .163, .117, .182, .153, .195,
.189, .134, .163, .133, .151, .145, .13, .139, .169, .164, .175, .135, .152,
.169, , .132, .167, .139, .184, .159, .14, .146, .157, , .139, .183, .16, .143
];
var color = d3.scale.linear()
.domain([d3.min(data), d3.max(data)])
(function(){d3 = {version: "2.0.3"}; // semver
if (!Date.now) Date.now = function() {
return +new Date;
};
if (!Object.create) Object.create = function(o) {
/** @constructor */ function f() {}
f.prototype = o;
return new f;
};
var d3_arraySubclass = [].__proto__?
@airportyh
airportyh / bubble.css
Created August 26, 2011 04:04
Moving bubbles
circle {
stroke: #fff;
stroke-width: 1.5px;
}
text {
font: 10px sans-serif;
}
@airportyh
airportyh / detect.js
Created January 4, 2012 06:19
Script to detect whether a test file is written in QUnit or Jasmine
// Script to detect whether a js unit test file is written in QUnit or Jasmine.
// Usage:
// node detect.js <test file>
var parser = require('uglify-js').parser
, fs = require('fs')
, filename = process.argv[2]
var patterns = {
jasmine: [
@airportyh
airportyh / config.log
Created February 13, 2012 04:16
RVM error installing ruby 1.9.3
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by configure, which was
generated by GNU Autoconf 2.68. Invocation command line was
$ ./configure --prefix=/Users/airportyh/.rvm/rubies/ruby-1.9.3-p0 --enable-shared --disable-install-doc --with-libyaml --with-opt-dir=/Users/airportyh/.rvm/usr
## --------- ##
## Platform. ##
@airportyh
airportyh / async.html
Created February 23, 2012 04:03
Detection of whether the current script has been included synchronously or asynchronously
<!doctype html>
<html>
<head>
<title>Async</title>
</head>
<body>
<h1>Async</h1>
<script>
function loadScript(url, callback){
function cb(){

On Windows

B:\testem\node_bug>node -v
v0.8.6

B:\testem\node_bug>mocha -V
1.3.2

B:\testem\node_bug>node spawn.js