Skip to content

Instantly share code, notes, and snippets.

@hitsujiwool
hitsujiwool / clock.js
Created August 25, 2012 06:57
clock with changable tick interval
/*!
* clock
* Copyright (c) 2012 hitsujiwool <utatanenohibi@gmail.com>
* MIT Licensed
*/
;(function(exports) {
function Clock(speed) {
@hitsujiwool
hitsujiwool / ibmModel1.js
Created July 15, 2012 04:33
IBM Model 1
/*
* IBM Model 1
*/
(function(exports) {
function train(sentencePairs, iteration) {
iteration = iteration || 100;
var count,
@hitsujiwool
hitsujiwool / app.js
Created May 28, 2012 03:19
module autoload in Node.js
var foo = {};
foo.__defineGetter__('bar', function() {
return require('./bar');
});
foo.bar();
@hitsujiwool
hitsujiwool / fiddle.html
Created April 3, 2012 12:40
JSONP Request Fails in IE6
<a href="javascript:void(0);">click</a>
<div id="log"></div>
@hitsujiwool
hitsujiwool / fiddle.js
Created April 2, 2012 00:52
module export pattern in Node.js
// module pattern 1
(function(exports) {
var ns = {};
ns.method = function() {};
exports.ns = ns;
}(this));
// module pattern 2
var ns = (function(exports) {
exports.method = function() {};
@hitsujiwool
hitsujiwool / fiddle.js
Created March 30, 2012 18:19
What is 'this'
var foo = {
bar: function() {
console.log('this is ' + this.toString());
}
};
var baz = foo.bar;
foo.bar(); // thisはfoo
baz(); // thisはwindow