Skip to content

Instantly share code, notes, and snippets.

dest = []
locs = []
def process(line):
global dest
inp_split = line.split(':')
dep = inp_split[0]
conn = inp_split[1]
dist = int(inp_split[2])
@trentbrooks
trentbrooks / gist:d6c63496b28b2ce1b11b
Created November 13, 2015 03:30
OF/Poco directory watcher minimal example
// ofApp.h
#include "Poco/DirectoryWatcher.h"
#include "Poco/Delegate.h"
Poco::DirectoryWatcher* watcher;
void onFileAdded(const Poco::DirectoryWatcher::DirectoryEvent& addEvent);
void onFileChanged(const Poco::DirectoryWatcher::DirectoryEvent& changeEvent);
// ofApp.cpp
watcher = new Poco::DirectoryWatcher(ofToDataPath("img"));
@trentbrooks
trentbrooks / gist:a99230cf4637b86cce98
Last active November 13, 2015 02:42
C++11 lambda + std::function callbacks. eg. sequence of animations
// https://msdn.microsoft.com/en-us/library/dd293599.aspx & https://msdn.microsoft.com/en-us/library/dd293608.aspx
// sequence of tweens/animations called sequentially
tween.go(&width, 200, 1.0).onDone([&]() {
tween.go(&height, 100, 1.0).onDone([&]() {
tween.go(&target, ofVec3f(100,200), 1.0).onDone([&]() {
tween.go(&target, ofVec3f(800,400), 3.0).onDone([&]() {
tween.go(&rotation, 900, 1.0).onDone([&]() {
tween.go(&target, ofVec3f(ofGetWidth()/2, ofGetHeight()/2), 2.0);
});
});
@trentbrooks
trentbrooks / gist:85339d9d9b9a05f145ee
Last active October 16, 2015 03:15
Arduino Yun setup
SETUP (FIRST TIME)
1. Connect laptop to WiFi network called ArduinoYun-XXXXXXXXXXXX
2. Goto http://arduino.local or 192.168.240.1
3. Password is "arduino" or my password
4. Click configure
5. Give it unique name eg. "ArduinoYunTB" and password
6. Enter Wifi details we want Arduino to use eg. "LWG"
7. Click restart
SETUP (NOT FIRST TIME)
@trentbrooks
trentbrooks / gist:523b60764bc5b6cfada7
Last active October 2, 2015 03:18
Instructions for George
// 1. go into github repo via terminal
cd brighthearts-beta
// 2. check which branch your on - eg. HPV-Vaccine
git branch
// 3. delete all your local changes, and reset to what is on github
git reset --hard HEAD
// 4. pull down the latest changes
@trentbrooks
trentbrooks / gist:f8a0bd42334c12890083
Created September 21, 2015 06:59
ofAVFoundationVideoPlayer previousFrame() replacement
#ifdef __OBJC__
ofAVFoundationVideoPlayer* p = (ofAVFoundationVideoPlayer*)videoPtr->getAVFoundationVideoPlayer();
if(p != nullptr) {
double timeSec = CMTimeGetSeconds([p getCurrentTime]) - (1.0/[p getFrameRate]);
CMTime time = CMTimeMakeWithSeconds(timeSec, NSEC_PER_SEC);
[p seekToTime:time withTolerance:kCMTimeZero];
}
#endif
git clone http://github.com/trentbrooks/someproject
git bundle create someproject.bundle --all
- need to zip assets if not in archive
- if OF, might need details about which version and addons
@trentbrooks
trentbrooks / gist:614b5afe68e620a7dd7b
Created July 9, 2015 04:53
Heroku site (Rockhampton)
cd rockhamptongallery
heroku git:remote -a rockhampton-web
//should list two remotes, origin/github and heroku
git remote -v
middleman build
git add -f app/build # -f because we are ignoring git dir
git push heroku develop:master # heroku only works with master branch, so push our develop onto their master.
@trentbrooks
trentbrooks / gist:e41a592ea87f2815d2c4
Last active August 29, 2015 14:22
threading/mutex objc problem
- (void)updateData:(NSTimer*)timer {
// if already getting data do nothing
if(!self.isFetchDataComplete) {
NSLog(@"Do not get data - flag is OFF...");
return;
}
// reset the flag
self.isFetchDataComplete = FALSE;
@trentbrooks
trentbrooks / gist:452dfc8dfaa95892aedf
Created February 26, 2015 05:24
Raspberry Pi2 + openframeworks setup
// 1 update gcc to 4.8
sudo apt-get install g++-4.8
cd /usr/bin
sudo rm g++
sudo ln -s g++-4.8 g++
// 1 download OF (from github or stable linuxarm7l release with https://github.com/openframeworks/openFrameworks/blob/master/libs/openFrameworksCompiled/project/linuxarmv7l/config.linuxarmv7l.rpi2.mk)
cd ~
curl -o https://github.com/openframeworks/openFrameworks/archive/master.zip
curl -o http://www.openframeworks.cc/versions/v0.8.4/of_v0.8.4_linuxarmv7l_release.tar.gz