Skip to content

Instantly share code, notes, and snippets.

View robotconscience's full-sized avatar

Brett Renfer robotconscience

View GitHub Profile
// BIND FIX FOR OLDER BROWSERS
if( Function.prototype.bind ) {
} else {
/** safari, why you no bind!? */
Function.prototype.bind = function (bind) {
var self = this;
return function () {
var args = Array.prototype.slice.call(arguments);
return self.apply(bind || null, args);
};
@robotconscience
robotconscience / arduinoquickfind.cpp
Created April 17, 2012 02:24
Find name of Arduino Uno in OF
ofSerial s;
vector <ofSerialDeviceInfo> deviceList = s.getDeviceList();
for(int k = 0; k < (int)deviceList.size(); k++){
port = deviceList[k].getDeviceName();
if ( port.find( "usbmodem" ) != string::npos ) break;
}
cout << "connecting to serial device "<< port<<endl;
@robotconscience
robotconscience / Syscommand.h
Last active October 8, 2017 21:49
openFrameworks threaded system command caller with output
//
// SysCommand.h
//
// Created by Brett Renfer on 2/22/12.
//
#pragma once
#include "ofThread.h"
class SysCommand : private ofThread
@robotconscience
robotconscience / ofNoWindowRunner.cpp
Created June 7, 2012 18:27
Use ofAppNoWindow on OS X
//
// ofNoWindowRunner.cpp
// touchForwarder
//
// Created by Brett Renfer on 6/7/12.
// Copyright (c) 2012 Rockwell Group. All rights reserved.
//
#include "ofNoWindowRunner.h"
#include "ofAppRunner.cpp"
@robotconscience
robotconscience / Ray.js
Created September 4, 2012 15:47
THREE Ray intersectObject with Sprite support
// override THREE Ray
THREE.Ray.prototype.intersectObject = function ( object, recursive ) {
var intersect, intersects = [];
if ( recursive === true ) {
for ( var i = 0, l = object.children.length; i < l; i ++ ) {
@robotconscience
robotconscience / loadStrings.h
Created January 27, 2013 19:39
Openframeworks version of Processing's loadStrings
static vector<string> loadStrings( string file ){
static vector<string> ret;
ret.clear();
ofBuffer temp = ofFile( file ).readToBuffer();
while ( !temp.isLastLine() ){
ret.push_back( temp.getNextLine() );
cout<<ret.back()<<endl;
}
return ret;
@robotconscience
robotconscience / ofxiOSImageSaver.h
Created September 10, 2014 16:05
openFrameworks iOS image saving
//
// ofxiOSImageSaver.h
// Colorizer
//
// Created by Brett Renfer on 9/9/14.
//
#pragma once
#include "ofMain.h"
@robotconscience
robotconscience / ofxiOSImageSharer.h
Last active August 29, 2015 14:06
openFrameworks iOS share window creation
//
// ofxiOSImageSharer.h
// Created by Brett Renfer on 9/9/14.
//
#pragma once
#import <UIKit/UIKit.h>
#include "ofMain.h"
@class ofxiOSViewController;
@robotconscience
robotconscience / ofxLibwebsockets_socketio_client.h
Created September 30, 2014 16:52
Start of connecting ofxLibwebsockets with socket.io. Not finished and probably won't ever be...
#include "ofApp.h"
string sid = "";
//--------------------------------------------------------------
void ofApp::setup(){
ofSetLogLevel(OF_LOG_VERBOSE);
ofxLibwebsockets::ClientOptions opts = ofxLibwebsockets::defaultClientOptions();
opts.channel = "/socket.io/1/websocket?EIO=2&transport=websocket&sid=";
opts.port = 3000;
@robotconscience
robotconscience / SvgSampler.h
Created November 18, 2014 14:52
openFrameworks SVG color sampler
#pragma once
#include "ofxSvg.h"
class SvgSampler {
public:
void load( string svgFile ){
svg.load(svgFile);