Skip to content

Instantly share code, notes, and snippets.

View jhs's full-sized avatar

Jason Smith jhs

  • McKinsey & Company
  • New York, NY
View GitHub Profile
// Example MX response with dnsd
//
// To test:
// 1. Run this program
// 2. dig @localhost -p 5353 example.com mx
var dnsd = require('dnsd')
var server = dnsd.createServer(handler)
server.zone('example.com', 'ns1.example.com', 'us@example.com', 'now', '2h', '30m', '2w', '10m')
@jhs
jhs / jhs_imac.rsa.pub
Created March 19, 2013 04:26
My SSH RSA public key
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAugw9qNFQfuzPdkjYYJX5/27o9zQGEgQ04b/iM541WL/Pjey4lkVUSk0eVjVq69PunIZjDGPR/4hBzdTxKznwvHtvT8Lgk/PKnqCf3u23vm/n0uvZ2a8HHAM06VTsE6DPqawStfjdKdT3uYrhzNsADuxLA+/METrPoQFUR2G26Y3oAdCRx/I0dQE4T6qmEefDN60Z0mpqHl44jcXk9mTTqqVwDbXJWH4UTF7b2m9j8iFDw0zGtXGCwvubJCzezxMls0/T8zmTDp0/X3/6CL42v457y3XwMfdCya5gq3a9/xdA8l01Kwg988Jp36RVayI8b5Su4vasrnmPtk4sHCfP/Q== jhs@jason-smiths-imac.local
@jhs
jhs / couchdb.js
Last active December 13, 2015 16:58
// Service all /_couchdb/* requests for CouchDB
//
module.exports = handle_http
function handle_http(req, res) {
res.writeHead(200, 'OK')
res.end('Hello to CouchDB!\n')
}

Hi, all.

Encouraged by my successful experiment with a Node.js view server, I am now working on a branch, nodejs_couchdb, with the following properties:

  • Remove couchjs from the project
  • Remove dependency on SpiderMonkey, libjs, 1.8.whatever...all that is gone
  • Remove dependency on libcurl
  • (Thus, simplified autoconf version dependency Hell)

Phase 1: Dependency on a "couchjs" executable which you install via npm install couchjs

@jhs
jhs / npm_Dec2012.txt.md
Last active December 10, 2015 11:08
Node.js npm December stats and reflections

Sent this to the [CouchDB users list][email] just now; duplicated here for others to see or comment

Hi, all. Sorry to be distant from the community recently. No excuse.

I thought I might share December stats from one of Apache CouchDB's most well-known deployments and killer apps: the Node.js npm registry.

Facts

  • Zero downtime
@jhs
jhs / rant.md
Last active December 10, 2015 09:18
Rant about Node.js library logging

What I want for library logging

I write Node.js libraries, and I want logging. Why is this so problematic?

Note, I am despairing about how library authors log stuff not how application builders decide on a logging framework.

Hopefully this document can become a spec or feature list for code I will write some day.

The antipattern

@jhs
jhs / example.js
Created December 10, 2012 03:16
My Node.js modules these days
// Short module explanation // Something to gather my thoughts
// // I think this looks cool.
//
module.exports = the_exported_function // Modules are a function. Always.
//
module.exports.extra = extra // Additional API entry points if
module.exports.other = other // desired.
//
var util = require('util') // Other packages from npm or core
var assert = require('assert') // No comma-first due to lots of
@jhs
jhs / for_in.js
Created August 10, 2012 16:34
Looping syntax
for (var thing in {'foo':1, 'bar':1, 'neat':1}) {
console.log('doing ' + thing)
doing(thing)
}
@jhs
jhs / iris-redis-example.js
Created August 4, 2012 02:00
Iris-Redis example
if(!process.env.redis_pass)
return console.error('Run this first: export redis_pass=<your password>')
var redis = require('iris-redis') // npm install iris-redis first, of course.
var client = redis.createClient(6379, 'redis.pouch.iriscouch.com')
client.auth(process.env.redis_pass)
client.on("ready", function() {
console.log('Connected %s at %s:%d', client.host, client.stream.remoteAddress, client.stream.remotePort)
client.iris_config(function(er, config) {
@jhs
jhs / irccloud_search.js
Created May 25, 2012 10:39
Get irccloud backlog
var request = require('request')
var SINCE = +process.env.since
if(!SINCE)
throw new Error('Need $since')
get_lines(SINCE)
function get_lines(beforeid) {
var headers = { 'Cookie': process.env.cookie }
if(!headers.Cookie)