Skip to content

Instantly share code, notes, and snippets.

@roxlu
roxlu / Mist.cpp
Last active January 2, 2016 13:09
Projective texture mapping; see http://www.reedbeta.com/blog/2012/05/26/quadrilateral-interpolation-part-1/ for more information
#include <swnt/Effects.h>
#include <swnt/effects/Mist.h>
template<class T>
inline bool intersect(const Vec3<T>& p0, const Vec3<T>& p1, const Vec3<T>& p2, const Vec3<T>& p3, Vec3<T>& result) {
Vec3<T> s1 = p1 - p0;
Vec3<T> s2 = p3 - p2;
float s, t;
s = (-s1.y * (p0.x - p2.x) + s1.x * (p0.y - p2.y)) / (-s2.x * s1.y + s1.x * s2.y);
@roxlu
roxlu / Weather.cpp
Created January 6, 2014 11:11
CURL retrieve HTML into string
size_t weather_write_data(void* ptr, size_t size, size_t nmemb, void* str) {
std::string* s = static_cast<std::string*>(str);
std::copy((char*)ptr, (char*)ptr + (size + nmemb), std::back_inserter(*s));
return size * nmemb;
}
std::string weather_download_yahoo_rss() {
std::string result;
std::string url = "http://weather.yahooapis.com/forecastrss?w=10242&u=c"; // w=10242 is Aberaron
@roxlu
roxlu / compile.sh
Created January 5, 2014 12:39
NGINX + PHP + MySQL
#!/bin/sh
# Compiling nginx + php + mysql on Mac OSX 10.9
# ---------------------------------------------
#
#
# CONFIGURE
# ---------------
# 1) Edit `conf/nginx.conf` and add this to the between the server { ... } config.
# NOTE: the current config you only need to uncomment the example that looks like this,
@roxlu
roxlu / main.cpp
Created January 4, 2014 20:54
Reading up on numerical methods and c++
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
void triangulate(float* a, float* b, int n);
void backsubst(float* a, float* b, int n);
void print(float* a, int rows, int cols);
int main() {
printf("\nGauss Seidel Elimination - Ch. 10 - Direct Solution of Linear Equation, page 204, An Introduction To Numerical Methods in C++\n\n");
@roxlu
roxlu / compile.sh
Created January 4, 2014 17:01
NGINX + PHP + configuration
#!/bin/sh
# Compiling nginx + php + mysql on Mac OSX 10.9
# ---------------------------------------------
#
#
# CONFIGURE
# ---------------
# 1) Edit `conf/nginx.conf` and add this to the between the server { ... } config.
# NOTE: the current config you only need to uncomment the example that looks like this,
@roxlu
roxlu / compile.sh
Created January 4, 2014 15:24
NGINX + PHP on Mac 10.9 (fresh install)
#!/bin/sh
# Compiling nginx + php + mysql on Mac OSX 10.9
# ---------------------------------------------
#
#
# Configure nginx
# ---------------
# Add this to the between the server { ... } config:
#
@roxlu
roxlu / compile.sh
Created January 3, 2014 22:40
NGINX + PHP on Mac 10.9 - WIP
#!/bin/sh
# Compiling nginx + php + mysql on Mac OSX 10.9
# ---------------------------------------------
#
#
# Configure nginx
# ---------------
# Add this to the between the server { ... } config:
#
@roxlu
roxlu / compile.sh
Created January 3, 2014 21:49
NGINX + PHP on Mac 10.9, WIP
#!/bin/sh
# Compiling nginx + php + mysql on Mac OSX 10.9
# ---------------------------------------------
#
#
# Configure nginx
# ---------------
# Add this to the between the server { ... } config:
#
@roxlu
roxlu / GUI.cpp
Created December 29, 2013 14:19
Minimal AntTweakBar integration with GLFW
#include <assert.h>
#include <GLFW/glfw3.h>
#include <swnt/GUI.h>
GUI::GUI()
:win_w(0)
,win_h(0)
{
}
@roxlu
roxlu / HeightField.cpp
Created December 23, 2013 22:55
Water simulation v0.0.0.16
#include "HeightField.h"
HeightField::HeightField()
:vert(0)
,frag(0)
,prog(0)
,vao(0)
,vbo_els(0)
,vbo(0)
,fbo(0)