Skip to content

Instantly share code, notes, and snippets.

View lerouxb's full-sized avatar

Le Roux Bodenstein lerouxb

View GitHub Profile
@lerouxb
lerouxb / debounced.html
Created October 25, 2012 15:26
debounced-modify event on all inputs, selects and textareas
<!doctype html>
<html>
<head>
<title>debounced modify event</title>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script>
$.fn.debouncedModify = function (options) {
if (!options) options = {};
if (!options.timeout) options.timeout = 250;
@lerouxb
lerouxb / dabblet.css
Created August 31, 2012 13:33
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
min-height: 100%;
var urlmod = require('url');
var http = require('http');
var https = require('https');
var gm = require('gm');
var TIMEOUT = 10000;
function identify(url, callback) {
var parsed = urlmod.parse(url);
var get;
console.log(parsed.protocol);
@lerouxb
lerouxb / index.html
Created June 20, 2012 14:03
Boilerplate
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Boilerplate</title>
<style class="reset">
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,p,blockquote,th,td{margin:0;padding:0;}
table{border-collapse:collapse;border-spacing:0;}
fieldset,img{border:0;}
var
express = require('express'),
gm = require('gm'),
http = require('http'),
request = require('request'),
urlmod = require('url'),
app = express.createServer();
app.use(express.logger('tiny'));
app.use(express.errorHandler({
var
express = require('express'),
gm = require('gm'),
http = require('http'),
request = require('request'),
urlmod = require('url'),
app = express.createServer();
app.use(express.logger('tiny'));
app.use(express.errorHandler({
/*
Run this, connect to
http://localhost:3000/check/image?url=http://dl.dropbox.com/u/1167202/IMAG0193.jpg
That image is just under 2Mb. I tell the request to disconnect immediately (see
the maxSize = 0 hack inside identifyImageURL()) and all the data keeps arriving
bit by bit until the entire file is downloaded.
(This is perhaps more obvious on my slow South African line, but you can see
the byte totals coming in and it trying to call destroy again and again in the
@lerouxb
lerouxb / gist:2108445
Created March 19, 2012 11:32
Star Control 2 Admission Policy
Person A: Can you imagine, Person B, what it must be like to argue for race based admissions policy?
Person A: To live in endless screaming pain for months on end? No you cannot.
Person B: hold, what you do is wrong!
Person A: You have not asked properly.
Person A: If you do not ask properly, we will not discuss this matter.
Person A: Instead, we use the race card.
Person A: oh wait
Person A: you DID ask properly
Person A: We will explain to you about the Nationalists and the British Colonialists
Person A: the PAC, our only friends... whom we exterminated
@lerouxb
lerouxb / placehold.js.html
Created March 6, 2012 09:31
Dynamically create a canvas to be used as an image placeholder.
<!doctype html>
<html>
<head>
<title>placehold.js</title>
<script>
/*
Dynamically create a canvas to be used as an image placeholder.
If you really want an <img>, you can use:
var dataURL = canvas.toDataURL("image/png");