Skip to content

Instantly share code, notes, and snippets.

View CrabDude's full-sized avatar

Adam Crabtree CrabDude

View GitHub Profile
@CrabDude
CrabDude / desc.txt
Last active January 3, 2016 12:48
South Bay Node.js Enterprise Breakfast
What: Breakfast for south bay enterprise node.js leaders
When: 8-9:30am, Friday, January 24
Where:
LinkedIn
2029 Stierlin Ct
Mountain View, CA 94043
Why: To regularly meet to discuss enterprise node.js concerns and encourage increased community in the south bay.
@CrabDude
CrabDude / asyncgen_listfiles.js
Created March 27, 2014 21:23
ListDir: Async Generator all the things!
// List all files recursively within a directory with maximum parallelism
"use strict";
let path = require('path')
let fs = require('fs')
let co = require('co')
let _ = require('lodash')
Function.prototype.partial = function() {
var args = Array.prototype.slice.call(arguments)
args.unshift(null)
@CrabDude
CrabDude / callback_contract.md
Last active December 20, 2019 18:50
Node.js Callback Contract

Node.js Callback* Contract

(aka "errback" or "error first callback")

  1. Function that takes 2 arguments
    • first argument is an error
    • second argument is the result
    • Never pass both
    • error should be instanceof Error
  2. Must never excecute on the same tick of the event loop
  3. Must be passed as last argument to function
@CrabDude
CrabDude / gist:f53f8996fb8816bb6372
Last active August 29, 2015 14:10
Node.js with FB Flow
// @flow weak
/* jshint ignore:start */
declare module 'http' {
declare function createServer(callback: (req: httpIncomingMessage, res: httpServerResponse) => void): httpServer
}
// declare class http {
// createServer(callback: (req: httpIncomingMessage, res: httpServerResponse) => void): httpServer
// }
@CrabDude
CrabDude / .eslintrc
Last active November 28, 2017 13:35
.eslintrc with Babel parser support (via babel-eslint package)
{
"env": {
"node": true,
"es6": true
},
"parser": "babel-eslint",
"rules": {
"no-throw-literal": 1,
"strict": "never",
"semi": [2, "never"],
@CrabDude
CrabDude / README.md
Last active August 29, 2015 14:18
Dropbox README

Dropbox (raw)

This is a basic Dropbox clone to sync files across multiple remote folders.

Time spent: <Number of hours spent>

Features

Required

@CrabDude
CrabDude / 1_overview.md
Created April 10, 2015 19:25
Proxy Echo Server Overview

Testing

async()=>{
// Pointless calling await because crypto.pbkdf2 returns nothing
await crypto.pbkdf2('asdf', 'salt', 4096, 512, 'sha256', function(err, key) {
if (err) throw err
user.password = key.toString('hex')
console.log(user.password)
// return key.toString('hex') // 'c5e478d...1469e50'
})
@CrabDude
CrabDude / README.md
Last active August 29, 2015 14:27
A sample Node.js Bootcamp submission README

Proxy Server

This is a Proxy Server for Node.js submitted as the pre-work requirement for CodePath.

Time spent: [Write the number of hours you spend here]

Completed:

  • Required: Requests to port 8000 are echoed back with the same HTTP headers and body
  • Required: Requests/reponses are proxied to/from the destination server
@CrabDude
CrabDude / asyncawait.html
Created November 4, 2015 02:03
BayNode Node Night 11/3/15: async/await by Adam Crabtree
<!DOCTYPE html>
<html>
<head>
<title>Async Await</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<style type="text/css">
@import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz);
@import url(https://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic);
@import url(https://fonts.googleapis.com/css?family=Ubuntu+Mono:400,700,400italic);