Skip to content

Instantly share code, notes, and snippets.

@biomood
biomood / Font.h
Created September 12, 2011 19:44
Client code for Meggy Jr to display a weather icon and temperature from host machine
char one[8][4] = {{0, 0, 1, 0},
{0, 0, 1, 0},
{0, 0, 1, 0},
{0, 0, 1, 0},
{0, 0, 1, 0},
{0, 0, 1, 0},
{0, 0, 1, 0},
{0, 0, 1, 0}};
char two[8][4] = {{1, 1, 1, 1},
@biomood
biomood / debug.cs
Created August 17, 2011 12:58
C# Debug Check
// to check if the exe is running in debug mode use:
#if DEBUG
// put code to run in debugmode
#endif
@biomood
biomood / Mergesort.lua
Created August 8, 2011 20:30
MergeSort in Lua
--[[ Implementation of MergeSort --]]
-- main mergesort algorithm
function mergeSort(A, p, r)
-- return if only 1 element
if p < r then
local q = math.floor((p + r)/2)
mergeSort(A, p, q)
mergeSort(A, q+1, r)
merge(A, p, q, r)
@biomood
biomood / ajax-json.js
Created August 1, 2011 13:33
Ajax sending a POST request with json
$.ajax({
url: "Service/request",
async: false,
type: "POST",
dataType: "json",
contentType: "application/json",
data: JSON.stringify(obj),
cache: false,
success: function (data) {
alert(data);
@biomood
biomood / InterruptMSP430.c
Created July 6, 2011 21:13
MSP430 - use an interrupt to set the LEDs on and off using the button
//
// main.c
//
// Use an interrupt to set two LEDs on the MSP430 on and off
// Created by David Roberts on 06/07/2011.
//
#include <io.h>
#include <signal.h>
@biomood
biomood / main.c
Created July 4, 2011 16:23
Displays the binary representation of an unsigned char using an MSP430
//
// main.c
// BlinkingLEDs
//
// Created by David Roberts on 30/06/2011.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#include <io.h>
@biomood
biomood / SpriteAnimate.cpp
Created June 29, 2011 15:57
Display an animating sprite using the Gameduino
#include <SPI.h>
#include <GD.h>
#include "alien_sprite.h"
struct sprite {
int no;
int x;
int y;
int anim;
byte rot;
@biomood
biomood / Sprite.cpp
Created June 27, 2011 21:44
Displaying a sprite using the Gameduino
#include <SPI.h>
#include <GD.h>
#include "alien_sprite.h"
void setup() {
// allow for setup
delay(250);
GD.begin();
@biomood
biomood / ImageToH.py
Created June 22, 2011 20:57
Python script to create a gameduino sprite header from an image
import sys
from PIL import Image
from gameduino import prep
image_path = ""
h_name = ""
# retrieve the command line arguments
if (len(sys.argv) > 2):
@biomood
biomood / AddRecordLinq.cs
Created June 22, 2011 11:05
Add a record to a DB using Linq to SQL
DataContext db = new DataContext();
try {
db.table.InsertOnSubmit(obj);
db.SubmitChanges();
}
catch(Exception) {
return false;
}
return true;