Skip to content

Instantly share code, notes, and snippets.

@monolithed
monolithed / grunt-dirsum.js
Created November 14, 2014 12:34
Hash-sum file (grunt-dirsum)
const fs = require('fs'),
dirsum = require('dirsum')
;
module.exports = function (grunt) {
grunt.registerMultiTask('hash', 'Hash-sum file.', function () {
const done = this.async();
var options = this.options({
algorithm: 'md5'
@monolithed
monolithed / xxd.sh
Created November 17, 2014 08:18
Edit HEX-document
vi file.js
:%!xxd
'use strict';
var utils = require('util');
module.exports = function (grunt, options) {
return {
index: {
options: {
template: function (data) {
var content = utils.format('return %s(%j);', data.contents, {
'use strict';
import FastClick from 'FastClick';
var utils = {
parse_events (events) {
return events.split(/[\s,]+/);
}
};
@monolithed
monolithed / fest.js
Created January 6, 2015 22:27
grunt-fest
/*!
* tasks/fest
*/
'use strict';
var utils = require('util');
module.exports = function (grunt, options) {
return {

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

var Article = require('../../../models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@monolithed
monolithed / grunt-copy-sync.js
Created January 9, 2015 16:04
grunt-copy-sync.js
/**
* utils/sync
*/
'use strict';
var fs = require('fs'),
grunt = require('grunt'),
path = require('path');
@monolithed
monolithed / DOMEvent.js
Created February 9, 2015 23:49
DOMEvent
'use strict';
/**
* @class DOMEvent
* @param {Object} element
*/
export default class DOMEvent {
constructor (element) {
this.element = element;
this.events = {};
scroll-behavior: smooth;
will-change: none;
'use strict';
/**
* @class
* @param {number} size
*/
export default class FixedList {
constructor (size) {