Skip to content

Instantly share code, notes, and snippets.

#include "Vec.h"
Vec Vec::cross(Vec o) {
Vec r;
r.x = y*o.z - z*o.y;
r.y = z*o.x - x*o.z;
r.z = x*o.y - y*o.x;
return r;
}
#include "Camera.h"
//The arch-dependent stuff
inline void Camera::firstUpdate() {
#ifdef WIN32
QueryPerformanceFrequency((LARGE_INTEGER*)&pFreq);
QueryPerformanceCounter((LARGE_INTEGER*)&pLastUpdate);
#else
gettimeofday(&pLastUpdate, NULL);
Q=(function() { q = "Q=(" + Q.toString() + ")()"; document.write(q); })()
@ANorwell
ANorwell / gist:761390
Created December 31, 2010 22:35
Initializing a graph in Graph.js
var G = new Graph(canvasElement);
@ANorwell
ANorwell / gist:761394
Created December 31, 2010 22:45
Graph.js JSON serialization
var graphJSON = G.toJSON();
G.fromJSON(graphJSON);
@ANorwell
ANorwell / gist:761411
Created December 31, 2010 23:08
Graph.js isEditable option
G.setOption('isEditable', true);
@ANorwell
ANorwell / gist:761414
Created December 31, 2010 23:10
Graph.js local storage
G.save("my graph")
//get a list of all graphs that are currently saved
var savedGraphs = G.getSavedGraphsList();
G.load(savedGraphs[0]);
@ANorwell
ANorwell / gist:761421
Created December 31, 2010 23:24
Graph.js setOption Example
//draw vertices as green circles
G.setOption('vertexDrawFunction',
//v is a vertex object with x and y attributes.
function(ctx,v,graph) {
ctx.beginPath();
ctx.fillStyle= '#0f0';
ctx.arc(v.x,v.y, 5,0,10,false);
ctx.fill();
ctx.closePath();
@ANorwell
ANorwell / gist:761427
Created December 31, 2010 23:36
Graph.js server storage
function loadGraph(canvasId, gid) {
var canvas = document.getElementById(canvasId);
var G = new Graph(canvas);
$.get(gServer,
{ type: "graph", id: gid },
function(data) {
G.fromJSON(data[0]["graph"]);
});
return G;
};
@ANorwell
ANorwell / gist:957773
Created May 5, 2011 19:51
Facebook client-side login
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js#appId=1234512345&amp;xfbml=1"></script>
<fb:login-button show-faces="true" width="200" max-rows="1"></fb:login-button>