Skip to content

Instantly share code, notes, and snippets.

@oampo
oampo / WebKitBufferPlayer.js
Created January 12, 2012 10:49
Web Audio API Buffer Playback for Audiolet
var WebKitBufferPlayer = function(audiolet, url) {
AudioletNode.call(this, audiolet, 0, 1);
this.isWebKit = this.audiolet.device.sink instanceof Sink.sinks.webkit;
this.context = this.audiolet.device.sink._context;
if (this.isWebKit) {
this.xhr = new XMLHttpRequest();
this.xhr.open("GET", url, true);
this.xhr.responseType = "arraybuffer";
@oampo
oampo / gist:1639302
Created January 19, 2012 10:30
XHR for WebGL file export
var data = this.canvas.toDataURL();
var request = new Request({
url: 'http://127.0.0.1:8080',
onFailure: function(xhr) {
console.error(xhr);
}
});
url = request.send('data=' + data + '&frame=' + this.frameCount);
@oampo
oampo / __hooks__.py
Created January 16, 2013 12:13
Template globals in Wok
from template_globals import template_globals
hooks = {
"page.template.pre" : [template_globals]
}
@oampo
oampo / Makefile
Last active December 26, 2015 04:49
STM32F4 Blinkenlights
# Useful locations
MBED = ../../mbed/build/mbed
# MCU
MANUFACTURER=STM
FAMILY=STM32F4XX
MCU=STM32F407
# Files
SRC = $(wildcard *.cc)
@oampo
oampo / serial_example.ino
Created December 4, 2013 10:09
Python->Arduino communication example
void setup() {
Serial.begin(9600);
pinMode(13, OUTPUT);
}
void loop() {
String serialString;
while (Serial.available()) {
serialString += Serial.read();
}
@oampo
oampo / api_tests.py
Created December 16, 2013 15:08
Flask API Testing
import unittest
import json
import uppr
class ApiTests(unittest.TestCase):
def setUp(self):
import os
class Config(object):
DEBUG = False
TESTING = False
CSRF_ENABLED = True
SECRET_KEY = 'temporary_secret_key'
class ProductionConfig(Config):
pass
@oampo
oampo / anagrams.py
Created January 28, 2014 15:21
Finds whether two strings are anagrams
import sys
from collections import Counter
c1 = Counter(sys.argv[1])
c2 = Counter(sys.argv[2])
c1.subtract(c2)
print not any(c1.values())
@oampo
oampo / list.css
Last active August 29, 2015 14:02
Pages #crumbs #no-index
ul.list {
list-style-type: none;
padding: 0;
font-size: 2em;
text-align: center;
}
@oampo
oampo / aliases.json
Last active August 29, 2015 14:02
Aliases #crumbs #no-index
{
"/work": "8ad52561445ec13c0d04",
"/about": "e63b610e2ce53f4d6aba",
"/local": "f7c18ce5e76151cbaf93"
}