Skip to content

Instantly share code, notes, and snippets.

@enten
enten / enumflag.js
Created August 10, 2017 06:14
EnumFlag
const {inspect} = require('util')
const DEFAULT = {
defaultValue: undefined,
dictionary: undefined,
value: undefined
}
function EnumFlag (enumFlag) {
const index = getDictionaryIndex(enumFlag.dictionary)
@enten
enten / is-relative-path.js
Last active August 8, 2017 23:38
Determines if filename is a relative path.
const {sep: platformSep} = require('path')
const {inspect} = require('util')
const POSIX_SEP = '/'
const WIN32_SEP = '\\'
const PATH_SEPARATORS = {
'aix': POSIX_SEP,
'darwin': POSIX_SEP,
'freebsd': POSIX_SEP,
@enten
enten / nextify.js
Last active August 22, 2017 15:15
Javascript Middleware Pattern
function nextify (middlewares, callback) {
return (...args) => {
middlewares.slice(0).reverse().reduce((next, fn) => {
return () => fn(...args, (err) => {
if (err) {
return callback(err)
}
next()
})
@enten
enten / ansi-styles.js
Last active July 1, 2021 07:34
Node JS ANSI Styles
module.exports = []
.concat([
'reset',
'bold',
'dim',
'italic',
'underline',
'blink',
,
'inverse',
@enten
enten / adsl2.js
Last active August 12, 2017 00:44
adsl2
const nodeNotifier = require('node-notifier')
const {
format,
inspect
} = require('util')
const CONSOLE = Object.assign({}, console)
const DEFAULT = {
@enten
enten / README.md
Last active February 22, 2017 18:59
Make a fork process callable easily

callableFork

Requirements

npm install caller errio eventemitter3

Example

@enten
enten / react-universally-wcf.js
Last active November 22, 2016 11:23
Rewriting of react-universally/tools/webpack/configFactory.js with wcf
var wcf = require('wcf')
var {basename, resolve} = require('path')
// mocks >
var globSync = () => []
var happyPackPlugin = (x) => x
// < mocks
var f = wcf.create()
for i in $(git status | grep modified | awk -F " " '{print $2}');
do cat $i | tr -d '\r' > $i.tmp; mv $i.tmp $i;
done
@enten
enten / get-gh-pages-url.sh
Last active April 3, 2018 13:08
Print Github username/repository from the current remote branch
REPO=git remote -v | grep -e push | awk '{print $2}' | sed 's/https:\/\/github.com\///g' | sed 's/.git//g'
REPOUSER=$(echo $REPO | awk -F '/' '{print $1}')
REPONAME=$(echo $REPO | awk -F '/' '{print $2}')
echo "https://$REPOUSER.github.io/$REPONAME"
@enten
enten / contributors.sh
Created August 23, 2015 17:52
Create MAINTAINERS file from git commits
#!/bin/sh
# contributors: Generate MAINTAINERS content from git commits
#
# Author: Steven Enten <steven@enten.fr>
# License : MIT
# Requirements: dirname cat echo eval grep read readlink shift tail
# Site: https//github.com/enten/losh
set -u