Skip to content

Instantly share code, notes, and snippets.

View RandomEtc's full-sized avatar
🦕

Tom Carden RandomEtc

🦕
View GitHub Profile
web: node app.js
@RandomEtc
RandomEtc / resizeable.pde
Created March 28, 2012 04:29
resizeable sketch in Processing (with notification of new size)
void setup() {
size(640,480);
frame.setResizable(true);
}
void draw() {
background(frameCount);
}
@RandomEtc
RandomEtc / escaped-json.js
Created May 11, 2012 05:18
Extra escapey JSON encoding for node.js
// preserve Twitter's style of JSON string encoding...
// escape higher value unicode (lowercase hex)
// escape < and > (uppercase hex)
// escape / in strings (\/)
// hugs! https://gist.github.com/1306986
// http://stackoverflow.com/questions/4901133/json-and-escaping-characters
function escapedStringify(s, emit_unicode) {
var json = JSON.stringify(s);
return emit_unicode ? json : json.replace(/\//g,
function(c) {
@RandomEtc
RandomEtc / Makefile
Created May 16, 2012 21:56
Minimal Objective-C HTTP client for testing UTF8 decoding issues
CC = clang
MAIN = main
SRCS = main.o
default: $(MAIN)
$(MAIN): $(SRCS)
$(CC) -O0 -Wall -o $(MAIN) $(SRCS) -framework Foundation
@RandomEtc
RandomEtc / app-broken.js
Created May 16, 2012 21:58
Minimal node.js server to pass Twitter API responses through JSON parse and stringify
var http = require('http')
https = require('https'),
url = require('url');
// proxy json requests to Twitter API, round-trip through JSON.parse/stringify:
http.createServer(function (req, res) {
if (req.url.indexOf('.json') == req.url.length - '.json'.length) {
var options = { host: 'api.twitter.com', path: req.url }
https.get(options, function(got) {
@RandomEtc
RandomEtc / update.js
Created July 12, 2012 19:43
SQL builder sketches for node.js and node-postgres
/*jshint node:true globalstrict:true*/
"use strict";
var assert = require('assert');
//
// Convenience function for building a simple UPDATE/SET/WHERE/RETURNING statement.
//
// e.g.
//
@RandomEtc
RandomEtc / shader.frag
Created July 26, 2012 23:53
direction shader for OpenCV flows
uniform sampler2D camTex;
uniform sampler2D xTex;
uniform sampler2D yTex;
// HSL functions from http://code.google.com/p/glmixer/source/browse/trunk/shaders/imageProcessing_fragment.glsl?spec=svn195&r=195
float HueToRGB(in float f1, in float f2, in float hue)
{
if (hue < 0.0)
hue += 1.0;
@RandomEtc
RandomEtc / config
Created August 1, 2012 23:45 — forked from bf4/config
campfire transcript export
---
BUNDLE_WITHOUT: ""
@RandomEtc
RandomEtc / README.md
Created October 18, 2012 18:37 — forked from johan/README.md
California earthquake responses by zip code
@RandomEtc
RandomEtc / convert.js
Created October 26, 2012 01:13
Simplify GeoJSON using d3-plugins/simplify (thanks @jasondavies for preserving topology!)
// TODO: options parser with overrides for projection, area etc.
if (process.argv.length != 4) {
console.error("usage: node convert.js <input.json> <output.json>");
process.exit(1);
}
require('d3')
require('./node_modules/d3-plugins/simplify/simplify.js')
var fs = require('fs');