Skip to content

Instantly share code, notes, and snippets.

@engie
engie / gist:778062
Created January 13, 2011 15:39
C++ doesn't support template specialisation based on typedefs, so wrap a float in a struct.
#include <iostream>
using namespace std;
struct Float
{
Float( float val ) : m_val( val ) {}
operator float() { return m_val; }
float m_val;
@engie
engie / play_vid.py
Created December 29, 2010 13:22
Script to send gstreamer data to the acab video wall
import sys
import threading
import gobject
gobject.threads_init()
import gst
import struct
import Queue
RGB_UNPACKER = struct.Struct("BBBB")
COLS = 16
@engie
engie / Singleton.py
Created October 15, 2010 09:46
Reminding myself of the order of static initialisation.
#include <stdio.h>
class C
{
public:
C()
{
printf("Created C\n");
}
};
import struct
import sys
class NamedStruct( struct.Struct ):
def __init__(self, *contents):
"""
Construct with ("Format", "Name"), tuples as arguments.
"""
self.names, format = zip(*contents)
#Flatten format into a string
template<typename Signature>
class callback
{
};
template<typename R , typename ARG_TYPE0>
class callback<R( ARG_TYPE0)>
{
public:
callback() {}