Skip to content

Instantly share code, notes, and snippets.

View tuxracer's full-sized avatar

Derek Petersen tuxracer

View GitHub Profile
@rawsyntax
rawsyntax / config
Created July 11, 2012 16:43
faster ssh
Host *
# don't try to authenticate with Kerberos
GSSAPIAuthentication no
GSSAPIKeyExchange no
# persist the ssh connection for 5 minutes
# subsequent ssh connections respond faster because its reusing an existing connection
ControlMaster auto
ControlPath ~/.ssh/master-%r@%h:%p
ControlPersist 5m
@lakenen
lakenen / detectanimation.js
Created June 28, 2012 17:17
JavaScript animated GIF detection!
function isAnimatedGif(src, cb) {
var request = new XMLHttpRequest();
request.open('GET', src, true);
request.responseType = 'arraybuffer';
request.addEventListener('load', function () {
var arr = new Uint8Array(request.response),
i, len, length = arr.length, frames = 0;
// make sure it's a gif (GIF8)
if (arr[0] !== 0x47 || arr[1] !== 0x49 ||
@cowboy
cowboy / 1.before.js
Created June 25, 2012 17:46
grunt: an example of building task targets dynamically
/*global module:false*/
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
min: {
ariaAccessibility: {
src: ['src/javascripts/jquery.selectBoxIt.ariaAccessibility.js'],
dest: 'src/javascripts/jquery.selectBoxIt.ariaAccessibility.min.js'
},
@dbainbridge
dbainbridge / sessionsStringFix.js
Created April 3, 2012 00:48
node-inspector full string output fix
// Replace refToObject in node-inspector's lib/sessions.js file to get rid of the 80 character limit on strings outputted from the console or tool tip.
// The Scope Variables panel will still show maximum of 80 characters along with the "(length: x)" suffix
function refToObject(ref) {
var desc = '',
name,
kids = ref.properties ? ref.properties.length : false;
switch (ref.type) {
case 'object':
name = /#<an?\s(\w+)>/.exec(ref.text);
@caseyjustus
caseyjustus / median.js
Created August 23, 2011 19:34
calculate the median of an array with javascript
function median(values) {
values.sort( function(a,b) {return a - b;} );
var half = Math.floor(values.length/2);
if(values.length % 2)
return values[half];
else
return (values[half-1] + values[half]) / 2.0;
@aih
aih / parseAndModifyHtml.js
Created May 8, 2011 17:27 — forked from clarkdave/parseAndModifyHtml.js
Using node.js to parse HTML with jsdom and modify it with jQuery
/**
* npm install jsdom
* npm install jquery
*/
var html = "<!doctype html><html><body><h1>Hello world!</h1></body></html>";
/* parse the html and create a dom window */
var window = require('jsdom').jsdom(html, null, {
// standard options: disable loading other assets
@Kami
Kami / gist:824099
Created February 12, 2011 20:41
Benchmark results (PyPy & NodeJS)
Intel Core 2 Quad E6700 @ 3.00
8 GB ram
Ubuntu 10.10
100k iterations
CPython 2.6.6
100.508443832
101.226439953