Skip to content

Instantly share code, notes, and snippets.

View jaz303's full-sized avatar

Jason Frame jaz303

  • Glasgow, Scotland, UK
  • 13:15 (UTC +01:00)
View GitHub Profile
Setting up an AS3/TextMate project, before I forget:
System
======
1. Install SDK in /Developer/SDKs/flex_sdk_x
2. Add SDK to $PATH (optional)
3. Install ActionScript 3 Bundle (if not in shared-env)
4. Set TextMate vars (Preferences -> Advanced -> Shell Variables)
* TM_FLEX_USE_FCSH => true
* TM_FLEX_PATH => /Developer/SDKs/flex_sdk_x
@jaz303
jaz303 / deadlock.rb
Created November 12, 2010 15:40
Can anyone tell me why this code deadlocks?
require 'socket'
require 'thread'
module SC
PORT = 0x55DE
def self.test
queue = Queue.new
sender = MessageSender.new(queue)
sender.start
@jaz303
jaz303 / gist:781358
Created January 15, 2011 23:17
Key State
<html>
<head>
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js'></script>
<script type='text/javascript'>
var states = {};
// w - 87
// a - 65
// s - 83
// d - 68
#
# This is how I would do this in Javascript
p RUBY_VERSION # 1.8.7
puts "With factory method:"
procs_1 = []
def make_proc(i)
class Handler {
public void handle(InputEvent ie) {
ie.dispatch(this);
}
public void handleInput(InputEvent ie) {
System.out.println("ERROR - NO HANDLER DEFINED");
}
public void handleInput(MouseEvent me) {
@jaz303
jaz303 / gist:890362
Created March 28, 2011 12:17
Snakes and Ladders!
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int squares[] = {
0, 36, 0, 10, 0, 0, 0, 0, 22, 0,
0, 0, 0, 0, 0, 0, -10, 0, 0, 0,
21, 0, 0, 0, 0, 0, 0, 56, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@jaz303
jaz303 / gist:1149141
Created August 16, 2011 13:55
Releasing within initializer - is this OK/best practice?
- (id)initWithFrame:(CGRect)frame {
if ((self = [super initWithFrame:frame])) {
if (![self _bindLayer]) {
[self release];
self = nil;
}
}
return self;
}
@jaz303
jaz303 / Makefile
Created October 23, 2011 15:57
Makefile for Linux STM32 microcontroller development
CC = arm-none-eabi-gcc
LD = arm-none-eabi-ld -v
AR = arm-none-eabi-ar
AS = arm-none-eabi-as
CP = arm-none-eabi-objcopy
OD = arm-none-eabi-objdump
CFLAGS = -I./ -I./stdlib/inc -DSTM32F10X_MD -fno-common -O0 -g -mcpu=cortex-m3 -mthumb
AFLAGS = -ahls -mapcs-32
LFLAGS =
@jaz303
jaz303 / gist:2204603
Created March 26, 2012 11:50
classy enums
public enum ShotType {
PISTOL (2, new Vec3f(0, 0, -35), new Vec3f(0, -1, 0), 0.99f),
ARTILLERY (200, new Vec3f(0, 30, -40), new Vec3f(0, -20, 0), 0.99f),
FIREBALL (1, new Vec3f(0, 0, -10), new Vec3f(0, 6, 0), 0.9f),
LASER (0.1f, new Vec3f(0, 0, -100), new Vec3f(0, 0, 0), 0.99f);
private final float mass;
private final Vec3f velocity;
private final Vec3f acceleration;
private final float damping;
// trying to do this:
var fn = new Function("foo", "bar", "baz", "return foo + bar + baz;");
// with arbitrary number of args:
var args = ["foo", "bar", "baz"];
var src = "return foo + bar + baz;"
// with a non-ctor fn i'd do:
var allArgs = args.slice(0);
allArgs.push(src);