Skip to content

Instantly share code, notes, and snippets.

#include <string.h>
#include <stdlib.h>
#define SHA1_SHIFT(word, bit) \
(((word) << (bit)) | ((word) >> (32 - (bit))))
#define F(t, b, c, d, x) \
do { \
if(0 <= t && t <= 19) \
x = (b & c) | ((~b) & d); \
@dchiji
dchiji / threadpool.c
Created December 23, 2009 10:40
thread pool
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <unistd.h>
typedef struct tid {
int n;
pthread_t *thread;
} tid_t;
@dchiji
dchiji / Makefile
Created December 2, 2009 10:58
KVS
.SUFFIXES: .erl .beam .yrl
.erl.beam:
erlc -W +'{parse_transform, smart_exceptions}' $<
.yrl.erl:
erlc -W +'{parse_transform, smart_exceptions}' $<
ERL = erl
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
#include <iostream>
#include <map>
#define LEVEL 128
/*
* <Skip List>
#include <pthread.h>
#include <stdio.h>
#include <time.h>
void *func(void *param_p)
{
int *p = (int *)param_p;
printf("## start: %u\n", (unsigned int)pthread_self());
for(int i = 0; i < 100000; i++) {
// name: curve.cpp
// compile: $ g++ curve.cpp `pkg-config gtkmm-2.4 --cflags --libs`
#include <cairomm/context.h>
#include <gtkmm/drawingarea.h>
#include <gtkmm/main.h>
#include <gtkmm/window.h>
#include <gtkmm.h>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#define MAX 100000
int main()
{
int lis[MAX];
int n = 0;
int j = 0;
-module(euclidean).
-export([euclidean/2]).
euclidean(M, 0) -> M;
euclidean(M, N) when M rem N == 0 -> N;
euclidean(M, N) -> euclidean(N, M rem N).
-module(heron).
-export([heron/3]).
heron(A, B, C) ->
S = (A + B + C) / 2,
math:sqrt(S * (S - A) * (S - B) * (S - C)).
#include <stdarg.h>
void cps(int a, int b, ...)
{
void *p;
void *m;
va_list ap;
va_start(ap, b);
p = va_arg(ap, void *);