Skip to content

Instantly share code, notes, and snippets.

@abicky
abicky / gist:3052980
Created July 5, 2012 11:00
Create HTMLImageElement from HTMLCanvasElement and HTMLCanvasElement from HTMLImageElement
import "js/web.jsx";
class Util {
static function image2Canvas(image : HTMLImageElement) : HTMLCanvasElement {
var document = dom.window.document;
var canvas = document.createElement("canvas") as HTMLCanvasElement;
canvas.width = image.width;
canvas.height = image.height;
var ctx = canvas.getContext("2d") as CanvasRenderingContext2D;
ctx.drawImage(image, 0, 0);
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"