Skip to content

Instantly share code, notes, and snippets.

@roxlu
roxlu / Parsing_Stun.txt
Created July 31, 2014 17:49
Some test data that can be used when parsing stun messages (WebRTC/ICE/STUN)
Below is a dump of a STUN message that can be used to validate your
STUN message integrity check. The password that is used to encrypt
the Message-Integrity is: "Q9wQj99nsQzldVI5ZuGXbEWRK5RhRXdC" (without quotes)
/* Raw STUN message as received from Chrome */
-----------
00 01 00 58
21 12 A4 42
48 75 38 77
@roxlu
roxlu / Reader.cpp
Created July 31, 2014 13:43
Testing the integrity of stun message. See http://tools.ietf.org/html/rfc5389#section-15.4 and http://tools.ietf.org/html/rfc5769#section-2.2 (validates correctly, code is still work in progress).
#include <stun/Reader.h>
#include <openssl/engine.h>
#include <openssl/hmac.h>
#include <openssl/evp.h>
namespace stun {
/* --------------------------------------------------------------------- */
@roxlu
roxlu / test_ssl_fingerprint.cpp
Created July 29, 2014 11:05
Create fingerprint / self signed certficate
/*
test_ssl_fingerprint
--------------------
This code shows the following:
- use openssl to generate a private key that can be used to encrypt application data
- extract the fingerprint from the key
@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.
#include "krx_dtls.h"
int krx_dtls_init() {
SSL_library_init();
SSL_load_error_strings();
ERR_load_BIO_strings();
OpenSSL_add_all_algorithms();
return 0;
}
@roxlu
roxlu / ssl_test2.c
Created March 28, 2014 15:12
Compact example of how to use openSSL with self signed (no password) keys/certificates, DTLS and memory BIOs
/*
Create server/client self-signed certificate/key (self signed, DONT ADD PASSWORD)
openssl req -x509 -newkey rsa:2048 -days 3650 -nodes -keyout client-key.pem -out client-cert.pem
openssl req -x509 -newkey rsa:2048 -days 3650 -nodes -keyout server-key.pem -out server-cert.pem
*/
#include <stdio.h>
@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 / main.cpp
Created February 22, 2014 15:36
LibHARU + PDF
/*
PDF
----
Very basic application which generates a poster from a
set of images. This application was created because I wanted
to have a poster from my instagram images. It uses a couple of
php files that login to my instagram account and generates a
shell script which downloads them to a directory.
uniform sampler2D u_scene_tex;
in vec2 v_tex;
out vec4 fragcolor;
void main() {
fragcolor = texture(u_scene_tex, v_tex) * 0.186315;
fragcolor += texture(u_scene_tex, v_tex + vec2(0.0, 0.00208333)) * 0.168585;
fragcolor += texture(u_scene_tex, v_tex - vec2(0.0, 0.00208333)) * 0.168585;
fragcolor += texture(u_scene_tex, v_tex + vec2(0.0, 0.00416667)) * 0.124891;
fragcolor += texture(u_scene_tex, v_tex - vec2(0.0, 0.00416667)) * 0.124891;
fragcolor += texture(u_scene_tex, v_tex + vec2(0.0, 0.00625)) * 0.0757501;