Skip to content

Instantly share code, notes, and snippets.

@roxlu
roxlu / test_vorbis.c
Last active August 29, 2015 14:00
Decoding vorbis flow (w/o cleanup yet).
/*
test_vorbis
------------
See online version: https://gist.github.com/roxlu/af1ffc1290b9dc37b5b9
Example code which decodes a .ogg file that contains vorbis and/or
some other stream, e.g. theora. We ignore all non-vorbis streams and
simply flush the packets.
@roxlu
roxlu / H264_Decoder.cpp
Created March 3, 2014 16:57
LibAV parser and decoder example with openGL (YUV420 -> RGB shader).
#include "H264_Decoder.h"
H264_Decoder::H264_Decoder(h264_decoder_callback frameCallback, void* user)
:codec(NULL)
,codec_context(NULL)
,parser(NULL)
,fp(NULL)
,frame(0)
,cb_frame(frameCallback)
,cb_user(user)
@roxlu
roxlu / README.md
Created February 23, 2014 13:57 — forked from mbostock/.block

Mitchell’s best-candidate algorithm generates a new random sample by creating k candidate samples and picking the best of k. Here the “best” sample is defined as the sample that is farthest away from previous samples. The algorithm approximates Poisson-disc sampling, producing a much more natural appearance (better blue noise spectral characteristics) than uniform random sampling.

See also the white-on-black and Voronoi variations of this example.

@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 / 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 / README.txt
Created December 11, 2013 14:18
Compile Apache, PHP and MySQL on Mac
COMPILE APACHE / PHP / MYSQL
===========================
- First compile/install apache, see compile_apache.sh for more info
- Then compile/install php/mysql, see compile_php.sh for more info
- Tested on Mac OSX 10.8, 2013.01.15