Skip to content

Instantly share code, notes, and snippets.

View bengl's full-sized avatar
💭
Set your status

Bryan English bengl

💭
Set your status
View GitHub Profile
@bengl
bengl / commits.js
Last active August 29, 2015 14:27
Analyse the commits on node core to see how many are doc-only, etc.
/**
* Plop this in your node git repo and run:
*
* $ node commits.js [num of commits you want to analyse (default 1000)]
*/
var exec = require('child_process').exec;
function gitDiffTree(commit, recursive, cb) {
exec('git diff-tree --name-only --no-commit-id ' + (recursive ? '-r ' : '') + commit, function(err, data) {
@bengl
bengl / using.js
Created March 23, 2011 15:22
Because I got tired of var module = require('module');
//using.js
var importThem = function(libs){
for (var i = 0; i < libs.length; i++) {
global[libs[i]] = require(libs[i]);
}
};
module.exports = function(){
if (arguments.length == 1
&& arguments[0].constructor.toString().indexOf("Array") != -1)
@bengl
bengl / music.coffee
Created September 27, 2011 03:58
A DSL for making music with CoffeeScript might look like this...
bpm 120
# BootsNCatsNBootsNCatsNBootsNCatsNBootsNCatsNBootsNCatsNBootsNCatsN
# http://i.imgur.com/sqmHC.jpg
drums = new DrumMachine()
n = (s) ->
drums 'hihat', s
boots = (s) ->
@bengl
bengl / Makefile
Created September 19, 2012 08:08
A simple C program that emits QR codes as ANSI art
CFLAGS=-Wall
all:
$(CC) $(CFLAGS) qransi.c -lqrencode -o qransi
@bengl
bengl / test.js
Last active December 10, 2015 23:08
domains don't really catch exceptions?
// node >= 0.8.*
var domain = require('domain');
process.on('uncaughtException', function(error){
console.error('UNCAUGHT!', error);
});
var d = domain.create();
d.on('error', function(error) {
@bengl
bengl / stuff.js
Created September 27, 2013 16:25
var app = express();
app.get('/', function(req, res){
try{
if (someBoolean) {
res.send("all good!")
} else {
throw Error("shit's fucked, yo");
}
} catch (e){
res.send(e.toString(), 500);
@bengl
bengl / be.txt
Created November 6, 2013 17:03
I swear it's not the logo for Bugatti.
#################################
###################################
####################################
##### #### ####
##### #### ####
#### ####
#### ####
#### #### ####
##### #### ####
@bengl
bengl / README.md
Last active December 29, 2015 11:19
Can't use repl inside domain. Or can I? I'm not sure.

It turns out that the node REPL doesn't seem to behave as expected inside a domain. (I'm using node v0.10.22)

Try running repltest.js, which is narrowed down from a much larger REPL-thing I'm working on. You'll get your REPL, but there is some weirdness. If you give it an empty line (i.e. just press Enter/Return), you'll get a syntax error, captured by the domain and ouput via line 6:

> 
SyntaxError: Unexpected token )
    at REPLServer.self.eval (repl.js:112:21)
    at Interface.<anonymous> (repl.js:239:12)
    at Interface.EventEmitter.emit (events.js:95:17)
@bengl
bengl / hamgear.md
Last active June 9, 2016 06:00
ham / amateur radio gear list for nodeconf
@bengl
bengl / exportedFunction.js
Created August 10, 2016 18:49
tern annotations?
// tern: const Thing = require('./thing.js')
/**
* @param {Thing} thing
*/
module.exports = function (thing) {
thing.foo();
}