Skip to content

Instantly share code, notes, and snippets.

@dthtvwls
dthtvwls / echo.js
Last active July 22, 2016 15:43
Send back the raw HTTP request (for elastic beanstalk, use node 6.2.2)
require('http')
.createServer((req, res) => {
let body = []
req
.on('data', chunk => body.push(chunk))
.on('end', () => res.end(
req.rawHeaders
.filter((el, i) => i % 2 === 0)
.reduce(
(a, key, i) => a.concat(`${key}: ${req.rawHeaders[i * 2 + 1]}`),

Keybase proof

I hereby claim:

  • I am dthtvwls on github.
  • I am dthtvwls (https://keybase.io/dthtvwls) on keybase.
  • I have a public key whose fingerprint is 9ECC 667D C9CE BDE7 29BF 7840 B7AA 4D45 967D EA0A

To claim this, I am signing this object:

// 32 16 16 16 48
// 097d43fb e23d 4633 9608 e930f252d32e
// time_low(8) - time_mid(4) - time_hi_and_version(4) - clock_seq_hi_and_reserved(2)/clock_seq_low(2) - node(12)
// leftmost bits are 0100 leftmost bits are 10
var uuid = function () {
var a = new Uint8Array(16); // 16 8-bit octets that are represented by 2-digit hex numbers
crypto.getRandomValues(a);
a[6] = a[6] & 0x0f | 0x40;
a[8] = a[8] & 0x3f | 0x80;