Skip to content

Instantly share code, notes, and snippets.

@roxlu
roxlu / keep_running.scpt
Created April 29, 2012 09:36
Keep application running, auto restart on crash
on appIsRunning(appName)
tell application "System Events" to (name of processes) contains appName
end appIsRunning
on makeActive(appName)
tell application appName
activate
end tell
end makeActive
@roxlu
roxlu / video.sh
Created May 7, 2012 09:22
Create high quality video with ffmpeg
ffmpeg -i 07.05.09_%04d.png -r 60 -s 640x480 -vcodec libx264 -vpre hq -b 2000k movie3.mov
@roxlu
roxlu / solver.h
Created May 9, 2012 21:28
Jos Stams fluid solver
#ifndef SOLVERH
#define SOLVERH
#define IX(i,j) ((i)+(N+2)*(j))
#define SWAP(x0,x) {float * tmp=x0;x0=x;x=tmp;}
#define FOR_EACH_CELL for ( i=1 ; i<=N ; i++ ) { for ( j=1 ; j<=N ; j++ ) {
#define END_FOR }}
static void add_source ( int N, float * x, float * s, float dt )
{
int i, size=(N+2)*(N+2);
@roxlu
roxlu / testApp.cpp
Created May 21, 2012 19:37
Gradient field visualization (partial derivative)
#include "testApp.h"
testApp::testApp() {
}
void testApp::setup(){
ofBackground(22,33,44);
ofSetFrameRate(60);
grad_w = 50;
@roxlu
roxlu / testApp.cpp
Created May 22, 2012 19:49
1D linear convection
#include "testApp.h"
// generate random data for "u"
void testApp::setup(){
ofBackground(22,33,44);
float dt = 0.1;
for(int i = 0; i < N; ++i) {
u[i] = ofNoise(dt*i);
}
}
@roxlu
roxlu / testApp.cpp
Created May 23, 2012 19:07
1D convection
#include "testApp.h"
void testApp::setup(){
ofSetFrameRate(60);
ofBackground(22,33,44);
gif.setup(ofGetWidth(), ofGetHeight());
record = false;
// setup some initial data.
@roxlu
roxlu / testApp.cpp
Created May 24, 2012 07:15
Basic bare bones openGL (shader,vbo,vao) with openFrameworks
#include "testApp.h"
//--------------------------------------------------------------
void testApp::setup(){
ofSetFrameRate(60);
ofBackground(22,33,44);
// create shader program
shader.setupShaderFromSource(GL_VERTEX_SHADER, VS);
@roxlu
roxlu / testApp.cpp
Created May 24, 2012 07:36
Basic bare bones openGL with openFrameworks (VBO, VAO, SHADER and texture(s))
#include "testApp.h"
//--------------------------------------------------------------
void testApp::setup(){
ofEnableNormalizedTexCoords();
ofDisableArbTex();
ofSetFrameRate(60);
ofBackground(22,33,44);
// Shader + VAO/VBO
@roxlu
roxlu / OMesh.cpp
Created May 26, 2012 16:10
OpenMesh
#include "OMesh.h"
OMesh::OMesh() {
}
OMesh::~OMesh() {
}
bool OMesh::save(const string& filepath) {
@roxlu
roxlu / ParallelTransportFrames.cpp
Created June 2, 2012 19:03
Generalizing Parallel Transport Frames
#include "ParallelTransportFrames.h"
#include "OpenGL.h"
void ParallelTransportFrames::addPoint(const Vec3& p) {
points.push_back(p);
}
void ParallelTransportFrames::create(Vec3 V) {
Vec3 V_prev = V;
for(int i = 0; i < points.size()-2; ++i) {