Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

var gistPrefix = 'http://gist.github.com/',
cachedWrite = document.write,
body = $('body'),
gists = $('p.gist').map(function(n, p) {
p = $(p);
var a = $('a', p),
href = a.attr('href');
if (a.length && href.indexOf(gistPrefix) == 0) {
var z="http://gist.github.com/",y=document.write,x=$("body"),w=$("p.gist").map(function(b,a){a=$(a);var c=$("a",a),u=c.attr("href");if(c.length&&u.indexOf(z)==0)return{p:a,id:u.substring(z.length)}}).get(),v=function(){if(w.length==0)document.write=y;else{var b=w.shift();document.write=function(){document.write=function(a){b.p.replaceWith(a);v()}};x.append('<scr'+'ipt src="'+z+b.id+'.js"></scr'+'ipt>')}};v();
meter{
display: block;
border: 1px outset;
height: 20px;
width: 100px;
overflow: hidden;
}
meter div
{
display: block;
@albertobajo
albertobajo / parse_signed_request
Created November 10, 2010 10:03
Python implementation of Facebook's php signed_request parser: http://developers.facebook.com/docs/authentication/canvas
import hmac
import simplejson as json
from base64 import urlsafe_b64decode
from hashlib import sha256
def parse_signed_request(signed_request, secret):
[encoded_sig, payload] = signed_request.split('.')
# decode data
@tracend
tracend / MeasureDistance.js
Created March 29, 2011 23:13
Unity3D: Measure distance
function Update() {
if ( Vector3.Distance( enemy.position, transform.position ) < 10 )
print("I sense the enemy is near!");
}
// Category: This is a free-form string used to categorise your events.
// Action: Another free-form string which represents the type of event, ex. “killed” and “game_start”.
// Label: This is an optional string parameter to the action.
// Value: This is an optional fractional number parameter to the action.
Application.ExternalCall("pageTracker._trackEvent", new object[] { category, action, label, value} );
@AngryAnt
AngryAnt / GameManager.cs
Created May 2, 2011 08:59
GameManager.cs
using UnityEngine;
using System.Collections;
public enum GameStatus
{
Setup,
Initializing,
ReInitializing,
AwaitingMasterServer,
@macintoxic
macintoxic / GameManager.cs
Created May 26, 2011 20:22 — forked from AngryAnt/GameManager.cs
GameManager.cs
using UnityEngine;
using System.Collections;
public enum GameStatus
{
Setup,
Initializing,
ReInitializing,
AwaitingMasterServer,
@AngryAnt
AngryAnt / MyStateMachine.cs
Created May 31, 2011 08:45
A simple state machine using a dictionary of delegates indexed by an enum.
using UnityEngine;
using System.Collections.Generic;
public class MyStateMachine : MonoBehaviour
{
public delegate void StateHandlerDelegate ();
public enum MyStateType
@kylefinley
kylefinley / gist:1025736
Created June 14, 2011 19:59
AppEngine ndb Threaded Messaging.
import cgi
from google.appengine.api import mail
from google.appengine.ext import deferred
from ndb import model
from tipfy.routing import url_for
from tipfyext.ndb.mixins import DateMixin