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 / 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 / barrel_bookmarklet.js
Created November 3, 2011 19:02
A bookmarklet to replicate Google's "do a barrel roll" on any arbitrary page.
javascript:(function(a,k,t,m,o,w,s){document.head.innerHTML+='<'+s+'@-'+m+k+m+t+'@-'+o+k+o+t+'@-'+w+k+w+t+'body{-'+m+a+'-'+o+a+'-'+w+a+'}</'+s})("-animation:r 4s 1;","-keyframes r{to{-","-transform:rotate(360deg)}}","moz","o","webkit","style>")
@bengl
bengl / .vimrc
Created February 28, 2012 00:53
auto-updating .vimrc
" ~/.vimrc
"
" Remote vimrc. Updates each time vim is started. This adds a bit of time to
" your vim startup, but I haven't found it to be a big deal.
"
" The bit.ly URL is the vimrc file from my dotfiles on github, raw. Replace it
" with your own.
"
" Why not just save it to ~/.vimrc? This way I can just update it on github
" and it's good to go on all my machines.
@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 / LICENSE.txt
Created December 13, 2012 10:00 — forked from 140bytes/LICENSE.txt
Do A Barrel Roll!
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@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)