Skip to content

Instantly share code, notes, and snippets.

View kentcdodds's full-sized avatar
🤓
working hard to make the world better with software

Kent C. Dodds kentcdodds

🤓
working hard to make the world better with software
View GitHub Profile
function fetchJSON(options, cb) {
fetch(options).
then(res => res.json()).
then(json => cb(null, json)).
catch(err => cb(err))
}

Getting Started with NPM (as a developer)

If you haven't already set your NPM author info, now you should:

npm set init.author.name "Your Name"
npm set init.author.email "you@example.com"
npm set init.author.url "http://yourblog.com"

npm adduser

@kentcdodds
kentcdodds / angular-static-server.js
Last active November 24, 2015 00:36 — forked from ryanflorence/static_server.js
Angular Static Server - Serves up static files. If the request doesn't match one, it'll send the hash version and lets Angular leverage html5Mode. Haven't tested it with Ember or others, but I imagine they'd work just as well. Thanks to rpflorence for the original version.
var http = require('http');
var url = require('url');
var path = require('path');
var fs = require('fs');
var base = path.join(process.cwd(), process.argv[2] || '');
var port = process.argv[3] || 8888;
var extensionRegex = /\.([0-9a-z]+)(?:[\?#]|$)/i;
var contentTypeMap = {
html: 'text/html',