Skip to content

Instantly share code, notes, and snippets.

View RandomEtc's full-sized avatar
🦕

Tom Carden RandomEtc

🦕
View GitHub Profile
@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 / example usage
Created March 2, 2010 21:28
really simple Flickr API code for as3
var flickr:Flickr = new Flickr('YOUR_KEY_HERE');
flickr.call('flickr.people.findByUsername', { username: 'Steve Coast' }, function(event:Event):void {
var rsp:XML = XML(event.target.data);
var userId:String = rsp.user[0].@id.toString();
flickr.call('flickr.photos.search', { user_id: userId, has_geo: 1, extras: 'geo' }, function(event:Event):void {
var rsp:XML = XML(event.target.data);
for each (var photo:XML in rsp.photos.photo) {
var lat:Number = parseFloat(photo.@latitude);
var lon:Number = parseFloat(photo.@longitude);
@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 / albers.js
Created July 14, 2010 23:18
An Albers Equal Area Conic projection in javascript, for protovis.
/*
An Albers Equal Area Conic projection in javascript, for protovis.
For centering the contiguous states of the USA in a 800x400 div, I used:
var scale = pv.Geo.scale(albers(23, -96, 29.5, 45.5))
.range({ x: -365, y: -375 }, { x: 1200, y: 1200 });
http://mathworld.wolfram.com/AlbersEqual-AreaConicProjection.html
@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;