Skip to content

Instantly share code, notes, and snippets.

struct Foo {
virtual int bar() = 0;
};
struct A : public Foo {
int bar() { return 1; }
};
struct B : public Foo {
int bar() { return 2; }
#include "material.h"
#include "opengl.h"
uint32_t VertexAttrib::convertType(type_t type)
{
switch (type) {
case FLOAT:
return GL_FLOAT;
case SHORT:
return GL_SHORT;
@szastupov
szastupov / gist:985035
Created May 22, 2011 00:39
audio experiments
#include <cassert>
#include <cstdlib>
#include <vector>
#include <boost/intrusive_ptr.hpp>
#include <AL/al.h>
#include <AL/alc.h>
#include <vorbis/vorbisfile.h>
#include "bicycles/sp.h"
template <class T>
class RefCounted {
public:
void incRef()
{
m_refcount++;
}
void decRef()
{
ac_power() {
echo 0 > /sys/devices/system/cpu/sched_mc_power_savings
echo 0 > /proc/sys/vm/laptop_mode
hdparm -B 128 -S 240 /dev/sda
echo max_performance > /sys/class/scsi_host/host0/link_power_management_policy
echo max_performance > /sys/class/scsi_host/host1/link_power_management_policy
echo 1 > /sys/module/snd_hda_intel/parameters/power_save
}
battery_power() {
/*
* This function ensures that there is required amount of data in the
* ndr stream. When there isn't, it tries to read as much data as
* possible in order to reduce the number of recv() calls. It grows
* the stream if necessary. It relies on pdu_size so be careful.
*/
static int
nds_fetch(int sock, ndr_stream_t *nds, size_t need)
{
ssize_t rc;
#include <stdio.h>
#include <sys/stat.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int main()
{
struct flock fl;
var zmq = require('../../')
, sock = zmq.socket('push');
sock.bindSync('tcp://127.0.0.1:5556');
setInterval(function(){
console.log('sending pub');
sock.send('10001 some pub');
}, 500);
from nodebox.graphics import *
from random import randint, choice, uniform
SIZE = (1280, 720)
class Circle(object):
def __init__(self):
self.x = randint(0, SIZE[0])
self.y = randint(0, SIZE[1])
self.color = [255, 204, 34, randint(20, 150)]
from __future__ import division, print_function
from nodebox.graphics import *
from random import randint, getrandbits, uniform
from collections import deque
SIZE = (1280, 800)
LAYERS = 20
STARS_COLOR = Color(189, 155, 0, 255, base=255)
WINDOWS_COLOR = Color(189, 155, 0, 255, base=255)