This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var foo = { | |
bar: function() { | |
console.log('this is ' + this.toString()); | |
} | |
}; | |
var baz = foo.bar; | |
foo.bar(); // thisはfoo | |
baz(); // thisはwindow |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// module pattern 1 | |
(function(exports) { | |
var ns = {}; | |
ns.method = function() {}; | |
exports.ns = ns; | |
}(this)); | |
// module pattern 2 | |
var ns = (function(exports) { | |
exports.method = function() {}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<a href="javascript:void(0);">click</a> | |
<div id="log"></div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var foo = {}; | |
foo.__defineGetter__('bar', function() { | |
return require('./bar'); | |
}); | |
foo.bar(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* IBM Model 1 | |
*/ | |
(function(exports) { | |
function train(sentencePairs, iteration) { | |
iteration = iteration || 100; | |
var count, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*! | |
* clock | |
* Copyright (c) 2012 hitsujiwool <[email protected]> | |
* MIT Licensed | |
*/ | |
;(function(exports) { | |
function Clock(speed) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# -*- coding: utf-8 -*- | |
# | |
# CSS Sprite Generator | |
# require imagemagick | |
# require Ruby >= 1.9 | |
# Usage: | |
# ruby csssprite.rb file1 file2 file3 [options] | |
# Options: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Phrase Extraction | |
*/ | |
;(function(exports) { | |
function extractPhrases(e, f, a) { | |
var fStart, | |
fEnd, | |
result = []; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'); | |
server = http.createServer(function (req, res) { | |
res.writeHead(200, {'Content-Type': 'text/plain'}); | |
res.end('Hello World\n'); | |
server.close(); | |
}); | |
server.listen(8080, 0, function () { | |
console.log('Server running at http://localhost:8080/'); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function App() { | |
this.specAndMessages = []; | |
}; | |
App.prototype.addSpecAndMessage = function(spec, message) { | |
this.specAndMessages.push({ | |
spec: spec, | |
message: message | |
}); | |
}; |
OlderNewer