Skip to content

Instantly share code, notes, and snippets.

#include "hg_adv.h"
#define ADV_DEBUG 0
VgHashTable write_buffers_8;
VgHashTable write_buffers_16;
VgHashTable write_buffers_32;
VgHashTable write_buffers_64;
typedef struct _AddrWBNode {
@hoheinzollern
hoheinzollern / zipper.scala
Created June 1, 2011 01:25
Zipper scala implementation
sealed abstract class Tree[A]
case class Item[A] (item: A) extends Tree[A]
case class Section[A] (s: List[Tree[A]]) extends Tree[A]
sealed abstract class Path[A]
case class Top[A] extends Path[A]
case class Node[A] (l: List[Tree[A]], p: Path[A], r: List[Tree[A]]) extends Path[A]
case class Location[A] (t: Tree[A], p: Path[A])
@hoheinzollern
hoheinzollern / sample_contracts.py
Created November 13, 2010 02:16
This is what the result should be
@invariant(lambda self: self.value >= 0)
class PositiveInt(object):
@post(lambda self: self.num_changes == 0 and self.value == 0)
def __init__(self):
self.value = 0
self.num_changes = 0
@post(lambda new, old: new.num_changes == old.num_changes + 1)
def add(self, x):
self.value += x
using System;
using System.Diagnostics.Contracts;
namespace Stack
{
public class StackEmpty : Exception { }
public class Stack
{
private object[] arr;
using System;
namespace Stack
{
public class StackEmpty : Exception { }
public class Stack
{
private object[] arr;
/**
* Builds a new sudoku instance given a difficulty level
*
* @param level describes the difficulty level of the generated game
* - 1 normal
* - 2 medium
* - 3 hard
*/
def makeSudoku(level: Int): Sudoku = {
var board = new Array[Array[Int]](9, 9)
void DWT::transform1d(float *src, int length, int step)
{
float *tmp = new float[length];
float W = 1/sqrt(2.0f);
for (int len = length/2; len >= PREVIEW; len /= 2) {
for (int i = 0; i < len; i++) {
float c = src[i*2*step];
float w = src[(i*2+1)*step];
tmp[i] = (c+w)*W;
tmp[i+len] = (c-w)*W;