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
Created January 29, 2015 19:37
Line graph noodling
<!DOCTYPE html>
<meta charset="utf-8">
<style>
html, body { margin: 0; }
.line {
fill: none;
stroke-width: 2.0;
}
.axis .tick line, .axis path.domain {
@RandomEtc
RandomEtc / callNextFrame.as
Created July 7, 2009 17:43
callNextFrame for as3
protected var delayedCalls:Array = [];
protected function callNextFrame(callback:Function, args:Array=null):void
{
delayedCalls.push({ callback: callback, args: args });
if (!hasEventListener(Event.ENTER_FRAME)) {
addEventListener(Event.ENTER_FRAME, onEnterForCallNextFrame);
}
}
@RandomEtc
RandomEtc / MatrixUtils.cs
Created August 5, 2009 00:07
simple C# Matrix manipulation for Silverlight transforms
using System;
using System.Windows.Media;
namespace Stamen
{
/*
* Extension methods for Matrix manipulation in Silverlight.
*
* Note that by default C# passes structs by value (and
* extension functions can't pass by reference) so the matrix
@RandomEtc
RandomEtc / tile_chop.pde
Created November 23, 2009 21:57
Resize big images to the nearest power of two and cut them up into 256px tiles.
String imageName = "world.topo.bathy.200401.3x5400x2700.jpg";
noSmooth();
print("opening original image... ");
PImage img = loadImage(imageName);
println("done!");
if (img.width % 256 != 0 || img.height % 256 != 0) {
@RandomEtc
RandomEtc / MapUtil.as
Created January 26, 2010 16:30 — forked from notlion/MapUtil.as
Ryan's quick Yahoo geocoder in as3
package candymaps.map
{
import com.modestmaps.geo.Location;
import flash.events.Event;
import flash.net.URLLoader;
import flash.net.URLRequest;
public class MapUtil
{
@RandomEtc
RandomEtc / MultiTouchController.pde
Created March 7, 2010 05:12
multi-touch for Android Processing
// from http://lukehutch.wordpress.com/2010/01/06/my-multi-touch-code-ported-to-eclair/
/**
* MultiTouchController.java
*
* (c) Luke Hutchison (luke.hutch@mit.edu)
*
* Modified for official level 5 API by Cyanogen (shade@chemlab.org)
*
@RandomEtc
RandomEtc / yql-csv.html
Created July 27, 2010 06:12
load csv files from anywhere using YQL
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$.ajax({
url: 'http://query.yahooapis.com/v1/public/yql',
data: {
q: "select * from csv where url='http://www.tom-carden.co.uk/p5/tube_map_travel_times/data/lines2.csv' and columns='station1,station2,line,time'",
format: 'json'
@RandomEtc
RandomEtc / ComposedEventDispatcher.as
Created August 10, 2010 18:31
implements IEventDispatcher, for when you can't subclass EventDispatcher directly
///// IN IMPORTS
import flash.events.IEventDispatcher;
import flash.events.EventDispatcher;
/////
///// IN CLASS DECLARATION:
implements IEventDispatcher
/////
///// IN CONSTRUCTOR:
@RandomEtc
RandomEtc / BingMapsProvider.as
Created August 11, 2010 00:14
experimental Modest Maps provider for the Bing REST API
package com.modestmaps.mapproviders.microsoft
{
import com.modestmaps.core.Coordinate;
import com.modestmaps.mapproviders.AbstractMapProvider;
import com.modestmaps.mapproviders.IMapProvider;
import com.modestmaps.util.BinaryUtil;
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.events.IEventDispatcher;
function loadCSV(url, columns, callback) {
var req = new XMLHttpRequest();
req.open('GET', url, true);
req.onreadystatechange = function (aEvt) {
if (req.readyState == 4) {// && req.status == 200) {
callback(parseCSV(req.responseText, columns));
}
};
req.send(null);
}