This file contains 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 dotfiles = (function (){ | |
var cmd = function cmd(hyphenE){ | |
var proto = 'ls -a ./ | grep -v'; | |
for(var i=0; i<hyphenE.length; i++){ | |
proto += ' -e '+hyphenE[i]; | |
} | |
return proto; | |
}; | |
var plastic = function plastic(stdout) { |
This file contains 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() { | |
'use strict'; | |
var spawn, dotfiles; | |
spawn = require('child_process').spawn; | |
dotfiles = function() { | |
var ls, grep; | |
ls = spawn('ls', ['-A']); | |
grep = spawn('grep', ['^\\.']); | |
ls.stdout.on('data', function (data) { |
This file contains 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 simpleGenerator(){ | |
yield "first"; | |
yield "second"; | |
yield "third"; | |
for (var i = 0; i < 3; i++) | |
yield i; | |
} | |
var g = simpleGenerator(); | |
console.log(g.next()); // "first" |
This file contains 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.exports = function(grunt) { | |
'use strict'; | |
grunt.initConfig({ | |
watch: { | |
files: ['src/js/*.js', 'spec/*.js'], | |
tasks: 'spec' | |
}, | |
jshint: { | |
files: ['src/js/*.js'], | |
options: { |
This file contains 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 fs = require('fs'); | |
fs.readFile('image.png', function(err, data) { | |
if (err) throw err; | |
console.log(new Buffer(data).toString('base64')); | |
}); |
This file contains 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
/** | |
* @fileOverview Easy to write to load grunt plugin. | |
* @author Daijiro Wachi | |
*/ | |
module.exports = function(grunt) { | |
"use strict"; | |
/** @type {object} pkg */ | |
var pkg = grunt.file.readJSON("package.json"); |
This file contains 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
/** | |
* like PHP's $_GET | |
* @type {Function} $_GET | |
* @param {String} params | |
* @return {Object} hash | |
*/ | |
var $_GET = (function $_GET(params) { | |
'use strict'; | |
// Exception |
This file contains 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 reverseObject(obj) { | |
var outObj = {}; | |
Object.keys(obj).reverse().map(function(k){ | |
outObj obj[k] = obj[k]; | |
}); | |
return outObj; | |
} |
This file contains 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
if(!Object.create) { | |
Object.create = function (o, prop) { | |
'use strict'; | |
var keys = Object.keys(prop); | |
o['__propertiesObject__'] = o['__propertiesObject__'] || {}; | |
keys.map(function(key) { | |
if (key in o) { | |
if (o['__propertiesObject__']['virtual'] !== true) { | |
throw new TypeError("Cannot overide property '"+ key +"' of #<Object>'"); | |
} |
This file contains 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'), | |
registry = 'http://registry.npmjs.org/typescript/'; | |
var list_known = function () { | |
http.get(registry, function(res) { | |
var data = ''; | |
res.setEncoding('utf8') | |
res.on('data', function(str) { | |
data += str; | |
}).on('end', function() { |
OlderNewer