Skip to content

Instantly share code, notes, and snippets.

View rc1's full-sized avatar

Ross Cairns rc1

View GitHub Profile
@rc1
rc1 / gist:5254142
Created March 27, 2013 13:29
Quick sketch to speed up the SK Pang Arduino DMX Shield serial in communication protocol.
#include <DmxSimple.h>
// 57600 baud rate
// unsigned char channel | unsigned char value | for 27 times then | read |
// read | read | for 27 times then | unsigned char success |
// DMX devices typically need to receive a complete set of channels
// even if you only need to adjust the first channel. You can
// easily change the number of channels sent here. If you don't
@rc1
rc1 / otf2ttf2eot.sh
Created April 9, 2013 14:49
Converts OpenType fonts file to an Embedded OpenType file on the Mac. Tools installed via homebrew on Mac.
#!/bin/sh
# Convert an OTF font into TTF an EOT formats.
# @source: http://stackoverflow.com/a/2467452/179015
# @note: brew install fontforge
# brew install
# @usage: sh otf2ttf2eot.sh FontName
otfFont="$1.otf"
ttfFont="$1.ttf"
eotFont="$1.eot"
fontforge -c '
@rc1
rc1 / Referenced
Last active December 16, 2015 16:49
How openFrameworks handles
template<>
float ofColor_<float>::limit() {
return 1.f;
}
@rc1
rc1 / Loader.js
Last active December 17, 2015 00:59
Make file for creating an mp3 audio sprite with an info JSON file for Howler.js. Input files maybe audio or video of any format supported by FFMPEG.
loadAudioSpritesObj("/sounds/audiosprite.json", function (sprites) {
console.log(sprites);
});
function loadAudioSpritesObj(filenane, callback) {
$.getJSON(filenane, function(json) {
var sprites = {};
var lastPositionMS = 0;
for (var i=0;i<json.length;i+=2) {
var spriteEndTime = json[i] + lastPositionMS;
@rc1
rc1 / SymphonyCMS.js
Last active December 17, 2015 02:18
Snippets that demonstrate incorporating SymphonyCMS datasources with Express.js and Jade. There are million different way to do this. This assumes all the data of the datasource can be held in memory... objectively not a bad thing: free memcache. We have had SymphonyCMSs notify instances of Express.js when changes in the db have occurred. Howeve…
var http = require('http');
var xml2js = require('xml2js');
var xmlParser = new xml2js.Parser({
normalize: false
});
// SymphonyCMS
var SymphonyCMS = function (options){
options = options || {};
@rc1
rc1 / jade-middleware.js
Last active December 17, 2015 12:49
Jade Compiler Middleware for Connect.js. Behaves similar to [less-middleware](https://npmjs.org/package/less-middleware) but also looks for index.jade files. Has basic caching but should not be used for production code.
var jade = require('jade');
var path = require('path');
var fs = require('fs');
// Debug logger
var useDebugLog = (typeof process.env.DEBUG_JADE_MIDDLEWARE !== "undefined");
var debugLog = function () {
if (!useDebugLog) { return; }
console.log.apply(this, Array.prototype.slice.call(arguments, 0));
};
@rc1
rc1 / ScreenStack.h
Last active December 18, 2015 09:19
#pragma once
#include "ofMain.h"
class ScreenStack;
// Base Screen class for using with ScreenStack
class Screen {
friend class ScreenStack;
public:
@rc1
rc1 / OSX Example
Last active April 11, 2024 18:50
Command line arguments in openFrameworks
open -n ./emptyExampleDebug.app/ --args 1 2 3 4
@rc1
rc1 / rpidipreader.sh
Last active August 11, 2022 15:30
Reading a DIP switch on the RPI
#!/usr/bin/env python
import RPi.GPIO as GPIO
import time
# use P1 header pin numbering convention
GPIO.setmode(GPIO.BOARD)
# Config
pins = [3,5,7,8,10,11,12]
@rc1
rc1 / gist:6163465
Created August 6, 2013 10:37
Console.log snippet for sublime text
<snippet>
<content><![CDATA[console.log("${1:this}", ${2:this});]]></content>
<tabTrigger>l</tabTrigger>
<scope>source.js</scope>
<description>Console.log</description>
</snippet>