Skip to content

Instantly share code, notes, and snippets.

View Arachnid's full-sized avatar

Nick Johnson Arachnid

View GitHub Profile
@Arachnid
Arachnid / eepy.c
Created August 3, 2009 20:26
Simple fiber library. Compile with: gcc -o eepy.o -g -c eepy.c; gcc -o test -lpthread -g test.c eepy.o
#include <assert.h>
#include <pthread.h>
#include <setjmp.h>
#include <signal.h>
#include <stdlib.h>
#include "eepy.h"
// Information about an active eepy process
typedef struct eepy_process {
jmp_buf context;
A unit test helper library for App Engine.
Note that this is currently COMPLETELY UNTESTED. Consider it demo code only.
This library aims to make it easier to unit-test app engine apps and libraries
by handling the creation and registration of service stubs and so forth for you.
It also provides a custom implementation of the Capability service that allows
you to specify what capabilities you want it to report as disabled, and it wraps
all stubs in a wrapper that will throw a CapabilityDisabledError if you attempt
to use a disabled service or method.
"""Implements a distributed transaction for transfers of funds.
Invariant: The sum of all accounts, plus all partially applied transfers, is 0.
Steps:
1) In a transaction, an Account is debited, and a Transaction object is created, with the
appropriate amount and target, but no other transaction.
2) In a transaction, the target Account is credited, and a Transaction object is created with
a predefined key name, and the other transaction referencing the one created in step 1.
3) The original Transaction object created in step 1 is updated to reference the transaction
<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs title="Links from appengine.reddit.com" height="300">
<Require feature="dynamic-height"/>
</ModulePrefs>
<Content type="html"><![CDATA[
<style type="text/css">
.rembeddit {
margin-bottom: 10px;
}
package main
import "fmt"
type state struct {
board [7][6]int;
heights [7]int;
}
type move struct {
include $(GOROOT)/src/Make.$(GOARCH)
TARG=kademlia
GOFILES=\
nodeid.go\
routingtable.go\
contact.go\
kademlia.go
include $(GOROOT)/src/Make.pkg
#!/usr/bin/python
import base64
import logging
import Queue
import sys
import threading
import time
import urllib2
package main
import (
"flag";
"log";
"os";
"strings";
"time";
)
from google.appengine.ext import db
class EntityCache(object):
"""Caches fetched entities so subsequent fetches return the same instance.
Usage:
cache = EntityCache()
e1, e2 = cache.get([k1, k2])
e3, e4 = cache.get([k2, k3])
assert e2 == e3
import logging
import time
from google.appengine.api import mail
from google.appengine.ext import db
from google.appengine.ext.deferred import defer
from google.appengine.runtime import apiproxy_errors
class BulkUpdater(object):
"""A bulk updater for datastore entities.