Skip to content

Instantly share code, notes, and snippets.

var sys = require('sys'),
times = 500000
function bm(label, fn) {
var start = +new Date
fn()
sys.puts(' ' + label + ' : ' + (+new Date - start) + ' ms')
};
/*
MooTools 1.2 Custom Backwards-Compatibility Library
By David Isaacson
Portions from Mootools 1.2 by the MooTools production team (http://mootools.net/developers/)
Copyright (c) 2006-2007 Valerio Proietti (http://mad4milk.net/)
Copyright (c) 2008 Siafoo.net
Cleaned up, shortened and logging added by Nathan White (http://www.nwhite.net)
*/
/* Window.Growl, version 2.0: http://icebeat.bitacoras.com
* Daniel Mota aka IceBeat <daniel.mota@gmail.com>
* Updated to 1.2b2 by Paul Streise <paulstreise@gmail.com>
* Updated to 1.2.2 by nwhite.net
--------------------------------------------------------------------------*/
var Gr0wl = {};
Gr0wl.Base = new Class({
Implements : [Chain],
Element.implement({
truncate : function(len,str,mid){
var str = str || '...';
var mid = !!mid;
var w = this.getSize().x;
if( w < len) return this;
var txt = this.get('text');
var char_size = Math.ceil(w / txt.length);
Element.implement({
truncate : function(len,str,mid){
var str = str || '...';
var mid = !!mid;
var w = this.getSize().x;
if( w < len) return this;
var txt = this.get('text');
var char_size = Math.ceil(w / txt.length);
Number.implement({
parsePermissions : function(){
var types = {r : 4, w : 2, x : 1 }, levels = {u : 1, g : 8, o : 64 }, perms = {};
for(l in levels){
for(t in types) perms[l+t] = !!(this & (levels[l] * types[t]));
}
return perms;
}
});
@nw
nw / Class.Mutators.Singleton.js
Created May 9, 2009 02:08
Class Initializers (Singleton)
Class.Initializers = {};
Class.initializer = function(obj){ return this._initializer_ = obj; }
Class.Mutators.initialize = function(initialize){
if(!this._initializer_) return initialize; // quick exit
return function(){
this._init_ = initialize;
for (var modifier in Class.Initializers) {
if (!this[modifier]) continue;
this[modifier] = Class.Initializers[modifier].call(this, this[modifier]);
var games = [
"4.....8.5.3..........7......2.....6.....8.4......1.......6.3.7.5..2.....1.4......",
"52...6.........7.13...........4..8..6......5...........418.........3..2...87.....",
"6.....8.3.4.7.................5.4.7.3..2.....1.6.......2.....5.....8.6......1....",
"48.3............71.2.......7.5....6....2..8.............1.76...3.....4......5....",
"....14....3....2...7..........9...3.6.1.............8.2.....1.4....5.6.....7.8...",
"......52..8.4......3...9...5.1...6..2..7........3.....6...1..........7.4.......3.",
"6.2.5.........3.4..........43...8....1....2........7..5..27...........81...6.....",
".524.........7.1..............8.2...3.....6...9.5.....1.6.3...........897........",
@nw
nw / hilow.js
Created March 25, 2015 03:20
Hi Low Guess Game
$(function(){
var input = $('#guess')
, btn = $('#guess_btn')
, status = $('#guesses')
, reset = $('#reset');
var guesses = 0;