Skip to content

Instantly share code, notes, and snippets.

View RandomEtc's full-sized avatar
🦕

Tom Carden RandomEtc

🦕
View GitHub Profile
@RandomEtc
RandomEtc / index.html
Last active September 26, 2015 23:47
Modest Maps Throwable
<!DOCTYPE html>
<html>
<head>
<title>Modest Maps JS - Throwable Test</title>
<script type="text/javascript" src="modestmaps.min.js"></script>
<script type="text/javascript">
(function(MM){
MM.ThrowableHandler = function() { }
@RandomEtc
RandomEtc / conversion.sh
Created September 13, 2011 04:00
conversion loops in bash
# to make a folder full of animated gifs into a folder full of vertical frames
# (brew install imagemagick)
for i in *.gif;do echo $i
convert "$i" "`echo $i | sed -e 's/\.gif//g'`%02d.gif"
convert "`echo $i | sed -e 's/\.gif//g'`*.gif" -append $i
done
# to make a folder full of html into a folder full of pdfs
# (brew install wkhtml2pdf)
@RandomEtc
RandomEtc / mongo_import.js
Created September 15, 2011 16:04
use node.js to copy from one mongo db to another
var url = require('url'),
mongodb = require('mongodb');
var sourceUrl = 'mongodb://user:pass@host:port/db',
targetUrl = 'mongodb://user:pass@host:port/db',
collectionName = 'my_awesome_collection';
function openDbFromUrl(mongoUrl, cb) {
var dbUrl = url.parse(mongoUrl),
dbName = dbUrl.pathname.slice(1), // no slash
@RandomEtc
RandomEtc / 1-make-key
Created September 16, 2011 16:35
generating SSL keys and Certificate Signing Requests for Heroku / Nginx / RapidSSL
Key was generated using:
tom% openssl genrsa -des3 -out example.com.key 2048
Generating RSA private key, 2048 bit long modulus
....+++
..........................................................................................................................+++
e is 65537 (0x10001)
Enter pass phrase for example.com.key:
Verifying - Enter pass phrase for example.com.key:
%tom
@RandomEtc
RandomEtc / README.md
Created September 22, 2011 02:41
Map Tiles in D3

An exercise in learning D3 / a proof of concept / my hat-in-the-ring for what comes next after Polymaps and Modest Maps. See the github project page for more information.

@RandomEtc
RandomEtc / Procfile
Created September 26, 2011 15:59
Getting Kue working on Heroku
web: node app.js
worker: node consumer.js
@RandomEtc
RandomEtc / README.md
Created September 28, 2011 19:06
How to enforce provider limits on interaction and tile loading in Modest Maps JS

See issue 57 for discussion and planned improvements.

@RandomEtc
RandomEtc / Makefile
Created December 7, 2011 23:17
Using Boost Signals2 to pass messages, return true to cancel propagation
# don't hate me for this Makefile, at least I provided one
BOOST_PATH = /Users/tom/Documents/Code/Cinder/Cinder/boost
main: main.o
g++ -o main main.o
main.o: main.cpp
g++ -c -I$(BOOST_PATH) -o main.o main.cpp
@RandomEtc
RandomEtc / csv2html.js
Created February 11, 2012 19:06
Quick node.js script to convert a CSV file to HTML
// first of all make sure we have enough arguments (exit if not)
if (process.argv.length != 5)
{
console.error("Usage: node csv2html.js input.csv template.ejs output.html")
console.error();
console.error("Outputs the given template for each row in the given input.")
console.error("Uses the first row of the CSV as column names in the template.")
process.exit(1);
}
@RandomEtc
RandomEtc / surrogate.js
Created February 20, 2012 20:36
fussing with UTF-16 surrogate encoding in Javascript
// see http://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B0000_to_U.2BD7FF_and_U.2BE000_to_U.2BFFFF
function escapeBMP(n) {
return '\\u'+('0000'+n.toString(16)).slice(-4);
}
// see http://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B10000_to_U.2B10FFFF
function makeSurrogate(n) {
var a = n - 0x10000;
var highBits = a >> 10;
var lowBits = a & 0x3FF;