Skip to content

Instantly share code, notes, and snippets.

Eran Hammer hueniverse

Block or report user

Report or block hueniverse

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
hueniverse / car.cpp
Created Apr 19, 2018
Build a Car in C++
View car.cpp
class Car {
void top () {
printf(" _______________________");
printf(" / | \");
  printf(" / | \");
  printf(" / | \");
  printf(" / | \");
  printf(" / | \");
hueniverse /
Last active Nov 19, 2019
Guidelines for using plugins to organize your hapi application

This document outlines the proper way of using plugins in a hapi-based application. By "proper" I mean "as designed". Of course you can do whatever you want in your code and there are many other patterns you can choose or develop, but this is what I had in mind when I designed the plugin system and as I continue to evolve it.

This document is a work-in-progress and only half-way done. It should probably move to a page on the site if someone wants to do the proofing work and submit it. I got bored writing it so will probably never finish it.

When should I organize my code using plugins?


Every hapi application should be implemented inside a plugin. This provides an easy path for extensibility and isolates your code from other plugins you are likely to use (e.g. inert for services static files, vision for template rendering, etc.). It also allows you to use more advace tools such as [glue](

hueniverse /
Created Sep 28, 2015
Private npm modules in Travis Pro

Log into npm using the account you want to use for accessing the private modules on Travis

$ npm login

Then copy the npm auth token from your ~/.npmrc file. It's the string after "//".

In Travis, add the NPM_TOKEN environment variable to the settings with the token value.

hueniverse / gist:a06f6315ea736ed1b46d
Last active Oct 16, 2019
Simple node.js code style tips to improve code quality
View gist:a06f6315ea736ed1b46d

Whether you use 2 spaces or 4 spaces, there are a few simple things that can make your node.js code easier to read. We've been using them in all the hapi modules for over 4 years now to great results. This list is by no means complete but it highlights the most useful elements that will give you immediate value in reducing bugs.

Required modules

JavaScript makes it harder than most languages to know where variables are coming from. Variables assigned required modules are particularly important because they represent a singleton object shared with the entire application. There are also globals and module globals, along with function variables and arguments.

Traditionally, variables starting with an uppercase letter represent a class that must be instantiated using new. This was an important semantic in the early days of JavaScript but at this point, if you don't know Date requires new Date() you are probably very new. We have adopted Upper Camel Case variable names for all module global variables

hueniverse / gist:a3109f716bf25718ba0e
Last active Mar 18, 2019
Response to Netflix's "Node.js in Flames" Blog Post
View gist:a3109f716bf25718ba0e

If you haven't read Netflix's Node.js in Flames blog post you should. It is a great deep dive into debugging a node performance problem. The post includes useful tips that can help you solve similar problems.

That said...

My feedback from the perspective of a framework developer is quite different. I found the tone and attitude towards express.js to be concerning and somewhat offensive. Here was a developer blaming the framework he chose for poor architecture when they never bothered to actually learn how the framework works in the first place. Everything that followed originated from this basic lack of understanding.

Express uses a very simple router logic which is at the core of how express works, so let’s examine that first (my knowledge of express is somewhat dated but I think the principle is still the same). Express keeps a hash of the various HTTP methods (GET, POST, etc.) and for each method, an array of middlewares. Each middleware is ju

hueniverse / gist:9238440
Last active Aug 29, 2015
npm and trademarks
View gist:9238440

US law protects marks used in commerce. This extends to any mark (name, image, color) used in commerce regardless of registration status. Most companies take the extra step of registering their marks with the US patent office and when issued they get to put the little (R) next to it. Until that happens companies like to point out their marks with a (TM). Either way, a mark is protected by the simple act of using it in commerce.

The goal of marks is to protect consumers. The idea is that you cannot create confusion in the market place or benefit from someone else's work. For example, companies won't let you even say they are a customer because that will create implied association.

US law also requires companies to enforce and protect their marks. You can't be selective in how you allow others to use it. If you ever want to go to court and protect your mark, you will have to show how you have been active to the best of your ability to protect it.

If npm inc. knowingly allowed you to use the npmjs module name

hueniverse / gist:7762917
Last active Jul 14, 2018
A/B testing with Confidence
View gist:7762917
var confidence = require('../');
// Master configuration
var master = {
key1: 'abc',
key2: {
$filter: 'env',
production: 1,
$default: 2
hueniverse / gist:7686452
Last active Oct 22, 2019
Walmart Mobile node.js Setup
View gist:7686452


We run multiple server processes in two data centers. Each process listens on two ports, one for HTTP and one for HTTPS. HTTPS is terminated by Apache prior to reaching node.js. HTTP goes directly from the client to node.js (through a master load balancer). We do not use clusters. We slice our physical servers into thin virtual machines running SmartOS, each with about 3GB of memory designed for a single node.js process.

Our node.js servers are hapi.js servers using the composer functionality and plugins architecture. We have three sets of plugins loaded: mobile web front end experience (single page app), legacy API reverse proxy, and monitoring.

We also serve original node.js services off another server zone which runs closed source plugins using hapi.


hueniverse / gist:7418774
Created Nov 11, 2013
I told someone I am going to use a competitor instead of their service. This is the response I got. Care to guess who it was?
View gist:7418774
I will disown you and never reply to any IM ever
You will NEVER be welcome at any dinner or conference of mine!
You will be on the blacklist of every event I ever put on, ESPECIALLY the speaker dinners
I will set up an automatic daily tweet telling the world how bad your taste is
I'll bring up my kids to consider your children as enemies and systematically train them to compete with whatever they do
I will creep in to your house at night and replace all the balsamic vinegar with regular wine vinegar MIXED WITH CARAMEL
I'll put a heater in your wine cellar
I'll take each of your chickens, feed them poison, then mix them up and feed the poison chicken mix to the alpacas
I'll replace all of your Islay scotch with expensive stuff from Speyside but I'll be sure to add my "essence" before I do
I'll take all your favorite web services and make them switch to oauth 1.0
hueniverse / gist:6097545
Created Jul 28, 2013
NodeConf 2013 Survery
View gist:6097545
"1": { "name": "Eran Hammer", "twitter": "eranhammer", "github": "hueniverse", "years": 3, "module": "poop", "instanceof": "Error", "pattern": "Callbacks", "firstConf": false },
"2": { "name": "Domenic Denicola", "twitter": "domenic", "github": "domenic", "years": 3, "module": "q", "instanceof": "WatIsThisIDontEven", "pattern": "Promises", "firstConf": false },
"3": { "name": "Lars Jacob", "twitter": "jaclar", "github": "jaclar", "years": 1, "module": "async", "instanceof": "Math", "pattern": "Callbacks", "firstConf": true },
"4": { "name": "Jacob Groundwater", "twitter": "0x604", "github": "jacobgroundwater", "years": 2, "module": "swig", "instanceof": "Factory", "pattern": "Callbacks within Promises within Monads within Fibres", "firstConf": true },
"5": { "name": "Tim Caswell", "twitter": "creationix", "github": "creationix", "years": 4, "module": "libuv", "instanceof": "Inventor", "pattern": "Continuables", "firstConf": false },
"6": { "name": "Jamison Dance", "twitter": "jergaso
You can’t perform that action at this time.