Skip to content

Instantly share code, notes, and snippets.

View wbyoung's full-sized avatar

Whitney Young wbyoung

  • FadingRed
  • Portland, OR
View GitHub Profile
@wbyoung
wbyoung / aws-deploy.sh
Last active September 12, 2017 02:26
#!/bin/bash
set -e
JQ="jq --raw-output --exit-status"
escape-json() {
python -c "import sys; import json; sys.stdout.write(json.dumps(sys.stdin.read().strip())[1:-1])"
}
@OverZealous
OverZealous / build.config.js
Last active June 21, 2021 04:12
Preliminary Gulpfile for replicating ngBoilerplate — Still a work in progress!
/**
* This file/module contains all configuration for the build process.
*/
/**
* Load requires and directory resources
*/
var join = require('path').join,
bowerrc = JSON.parse(require('fs').readFileSync('./.bowerrc', {encoding: 'utf8'})),
bowerJSON = bowerrc.json.replace(/^\.?\/?/, './'),
@timruffles
timruffles / maybe-es6.js
Last active December 20, 2015 12:19
Generators let you cut away at boiler-plate. Here I'm using it to do similar things to Haskell's Maybe, which effectively defines an error state (e.g NaN) once, and then write a lot of code that doesn't now have to bother checking for it explicitly. The numericalProcess can now be defined without any checking for NaN, in a point-free (not refere…
var Nothing = {Nothing: true}
function MaybeGenerator() {
var g = arguments[arguments.length - 1]
// list of functions that test for any "Nothing" values
var maybes = [].slice.call(arguments,0,arguments.length - 1)
return function(value) {
var generator = g.apply(null,[].slice.call(arguments,1))
var result
@domenic
domenic / interop.md
Last active July 7, 2022 19:47
`module.exports =` and ES6 Module Interop in Node.js

module.exports = and ES6 Module Interop in Node.js

The question: how can we use ES6 modules in Node.js, where modules-as-functions is very common? That is, given a future in which V8 supports ES6 modules:

  • How can authors of function-modules convert to ES6 export syntax, without breaking consumers that do require("function-module")()?
  • How can consumers of function-modules use ES6 import syntax, while not demanding that the module author rewrites his code to ES6 export?

@wycats showed me a solution. It involves hooking into the loader API to do some rewriting, and using a distinguished name for the single export.

This is me eating crow for lots of false statements I've made all over Twitter today. Here it goes.

@dnagir
dnagir / rspec-syntax-cheat-sheet.rb
Created November 5, 2010 09:29
RSpec 2 syntax cheat sheet by example
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")