Skip to content

Instantly share code, notes, and snippets.

body {
background-color: white;
color: rgba(0,0,0,0.8);
font-family: Georgia,Cambria,"Times New Roman",Times,serif;
}
#editor {
box-shadow: none
}
@tj
tj / lame.js
Last active August 29, 2015 14:03
function shutdown() {
var times = 0;
process.on('SIGINT', function(){
trapped('INT');
});
process.on('SIGQUIT', function(){
trapped('QUIT');
});
@tj
tj / stuff.md
Last active September 30, 2017 19:13
ES6 modules

Ok so http://wiki.ecmascript.org/doku.php?id=harmony:modules looks more less the same as it did last time I looked, however that document combined with https://github.com/rwaldron/tc39-notes/blob/master/es6/2014-06/jun-5-modules.md#do-we-need-the-module-foo-from-foo-import-syntax looks like we're conflating quite a few concepts (IMO... not trying to anger anyone).

Personally I'm in favour for removing module as mentioned in the gist. I would also remove re-exporting (export * from "crypto"), even if it's a nicety I can't say out I've done much re-exporting in the thousands and thousands of modules I've written, does anyone else do this often? (not sure)

Single exported value

Personally (barring weird edge-cases I'm not aware of?) I would love if we only had exporting a single or multiple value, with only one syntax for importing. For example the common use-case of exporting a single function or value:

ferret.js

@tj
tj / README.md
Created March 30, 2014 05:07 — forked from mbostock/.block

A test for the new topojson.merge functionality that will be available in the next release of TopoJSON, 1.6. The state boundaries are computed by merging the county boundaries!

The merge algorithm appears to have some issues with Virginia’s small counties; I am currently investigating this problem.

@tj
tj / coros.rb
Last active August 29, 2015 13:55
def receive(co)
let status, val = coroutine.resume(co)
return val
end
def send(x)
coroutine.yield(x)
end
/**
* POST to create a new user.
*/
exports.create = function *(){
var body = yield parse(this);
// password
var pass = body.password;
assert(pass, 400, 'password is required');
language: node_js
script: make test
notifications:
email:
- [email protected]
node_js:
- "0.11"
- "0.10"
services:
- redis
var photos = yield domains.map(function(domain, i){
return albums[i].map(function(album){
return dropbox.photos(domain, album);
});
});
@tj
tj / config.js
Last active December 27, 2015 14:49
/**
* Module dependencies.
*/
var pkg = require('../package');
var env = process.env.NODE_ENV || 'development';
/**
* Return setting `name`.
*
@tj
tj / gist:7157148
Created October 25, 2013 16:06
lib/log.js
var conf = require('config');
module.exports = conf('use production logger')
? require('log-prod')
: require('log-dev');