Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / MeggyJrGameOfLife.c
Created September 18, 2011 21:15
Conway's game of life for the Meggy Jr
#include <stdlib.h>
#include <MeggyJrSimple.h>
byte screen[8][8] = {{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
@biomood
biomood / cLua
Created October 2, 2011 19:44
Compiling C functions to be called from lua
gcc -Wall -shared -I/usr/local/include/ -L/usr/local/lib/ -llua -o serial.so serial.c
@biomood
biomood / postify.js
Created November 16, 2011 13:30
Postify method, send complex JSON to MVC
$.postify = function(value) {
var result = {};
var buildResult = function(object, prefix) {
for (var key in object) {
var postKey = isFinite(key)
? (prefix != "" ? prefix : "") + "[" + key + "]"
: (prefix != "" ? prefix + "." : "") + key;
@biomood
biomood / C_Lua_Chumby
Created January 5, 2012 21:55
Compiling a c lua library on the chumby
gcc -Wall -shared -I/mnt/storag
e/Lua/include/ -L/mnt/storage/Lua/lib/ -llua -lm -ldl -o screen.so screen.c
@biomood
biomood / PagerList.lua
Created March 14, 2012 21:06
Love2D Paged List
local g = love.graphics
PagerList = {
rowsPerPage = 4,
spaceBetweenRow = 44,
initSpace = 24,
noPages = 0,
currentPage = 0,
noRows = 0,
rowsToDisplay = 0,
luaL_newmetatable(L, SCREENMETA);