- OS X Mountain Lion (10.8.1)
- XCode 4.5.1 with "Command Line Tools" installed in Preferences > Downloads > Components
- MacPorts Mountain Lion installer.
Install dependencies: (you might want a grab a coffee)
sudo port install boehmgc pcre mysql5 ocaml
package main | |
import ( | |
"fmt" | |
"reflect" | |
) | |
type Foo struct { | |
FirstName string `tag_name:"tag 1"` | |
LastName string `tag_name:"tag 2"` |
// Boilerplate | |
function objectUnion(definer) { | |
var defined = 0, length = 0, isDefined = false, definitions, key; | |
definitions = definer(function() { | |
var names = arguments, fold; | |
if(isDefined) { | |
throw new TypeError('This objectUnion has already been defined'); | |
} | |
function Ctor() {} |
Install dependencies: (you might want a grab a coffee)
sudo port install boehmgc pcre mysql5 ocaml
// Note: there are bugs in hygienic renaming, so this doesn't work all the time yet. | |
macro varr { | |
case [$var (,) ...] = $expr => { | |
var i = 0; | |
var arr = $expr; | |
$(var $var = arr[i++];) ... | |
} |
var lib = require('./lib'), | |
位 = lib.method('show', lib.isNumber, function(n) { | |
return n.toString(2); | |
}); | |
exports.showBinaryTimesTwo = 位.bind(位.showTimesTwo)(位); |
macro $do { | |
case { $y:expr } => { | |
$y | |
} | |
case { $x:ident <- $y:expr $rest ... } => { | |
位['>=']($y, function($x) { | |
return $do { $rest ... } | |
}); | |
} | |
} |
An experimental Javascript library that can be used for asynchronous control flow, non-determinism, parsing, and other kinds of computations which implement the interface:
bind :: m a -> (a -> m b) -> m b
return :: a -> m a
This gist is a temporary living situation for do.js, and will most likely be expanded into a full blown Github repository in the future.
First, you have to enable profiling
> db.setProfilingLevel(1)
Now let it run for a while. It collects the slow queries ( > 100ms) into a capped collections, so queries go in and if it's full, old queries go out, so don't be surprised that it's a moving target...
/* | |
Copyright (c) 2011 Andrei Mackenzie | |
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE |
function levenshtein(s1, s2) { | |
// http://kevin.vanzonneveld.net | |
// + original by: Carlos R. L. Rodrigues (http://www.jsfromhell.com) | |
// + bugfixed by: Onno Marsman | |
// + revised by: Andrea Giammarchi (http://webreflection.blogspot.com) | |
// + reimplemented by: Brett Zamir (http://brett-zamir.me) | |
// + reimplemented by: Alexander M Beedie | |
// * example 1: levenshtein('Kevin van Zonneveld', 'Kevin van Sommeveld'); | |
// * returns 1: 3 |