Skip to content

Instantly share code, notes, and snippets.

@dliv
dliv / bghwinc.md
Last active October 5, 2021 17:24
Bypass GH when installing node-canvas v2.8.0

Run Local Server Serving Node-Gyp Pages

Run server.py from: https://github.com/dliv/node-canvas

You will need to create a localhost.pem in the root directory.

openssl req -new -x509 -keyout localhost.pem -out localhost.pem -days 365 -nodes

Update Webapp Consuming Node-Canvas

alias gx="git clean -fd && git reset --hard"
@dliv
dliv / flow-exhaustive-switch.js
Created April 20, 2017 14:46
Flow - Exhaustive Switch
// from: http://ouicar.github.io/2016/08/08/exhaustive-switch.html
// modified to use Flow comments
/* ::
type Empty = 'empty type' & 'nothing there';
type t = 'a' | 'b';
*/
function unexpectedCase(impossible /* : Empty */) /* : void */ {
reportError(`Unexpected case ${impossible}`);
@dliv
dliv / i18n-api.js
Created February 14, 2017 23:51
Example i18n Express Ap :app/categories/:category/keys/:key
const express = require('express');
const _ = require('lodash');
const bodyParser = require('body-parser');
const i18nApp = express.Router();
// parse application/x-www-form-urlencoded
// for easier testing with Postman or plain HTML forms
@dliv
dliv / User.js
Created February 14, 2017 18:01
const bcrypt = require('bcrypt');
const knex = require('knex')(require('../../../knexfile'));
const bookshelf = require('bookshelf')(knex);
const User = bookshelf.Model.extend({
tableName: 'users',
hasTimestamps: true,

Kill Process Using Port

Tested on mac.

Nuclear

Assuming you know the command name, own the process, and want to kill them all.

$ killall node

@dliv
dliv / watch-and-touch.js
Last active January 13, 2017 21:15
watch a group of files and, on change, touch a different file
// Example usage:
// node watch-and-touch 'src/**/*.post.css' src/styles-index.post.css
//
// Example will `touch` src/styles-index.post.css if any other css file
// under src changes. Potential usecase: webpack hot module reloading is
// working for your primary postcss file, but does not work for other
// postcss files imported from the main file.
//
// See: https://github.com/postcss/postcss-loader/issues/122
// See: https://github.com/postcss/postcss-import/issues/233
@dliv
dliv / netgear-router-rce.md
Last active December 15, 2016 02:42
Netgear Router RCE
@dliv
dliv / yanslate.py
Created October 24, 2016 18:58
yanslate
def yanslate(text):
return " ".join(["y"+word[1:] for word in text.split()])
@dliv
dliv / .gitignore_global
Created October 22, 2016 02:04
.gitignore_global
# touch ~/.gitignore_global
# git config --global core.excludesfile ~/.gitignore_global
.idea
.DS_Store
npm-debug.log