Skip to content

Instantly share code, notes, and snippets.

Peter Vu vietvu-nguyen

  • neukind
  • tokyo
Block or report user

Report or block vietvu-nguyen

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
miguelmota /
Created Jul 8, 2018
BIP32 vs BIP39 vs BIP44
  • BIP32 - is a method for generating a tree of private keys from a master private key.
  • BIP39 - method for encoding 128-256 bits of random data into 12-24 word phrases from a list of interchangable 2018 words, and then turn those phrases into a 64 byte hash.
  • BIP44 - is a method for structuring a private key tree in a specific way that will facilate usage/restoration/discovery of multiple accounts for multiple purposes.
zcaceres /
Last active Mar 30, 2020
error handling patterns in Express

Handling Errors

Express.js makes it a breeze to handle errors in your routes.

Express lets you centralizes your error-handling through middleware.

Let's look at patterns for how to get the most out of your error-handling.

First, our error-handling middleware looks like this:

cpsubrian / db.js
Last active Feb 21, 2020
Mock knex database for Jest
View db.js
/* eslint-env jest */
import _ from 'lodash'
import path from 'path'
import fs from 'fs'
import callsites from 'callsites'
import knex from 'knex'
import hash from 'object-hash'
import conf from '<conf>'
// Get the db config.
tracker1 /
Last active Mar 28, 2020
Anatomy of a JavaScript/Node project.

Directory structure for JavaScript/Node Projects

While the following structure is not an absolute requirement or enforced by the tools, it is a recommendation based on what the JavaScript and in particular Node community at large have been following by convention.

Beyond a suggested structure, no tooling recommendations, or sub-module structure is outlined here.


  • lib/ is intended for code that can run as-is
  • src/ is intended for code that needs to be manipulated before it can be used
paulallies / gist:0052fab554b14bbfa3ef
Last active Mar 28, 2020
Remove node_modules from git repo
View gist:0052fab554b14bbfa3ef
#add 'node_modules' to .gitignore file
git rm -r --cached node_modules
git commit -m 'Remove the now ignored directory node_modules'
git push origin master
branneman /
Last active Mar 29, 2020
Better local require() paths for Node.js

Better local require() paths for Node.js


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:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions

You can’t perform that action at this time.