Skip to content

Instantly share code, notes, and snippets.

#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;
/*
* 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;
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() {
template <class T>
class RefCounted {
public:
void incRef()
{
m_refcount++;
}
void decRef()
{
@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"
#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;
struct Foo {
virtual int bar() = 0;
};
struct A : public Foo {
int bar() { return 1; }
};
struct B : public Foo {
int bar() { return 2; }
open OUnit
class printable_point x_init =
object (s)
val mutable x = x_init
method get_x = x
method move d = x <- x + d
method print = string_of_int s#get_x
end
template <class T>
int ffs(T i)
{
T step = sizeof(i)*8 >> 1;
int n = 1;
for (; step > 1; step >>= 1) {
T shift = ((T)1 << step)-1;
if (!(i & shift)) {
n += step;
{-# LANGUAGE OverloadedStrings #-}
import System.IO
import Network.Curl
import Network.URI
import Text.HTML.TagSoup
import Text.Printf
import Data.Graph.Inductive
import qualified Data.Map as M
import qualified Data.Set as S
import qualified Data.ByteString.Lazy as BS