Skip to content

Instantly share code, notes, and snippets.

@buptpatriot
buptpatriot / pairObject.c
Last active January 1, 2016 07:49
Pair object just like that in lisp.
#include <stdio.h>
#include <stdlib.h>
typedef enum {
OBJ_INT,
OBJ_PAIR
} ObjectType;
typedef struct sObject {
ObjectType type;
@buptpatriot
buptpatriot / TestSynchronization.java
Created January 3, 2014 09:35
Test Java Synchronization.
import java.lang.Thread;
import java.util.concurrent.atomic.AtomicInteger;
public class TestSynchronization {
public static void main(String[] args) {
Task task = new Task();
for (int i = 0; i < 100; i++) {
new Thread(task).start();
}
@buptpatriot
buptpatriot / the-tank-war.rkt
Last active January 2, 2016 07:38
A racket game. The tank war.
#lang racket
(require 2htdp/image)
(require (except-in racket/gui/base make-pen make-color))
(require (only-in mrlib/image-core render-image))
(define SCORE 0)
(define GAMEOVER #f)
(define TIMER-INTERVAL 50)
@buptpatriot
buptpatriot / josephus.scm
Last active January 3, 2016 00:19
约瑟夫问题
(define (f n k)
(define (f-iter result counter)
(if (> counter n)
result
(f-iter (add1 (modulo (+ result k -1) counter))
(add1 counter))))
(f-iter 1 2))
(define (advanced-f prisoners k)
(define (new-list lst p)
@buptpatriot
buptpatriot / SimpleHTTPServerWithUpload.py
Created February 6, 2018 08:18 — forked from UniIsland/SimpleHTTPServerWithUpload.py
Simple Python Http Server with Upload
#!/usr/bin/env python
"""Simple HTTP Server With Upload.
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.
"""