This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding=utf8 | |
# Copyright (C) 2011 Saúl Ibarra Corretgé <[email protected]> | |
# | |
import hashlib | |
import os | |
import re | |
import socket | |
import struct |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding=utf8 | |
# Copyright (C) 2011 Saúl Ibarra Corretgé <[email protected]> | |
# | |
# Some inspiration taken from: http://www.morethantechnical.com/2009/03/05/qt-opencv-combined-for-face-detecting-qwidgets/ | |
import cv | |
import sys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In [1]: class Foo(object): | |
...: def __init__(self, bar): | |
...: self.bar = bar | |
...: def __eq__(self, other): | |
...: return self.bar == other.bar | |
...: | |
...: | |
In [2]: Foo('baz') == Foo('baz') | |
Out[2]: True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "Python.h" | |
#include "structmember.h" | |
/* Type definition */ | |
typedef struct { | |
PyObject_HEAD | |
PyObject *bar; | |
PyObject *baz; | |
} Foo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://mail.python.org/pipermail/pythonmac-sig/2009-September/021649.html | |
# On Mac OSX Python may run in 32 or 64 bit mode so platform.architecture() is not reliable. | |
# Example: use 32bit Python: export VERSIONER_PYTHON_PREFER_32_BIT=yes | |
def arch(): | |
import ctypes | |
return {4: "i386", 8: "x86_64"}[ctypes.sizeof(ctypes.c_size_t)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding=utf-8 | |
# Copyright (C) 2011 Saúl Ibarra Corretgé <[email protected]> | |
# | |
# Based on callcontrol/opensips.py, Copyright (C) 2006-2011 AG Projects. | |
# OpenSIPS configuration example: | |
# loadmodule "mi_datagram.so" | |
# modparam("mi_datagram", "socket_name", "/var/run/opensips/socket") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################ | |
# host/port binding for http server | |
HOST = '0.0.0.0' | |
PORT = 5000 | |
############################################ | |
from flask import Flask, render_template | |
import plivohelper | |
import os |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import threading | |
class ThreadLocalMeta(type): | |
"""Metaclass to keep a single class instance per thread""" | |
_local = threading.local() | |
def __call__(cls, *args, **kwargs): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import zmq | |
from zmq.eventloop import ioloop, zmqstream | |
ioloop.install() | |
import tornado | |
import tornado.web | |
import tornadio | |
import tornadio.router |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#define ASSERT(x) \ | |
do { \ | |
if (!(x)) { \ | |
fprintf (stderr, "%s:%u: %s: Assertion `" #x "' failed.\n", \ | |
__FILE__, __LINE__, __func__); \ |