Skip to content

Instantly share code, notes, and snippets.

View joshcarr's full-sized avatar
👁️
Seeing

Josh Carr joshcarr

👁️
Seeing
View GitHub Profile
@joshcarr
joshcarr / gist:648079
Created October 26, 2010 23:26
SVN bash script to export changed files
#!/bin/bash
# USAGE:
# ./svn-export revision-from revision-to repository target-directory
# ./svn-export 20 25 svn://localhost/myrepository .
if [ ! $1 ] || [ ! $2 ] || [ ! $3 ] || [ ! $4 ]; then
echo "Please enter a revision from, revision to, SVN repository, and target directory"
exit
fi
@joshcarr
joshcarr / soundwaves.js
Created May 1, 2014 23:16
Creating sound waves with JavaScript
// Creating sound waves with JavaScript
// from http://js.do/blog/sound-waves-with-javascript/
var samples = []
//
//
//
// Achord
@joshcarr
joshcarr / README.md
Last active August 24, 2023 04:09 — forked from mbostock/.block
Google Maps + D3 + hexbin

This example shows how to use the d3.hexbin plugin for hexagonal binning on GoogleMaps. It is an update of Mike Bostock's Google Maps + D3 block.

@joshcarr
joshcarr / bookmarklet-boilerplate.js
Last active August 9, 2023 08:51
bookmarklet boilerplate
javascript:(function(){
// avoid the bookmarklet activating more than once
if (window.MyNamespace) {
return;
}
window.MyNamespace = { };
var version = 1,
script = document.createElement('script');
@joshcarr
joshcarr / window-height-width.js
Created July 3, 2014 00:04
vanilla JS window width and height
// vanilla JS window width and height
var w=window,
d=document,
e=d.documentElement,
g=d.getElementsByTagName('body')[0],
x=w.innerWidth||e.clientWidth||g.clientWidth,
y=w.innerHeight||e.clientHeight||g.clientHeight;
@joshcarr
joshcarr / groupby.js
Created June 12, 2014 23:52
Javascript GroupBy function
function groupBy( array , f ) {
var groups = {};
array.forEach( function( o )
{
var group = JSON.stringify( f(o) );
groups[group] = groups[group] || [];
groups[group].push( o );
});
return Object.keys(groups).map( function( group )
{
@joshcarr
joshcarr / README.md
Last active February 9, 2020 20:01 — forked from mbostock/.block
@joshcarr
joshcarr / .block
Created April 19, 2017 18:54 — forked from Azgaar/.block
Fantasy Map Generator
license: gpl-3.0
height: 760
border: no
@joshcarr
joshcarr / bling.js
Created June 10, 2016 17:17 — forked from paulirish/bling.js
bling dot js
/* bling.js */
window.$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function (name, fn) {
this.addEventListener(name, fn);
}
NodeList.prototype.__proto__ = Array.prototype;
@joshcarr
joshcarr / clone.js
Created July 14, 2014 19:13
Javascript Cloning
// FROM http://stackoverflow.com/questions/728360/most-elegant-way-to-clone-a-javascript-object
// When I had to implement general deep copying I ended up compromising by
// assuming that I would only need to copy a plain Object, Array, Date, String,
// Number, or Boolean. The last 3 types are immutable, so I could perform a
// shallow copy and not worry about it changing. I further assumed that any
// elements contained in Object or Array would also be one of the 6 simple
// types in that list. This can be accomplished with code like the following:
function clone(obj) {