Skip to content

Instantly share code, notes, and snippets.

@drewwells
drewwells / Simple jsonp proxy via node-http-proxy
Created March 10, 2011 17:53
This demo works for basic data, generic requests ie url=http://google.com don't work
var http = require('http'),
httpProxy = require('http-proxy'),
url = require('url');
// Create your proxy server
httpProxy.createServer(function(req, res, proxy){
var baseUrl = url.parse(req.url, true),
query = baseUrl.query,
server = !!query.url ? query.url.replace(/http:\/\/([^:\/]+).*/i,function(url,server){return server;}) : '',
port = !!query.url ? query.url.match(/:(\d+)/) : 80;
@drewwells
drewwells / FPS meter me
Created March 18, 2011 21:10
Add FPS meter to any page
//Copy to URL bar:
javascript:var s=document.createElement("script");s.src="https://github.com/mrdoob/stats.js/raw/master/build/Stats.js",document.body.appendChild(s),s.onload=function(){var a=new Stats,b=a.domElement.style;b.position="fixed",b.left="0px",b.top="0px",document.body.appendChild(a.domElement),setInterval(a.update,1e3/60)}
//Source
var s = document.createElement('script');
s.src = 'https://github.com/mrdoob/stats.js/raw/master/build/Stats.js';
document.body.appendChild(s);
s.onload = function() {
var stats = new Stats(),
@drewwells
drewwells / core.test.js
Created April 14, 2011 20:21
RequireJS and QUnit sitting in a tree
//Wait for relevant code bits to load before starting any tests
define(['core.js'], function( core ) {
module("Core Tests");
test("Test core methods", function(){
expect(2);
equals( 1, 1, "A trivial test");
ok( true, "Another trivial test");
});
@drewwells
drewwells / LICENSE.txt
Created August 12, 2011 01:46 — forked from padolsey/LICENSE.txt
140byt.es -- Click ↑↑ fork ↑↑ to play!
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@drewwells
drewwells / plot.html
Created August 30, 2011 05:08
PhiloGL O3D.Plane
<!DOCTYPE html>
<html>
<head>
<style>
body{
font-family: 'HelveticaRegular',arial,sans-serif;
}
</style>
<script id="shader-fs" type="x-shader/x-fragment">
@drewwells
drewwells / nResolve.js
Created September 15, 2011 15:31
Merge data from many AJAX requests
function aj( url ){
return $.ajax({
url: url,
success: function( data ){
}
);
}
function resolve( args ){
@drewwells
drewwells / index.js
Created October 17, 2011 17:44 — forked from steeleforge/index.js
Simple node.js webserver with logging. Serves whatever files are reachable from the directory where node is running. [support for Node for Windows]
/*
* Fork & Refactor of https://gist.github.com/246761
* -> Credit: Noah Sloan <http://noahsloan.com>
*/
/**
* Simple webserver with logging. Serves whatever files are reachable from
* the directory where node is running. Supports Windows port of node.
*/
var fs = require('fs'),
@drewwells
drewwells / Custom.css
Created October 26, 2011 19:30 — forked from anonymous/gist:1258555
Solarized Dark Theme (with sidebar and view-source colors) for Google Chrome Dev Tools
/**********************************************/
/*
/* Solarized Dark Skin by Mark Osborne - 2011
/*
/* Based on IR_Black Skin by Ben Truyman:
/* https://gist.github.com/1245727
/*
/* and Todd Werth's IR_Black:
/* http://blog.toddwerth.com/entries/2
/*

Issue with manipulating base href and jQuery UI making ajax calls to the new document.baseURI.