Skip to content

Instantly share code, notes, and snippets.

View eilgin's full-sized avatar

thomas eilgin

View GitHub Profile
dahjelle /
Created July 13, 2016 16:48
Pre-commit hook for eslint, linting *only* staged changes.
for file in $(git diff --cached --name-only | grep -E '\.(js|jsx)$')
git show ":$file" | node_modules/.bin/eslint --stdin --stdin-filename "$file" # we only want to lint the staged changes, not any un-staged changes
if [ $? -ne 0 ]; then
echo "ESLint failed on staged file '$file'. Please check your code and try again. You can run ESLint manually via npm run eslint."
exit 1 # exit with failure status

Git Cheat Sheet


Getting Started

git init


a0viedo / asyncQuiz.js
Last active January 26, 2021 19:54
Can you guess what the console will print? Extracted from the book Mastering Node.js
var fs = require('fs');
var EventEmitter = require('events').EventEmitter;
var pos = 0;
var messenger = new EventEmitter();
messenger.on('message', function(msg) { console.log(++pos + " message:" + msg);
console.log(++pos + " first");
soarez /
Last active May 28, 2024 02:57
How to setup your own CA with OpenSSL

How to setup your own CA with OpenSSL

For educational reasons I've decided to create my own CA. Here is what I learned.

First things first

Lets get some context first.

branneman /
Last active April 27, 2024 04:16
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