Skip to content

Instantly share code, notes, and snippets.

@julsam
julsam / ImagePacker.py
Created March 27, 2011 11:17
These two classes can pack surfaces of different sizes into one big surface.
import pygame
class PackNode(object):
"""
Creates an area which can recursively pack images into itself.
"""
def __init__(self, area):
# if tuple contains two elements, assume they are width and height,
# and origin is (0,0)
if len(area) == 2:
>>>>+>+++>+++>>>>>+++[
>,+>++++[>++++<-]>[<<[-[->]]>[<]>-]<<[
>+>+>>+>+[<<<<]<+>>[+<]<[>]>+[[>>>]>>+[<<<<]>-]+<+>>>-[
<<+[>]>>+<<<+<+<--------[
<<-<<+[>]>+<<-<<-[
<<<+<-[>>]<-<-<<<-<----[
<<<->>>>+<-[
<<<+[>]>+<<+<-<-[
<<+<-<+[>>]<+<<<<+<-[
<<-[>]>>-<<<-<-<-[
@julsam
julsam / Spritemap.as
Created April 2, 2011 19:08
flash punk
/** @private Updates the animation. */
override public function update():void
{
if (_anim && !complete)
{
_timer += (FP.fixed ? _anim._frameRate : _anim._frameRate * FP.elapsed) * rate;
if (_timer >= 1)
{
while (_timer >= 1)
{
@julsam
julsam / google-profiles.py
Created May 19, 2011 15:03
Google profiles
import sys
import os.path
import xml.dom.minidom
import urllib2
try:
f = open("profiles-sitemap.xml")
except:
sys.exit("Error opening file")
@julsam
julsam / SerialDialog.pde
Created October 6, 2011 18:23
Arduino Python SerialDialog
int incomingByte = 0;
void
setup()
{
Serial.begin(9600);
}
void
loop()
@julsam
julsam / temperatureSensor.pde
Created January 15, 2012 14:18
Temperature sensor + LED display
int pin = 0; // analog pin
int temp = 0; // temperature variable
int samples[8];
int ledPins[] = { 2, 3, 4, 5, 6, 7 };
int binaries[] = { B00100000, B00010000, B00001000, B00000100, B00000010, B00000001}; // control bits
const int ledCount = 6;
void setup()
{
Serial.begin(9600);
@julsam
julsam / dabblet.css
Created March 14, 2012 14:38
Toggle button with checkboxes & radio
input[type="radio"], input[type="checkbox"] {
display: none;
}
input[type="radio"] + label, input[type="checkbox"] + label {
color: #555;
border: 1px solid #ccc;
border-radius: 4px;
padding: 5px 9px;
line-height: 22px;
.root {
padding: 20px;
position: relative;
}
.root .child {
display: inline-block;
width: 45%;
height: 600px;
background-color: #fff;
position: relative;
@julsam
julsam / GameScene.hx
Created May 22, 2013 08:44
HaxePunk Splitscreen
package ;
import com.haxepunk.HXP;
import com.haxepunk.Scene;
import com.haxepunk.utils.Key;
import nme.display.BitmapData;
import nme.geom.Point;
import nme.geom.Rectangle;
class GameScene extends Scene
@julsam
julsam / final solution; thanks Joshua !
Last active August 29, 2015 13:57
breaking nested loop in haxe - which solution is the best ?
canPlace = 1;
for (y in 0...height)
{
for (x in 0...width)
{
if (mapArr[x][y] != ' ')
{
canPlace = 2;
break;
}