Skip to content

Instantly share code, notes, and snippets.

View boj's full-sized avatar

Brian Jones boj

View GitHub Profile
@boj
boj / SgfGrammar
Created February 28, 2009 04:02
SgfGrammar
grammar SgfGrammar
rule node
'(' sp chunk* sp ')' sp {
def value
get([elements[2]])
end
def get(e)
a = []
if !e.nil?
#
# Created by Eric Lindvall <eric@sevenscale.com>
#
# WHAT: Provides a simple overview of memory allocation occuring during a
# require.
#
# NOTE: The numbers provided are of self + children, meaning the same will
# be attributed to multiple files at once.
#
# Also, memory that is no longer referenced (and would be freed) is still
class Achievement
include MongoMapper::Document
key :name, String
key :description, String
key :requirements, String
key :lang, String
end
SELECT id, username, exp, money, @prev := @curr, @curr := money, @rank := IF(@prev = @curr, @rank, @rank+1) AS rank FROM users, (SELECT @curr := null, @prev := null, @rank := 0) sel1 ORDER BY money DESC LIMIT 1;
class Watch
# Instance property
location: 'here'
# Class property
@location: 'over there'
locate: ->
alert "I am #{@location}."
@boj
boj / warcraft
Created January 5, 2011 01:00
simple script to keep you from logging out
tell application "World of Warcraft"
activate
end tell
tell application "System Events"
tell process "World of Warcraft"
repeat
set x to (random number from 1 to 2)
if x = 2 then
@boj
boj / score.rb
Created February 22, 2011 10:18
MongoMapper MapReduce Example
class Score
include MongoMapper::Document
key :user_id, ObjectId, :index => true
key :stage, String, :index => true
key :score, Integer
timestamps!
def self.high_score_map
<<-MAP
using UnityEngine;
using System.Collections;
public class SystemController : MonoBehaviour {
const int size = 64;
public GameObject[][] cubes = new GameObject[size][];
public GameObject clone_cube;
void Awake() {
using UnityEngine;
using System.Collections;
public class ParallaxScroll : MonoBehaviour {
public float furthestDepth = 100.0F;
public float depthStep = 10.0F;
public float baseSpeed = 0.001F;
public int baseSpeedup = 2;
@boj
boj / ColorPicker.cs
Created August 30, 2011 17:39
Unity3d Color Picker
using UnityEngine;
using System.Collections;
// relies on: http://forum.unity3d.com/threads/12031-create-random-colors?p=84625&viewfull=1#post84625
public class ColorPicker : MonoBehaviour {
public bool useDefinedPosition = false;
public int positionLeft = 0;
public int positionTop = 0;