Skip to content

Instantly share code, notes, and snippets.

View simov's full-sized avatar

simo simov

View GitHub Profile
@simov
simov / readdirr.js
Last active August 29, 2015 14:14
Recursively read directory using generators, co and thunkify
var fs = require('fs')
, path = require('path')
, co = require('co')
, thunkify = require('thunkify')
, readdir = thunkify(fs.readdir)
, stat = thunkify(fs.stat)
var recursive = co.wrap(function* (root) {
var dirs = [], files = []
@simov
simov / app.js
Created May 5, 2015 15:39
Modifying the global state
var file1 = require('./file1')
var file2 = require('./file2')
@simov
simov / readdirr.js
Last active August 29, 2015 14:21
Recursive asynchronous streaming of directory
import fs from 'fs'
import path from 'path'
import stream from 'stream'
import bluebird from 'bluebird'
bluebird.promisifyAll(fs)
class Readdirr extends stream.Readable {
constructor(root) {
@simov
simov / parser.js
Created May 30, 2015 14:46
tape + tap-reporter = wrong events order
var parser = require('tap-parser') // 1.1.4
var p = parser()
process.stdin.pipe(p)
p.on('extra', function (line) {
console.log('extra', line)
})
@simov
simov / monokai-theme-github-code-view-and-gist.css
Last active October 10, 2015 16:07
Monokai Theme for GitHub code view and Gist - http://stylebot.me/styles/1652
/* COMMON */
/*background*/
.type-html,
.type-css,
.type-javascript,
.type-html .highlight,
.type-css .highlight,
.type-javascript .highlight,
@simov
simov / readdirr.js
Created November 22, 2012 20:00
Recursive directory listing in NodeJS.
var fs = require('fs'),
path = require('path');
var dir = null, file = null;
exports.readdirr = function (dpath, cb) {
dir = [], file = [];
dir.push(dpath);
@simov
simov / moment-weeks.js
Created November 28, 2012 23:21
Helper functions for weeks in moment.js
var moment = require('moment');
moment.fn.isISO = true;
moment.fn.dayISO = function () {
var self = this.clone();
return self.day() == 0 ? 6 : self.day()-1;
}
@simov
simov / gulpfile.js
Created October 16, 2015 16:52
Gulpfile + Babel + Sourcemaps
var path = require('path')
var gulp = require('gulp')
var sourcemaps = require('gulp-sourcemaps')
var babel = require('gulp-babel')
var paths = {
es6: ['**/*.js', '!gulpfile.js', '!build/**/*.*'],
es5: 'build',
// must be absolute or relative to source map
@simov
simov / function-events.js
Last active December 10, 2015 13:48
The `list` function is looping through a list of asynchronous operations. The `main` function is notified about the state of the `list` function on each step.
function list (step, end) {
function loop (index) {
if (index == 10) return end();
step(index, function next () {
loop(++index);
});
}
loop(0);
}
@simov
simov / sublime-shortcuts.md
Created September 4, 2013 16:21
Sublime Text 2 Shortcuts

#Sublime Text 2 Shortcuts

###Legend

key symbol
ctrl
shift
alt
tab