Skip to content

Instantly share code, notes, and snippets.

View ofZach's full-sized avatar

ofZach

View GitHub Profile
@ofZach
ofZach / gitignore OF
Created September 12, 2012 14:41
good gitignore for OF
# Some general ignore patterns
build/
obj/
*.o
Debug*/
Release*/
*.mode*
*.app/
*.pyc
.svn/
@ofZach
ofZach / all OF addons
Created October 16, 2012 02:30
all openframeworks addons from ofxAddons
#!/bin/bash
git clone git://github.com/armadillu/ofxAnimatable.git;
git clone git://github.com/yuichi1004/ofxAnimationKit.git;
git clone git://github.com/alinakipoglu/ofxAssimpNISync.git;
git clone git://github.com/alinakipoglu/ofxAssimpOpenNISkeletonSync.git;
git clone git://github.com/after12am/ofxBoids.git;
git clone git://github.com/diasbruno/ofxCompositeMotion.git;
git clone git://github.com/paulobarcelos/ofxDisplayStackObject.git;
git clone git://github.com/satoruhiga/ofxEasingFunc.git;
@ofZach
ofZach / statistics
Created November 4, 2012 22:23
statistics / C++
/// This is a recipe from the O'Reilly Safari Cookbook
/// http://safari.oreilly.com/0596007612/cplusplusckbk-CHP-11-SECT-5
/// Usage:
/// vector<int> v;
/// computeStats(v.begin( ), v.end( ), sum, mean, var, dev, skew, kurt);
#pragma once
@ofZach
ofZach / calibration pattern
Created November 9, 2012 11:42
calibration pattern
// useful for projection alignment, etc:
// http://i.imgur.com/rWJLE.jpg
int nbOfCol = ofGetWidth() / 25;
int boardWidth = ofGetWidth();
int boardHeight = ofGetHeight();
@ofZach
ofZach / gist:5082043
Created March 4, 2013 12:48
median filter for arduino, uses bubble sort
// medianFilter filter;
// filter.addValue(5);
// filter.addValue(3);
// filter.addValue(2);
// filter.addValue(100);
// filter.addValue(9);
// Serial.println(filter.getMedian());
//
// filter.addValue(100);
// Serial.println(filter.getMedian());
// was noticing sin(ofGetElapsedTimef()) gets crunchy at some point, because of lower resolution in sin / cos. here's an alternative function that seems to help... not tested for speed.
float ofGetElapsedTimeForSin(){
long long timeNow = ofGetElapsedTimeMillis();
long long modForTwoPi = (int)(TWO_PI*1000.0);
return ((float)(timeNow % modeForTwoPi)/1000.0);
}
@ofZach
ofZach / gist:7808368
Created December 5, 2013 16:20
modifying glfw window in OF (0.8)
// in main.cpp
ofAppGLFWWindow w;
ofSetupOpenGL(&w, 1024,432,OF_WINDOW); // <-------- setup the GL context
testApp * app = new testApp();
app->WINDOW = &w;
ofRunApp(app);
@ofZach
ofZach / gist:8242765
Created January 3, 2014 17:53
billboard using ofNode / ofCamera
//--------------------------------------------------------------
void testApp::draw(){
glEnable(GL_DEPTH_TEST);
ofEnableLighting();
ofLight light;
light.setPosition(ofPoint(-200,0, -1000));
light.lookAt( ofPoint(-1000,0,0));
light.setDirectional();
@ofZach
ofZach / gist:8255060
Created January 4, 2014 12:44
funky curved line via ofNode
// in .h file:
ofNode a,b,c;
float aEnergy;
float bEnergy;
float aEnergySmth;
float bEnergySmth;
float time;
ofPolyline nodeLine;
@ofZach
ofZach / gist:8816529
Last active August 29, 2015 13:56
ruby to make markdown links a href target blank links. sort of doesn't work with link URLs that have () in them -- like some wikipedia urls that disambiguate. also seems to convert images inadvertently as well as markdown links since they have a similar-ish format.
File.open('test.txt', 'r+') do |f|
out = ""
f.each do |line|
out << line.gsub(/\[([^\]]+)\]\(([^)]+)\)/, '<a target="_blank" href="\2">\1</a>')
end
f.pos = 0
f.print out
f.truncate(f.pos)
end