Skip to content

Instantly share code, notes, and snippets.

@cheery
cheery / index.coffee
Created June 25, 2012 10:02
web app template
# position into www/index.coffee
getBuffer = (url, response) ->
xhr = new XMLHttpRequest()
xhr.open 'GET', url, true
xhr.responseType = 'arraybuffer'
xhr.onload = response
xhr.send()
$ ->
document.body.innerHTML = "<p>hello there!</p>"
@cheery
cheery / non_builtin_types.c
Created July 24, 2012 12:43
hello to you too!
#include <stdio.h>
struct hello {
int hello;
};
typedef struct hello hello;
hello* buffalo(hello* hello) {
hello->hello = 5;
@cheery
cheery / core.py
Created August 12, 2012 21:44
Relatively straightforward structural editor's stub (WIP)
import util
@util.make_list
def mkslots(data):
for obj in data:
if isinstance(obj, Template) or obj == None:
yield One(obj)
else:
try:
g = iter(obj)
import struct
fmt = "llHHi"
fmt_len = struct.calcsize(fmt)
class EvDev(object):
on_event = lambda self, timestamp, type, code, value: None
def __init__(self, devname, fd, id_serial, id_path_tag):
self.devname = devname
self.fd = fd
@cheery
cheery / demo.js
Created October 28, 2012 11:24
Bug with Raspberry pi, EGL and node.js.
console.log("loading bagu");
var bagu = require("./build/Release/bagu");
console.log("bagu loaded");
console.log(bagu);
@cheery
cheery / videocontext.h
Created October 28, 2012 17:34
WebGL interface proposal for node-video
class LinuxVideoContext : public IVideoContext, public node::ObjectWrap {
bool IsCurrent();
void MakeCurrent();
void SwapBuffers();
void Close();
};
@cheery
cheery / compile
Created December 1, 2012 15:53
simple openwf test
#!/bin/sh
CFLAGS="-I/opt/vc/include/ -I/opt/vc/include/interface/vcos/pthreads"
LDFLAGS="-L/opt/vc/lib/ -lWFC -lGLESv2 -lvcos"
gcc enum.c -o bin/enum $CFLAGS $LDFLAGS
@cheery
cheery / evdev.coffee
Created December 17, 2012 15:26
WIP demonstration desktop environment written over the bindings in my repository
fs = require 'fs'
class EvDevIO
constructor: (path, callback) ->
@buffer = new Buffer 16
@view = new DataView @buffer
fs.open path, "r+", (err, @fd) =>
if err then return callback(err, null)
@_read_loop(callback)
@cheery
cheery / png_decode.py
Created December 22, 2013 09:45
Gets difficult to optimize from here. It spends most of the time inside png_filters.c and the builtin zlib decode function.
import struct
import zlib
png_header = "89504E470D0A1A0A".decode('hex')
def png_chunks(file):
header = file.read(8)
assert header == png_header
length = 1
while length > 0:
@cheery
cheery / bootloader.coffee
Created January 29, 2014 19:43
How would I get source maps working here? The scripts are loaded from inside an archive, they need to be wrapped into modules so they find each other.
zip.workerScriptsPath = "lib/"
$ ->
archiveURL = 'app.zip'
requestBlob archiveURL, {
load: (blob) ->
new ZipReader blob, {
load: (entries) ->
console.log "loaded"
runModule(archiveURL, entries, {}, 'scripts/main')