Skip to content

Instantly share code, notes, and snippets.

@trentbrooks
trentbrooks / gist:bfb6412fbbf5e28dfba6
Created June 19, 2014 00:11
ofSystem bug with fclose in openframeworks
string ofSystem(string command){
FILE * ret = NULL;
#ifdef TARGET_WIN32
ret = _popen(command.c_str(),"r");
#else
ret = popen(command.c_str(),"r");
#endif
string strret;
char c;
@trentbrooks
trentbrooks / TemplateInfo.plist
Created April 29, 2014 07:52
Edit the xcode c++ template- duplicate C++ Class.xctemplate in Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/File Templates/ C and C++/
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>AllowedTypes</key>
<array>
<string>public.c-plus-plus-source</string>
</array>
<key>DefaultCompletionName</key>
<string>File</string>
@trentbrooks
trentbrooks / gist:11392776
Created April 29, 2014 07:18
Download all images from website (1-88 on gratisography.com) with curl
curl "http://www.gratisography.com/pictures/[1-88]H.jpg" -o "#1.jpg"
@trentbrooks
trentbrooks / gist:9357821
Last active August 29, 2015 13:57
stringstream extraction
string data = "hello there";
// standard stringstream extraction based on ' ' character
stringstream ss(data);
string extract1;
ss >> extract1; // hello
cout << extract1 << endl;
string extract2;
ss >> extract2; // there
cout << extract2 << endl;
@trentbrooks
trentbrooks / gist:8969897
Last active August 29, 2015 13:56
for kurt
int previousStatus = 0; // 0 = nothing, 1 = hand above head
int resetStatusCounter = 0;
int resetStatusThreshold = 100;
void draw() {
// do normal kinect updates and processing here (your code)
int status = ?; // you need to work out when hand is above, etc
@trentbrooks
trentbrooks / gist:7496260
Created November 16, 2013 05:14
Point Grey modified
#include "FlyCapture2.h"
using namespace FlyCapture2;
@trentbrooks
trentbrooks / gist:7444679
Created November 13, 2013 06:33
Easy event listener adding/removing. Put below methods in the object's .h only, and make sure the testApp has the onSomething method.
template <class ListenerClass>
void addEventListener(ListenerClass * listener){
ofAddListener(onChangedEvent,listener,&ListenerClass::onSomething);
};
template <class ListenerClass>
void removeEventListener(ListenerClass * listener){
ofRemoveListener(onChangedEvent,listener,&ListenerClass::onSomething);
};
@trentbrooks
trentbrooks / gist:7206615
Created October 28, 2013 23:26
Icosahedron
ofMesh ico = createIcosahedron(120);
ofMesh testApp::createIcosahedron(float size) {
ofMesh mesh;
GLdouble vertexB[][3]= {
{0, -0.525731, 0.850651}, // vertices[0]
{0.850651, 0, 0.525731}, // vertices[1]
{0.850651, 0, -0.525731}, // vertices[2]
{-0.850651, 0, -0.525731}, // vertices[3]
@trentbrooks
trentbrooks / drawRibbonRainbow
Last active December 25, 2015 03:49
draw a rainbow ribbon (uses MeshUtils.h)
deque<ofVec3f> mousePts;
void testApp::drawRibbonRainbow() {
mousePts.push_back(ofVec3f(ofGetMouseX(), ofGetMouseY(), 0));
ofPolyline polyPoints;
for(int i = 0; i < mousePts.size(); i++) {
polyPoints.addVertex(mousePts[i]);
}
@trentbrooks
trentbrooks / .bash_profile
Created May 20, 2013 00:39
Lazy GitHub shortcut: copy file into your home directory next to '.bash_history' (if .bash_profile already exists, just copy/paste the function below). Launch terminal, cd into your local repo, then type- gitit "some commit". Note, function assumes your working with a 'develop' branch, if not change 'develop' to whatever your branch is, eg. 'mas…
function gitit {
git pull origin develop
git add -A
git commit -am "$1"
git push origin develop
}