Skip to content

Instantly share code, notes, and snippets.

View watilde's full-sized avatar
👋
Hi

Daijiro Wachi watilde

👋
Hi
View GitHub Profile
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) {
@watilde
watilde / dotfiles.js
Created May 3, 2013 18:57
Get the name of Dotfiles;
(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) {
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"
@watilde
watilde / gist:5617571
Created May 21, 2013 05:03
gruntfile.js
module.exports = function(grunt) {
'use strict';
grunt.initConfig({
watch: {
files: ['src/js/*.js', 'spec/*.js'],
tasks: 'spec'
},
jshint: {
files: ['src/js/*.js'],
options: {
@watilde
watilde / gist:5667946
Last active December 17, 2015 20:29
Image's base64
var fs = require('fs');
fs.readFile('image.png', function(err, data) {
if (err) throw err;
console.log(new Buffer(data).toString('base64'));
});
@watilde
watilde / gruntfile.js
Last active December 17, 2015 21:39
Easy to write to load grunt plugin.
/**
* @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");
@watilde
watilde / $_GET.js
Last active December 18, 2015 04:39
/**
* like PHP's $_GET
* @type {Function} $_GET
* @param {String} params
* @return {Object} hash
*/
var $_GET = (function $_GET(params) {
'use strict';
// Exception
function reverseObject(obj) {
var outObj = {};
Object.keys(obj).reverse().map(function(k){
outObj obj[k] = obj[k];
});
return outObj;
}
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>'");
}
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() {