This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#-*-coding:utf-8-*- | |
""" | |
Use decorate to maintain a memory cache. | |
""" | |
def cache_c(fn): | |
cache = {} | |
miss = None | |
def wrapper(*args, **kwargs): | |
result = cache.get(args, miss) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#include<string.h> | |
#include<stdlib.h> | |
char* strfromlonglong(long long value){ | |
char buf[32], *p; | |
unsigned long long v; | |
v = (value < 0) ? -value: value; | |
p = buf + 31; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* This is a really minimal testing framework for C. | |
* | |
* Example: | |
* | |
* test_cond("Check if 1 == 1", 1==1) | |
* test_cond("Check if 5 > 10", 5 > 10) | |
* test_report() | |
*/ | |
#include<stdio.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
#-*-coding:utf-8-*- | |
""" | |
A decorator used to calculate the cost time of functions. | |
""" | |
import time | |
from functools import wraps |