Skip to content

Instantly share code, notes, and snippets.

@physacco
physacco / test_leveldb.py
Created March 14, 2013 08:34
Test the performance of sqlite3 and leveldb by writing many key-value pairs.
import time
import random
import leveldb
Data1 = ' ' * 100
Data2 = ' ' * 10000
def test_write(db, data, count):
size = 0
for i in range(count):
@physacco
physacco / install-python-2.7.3.sh
Created March 15, 2013 02:29
Install Python-2.7.3.
cd /tmp
wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz
tar xzf Python-2.7.3.tgz
cd Python-2.7.3
./configure --prefix=/opt/python/2.7.3
make && make install
export PATH=/opt/python/2.7.3/bin:$PATH
cd /tmp
@physacco
physacco / ehttpd.erl
Created March 15, 2013 17:16
This is a hello-world HTTP server in Erlang. It is used to test the performance of servers.
-module(ehttpd).
-compile(export_all).
start() ->
start(8888).
start(Port) ->
N = erlang:system_info(schedulers),
listen(Port, N),
io:format("ehttpd ready with ~b schedulers on port ~b~n", [N, Port]),
@physacco
physacco / test_once.go
Created March 18, 2013 03:02
Test the effect of sync.Once.
// Test the effect of sync.Once.
// See another example: http://golang.org/pkg/sync/#Once
package main
import (
"fmt"
"sync"
"runtime"
)
@physacco
physacco / README.md
Last active December 15, 2015 04:38
This is a very trivial demo that shows the basic usage of cgo.

This is a very trivial demo that shows the basic usage of cgo.

Build and Run:

$ go build main.go
$ ./main
hello, cgo
3
@physacco
physacco / README.md
Created March 23, 2013 12:01
This demo implements a simple key-value storage server based on GAE DataStore.

Start dev server

~/src/google/appengine/dev_appserver.py .

Test from client

$ curl http://localhost:8080/cache
$ curl -X PUT -d 'this is foo' http://localhost:8080/cache/foo
$ curl http://localhost:8080/cache/foo

this is foo

@physacco
physacco / xreader_and_xwriter.go
Last active December 15, 2015 08:39
This demo shows how to wrap io.Reader or io.Writer into a stream cipher.
package main
import (
"io"
"os"
)
type XReader struct {
io.Reader
Cipher []byte
@physacco
physacco / test_sjcl.js
Created March 25, 2013 13:36
Basic usage example of SJCL.
// Basic usage example of SJCL.
// Tested on firefox 20.0 and nodejs 0.8.
// Refer to: http://crypto.stanford.edu/sjcl/
var sjcl = require("./sjcl");
var plaintext = "大丈夫だ、問題ない";
var encrypted = sjcl.encrypt("password", plaintext);
console.log(encrypted);
var decrypted = sjcl.decrypt("password", encrypted);
console.log(plaintext == decrypted);
@physacco
physacco / dec.py
Created April 4, 2013 16:41
Decryption program for the game Twisty Destiny.
import os, sys
import StringIO
import time
import pdb
### init some paths
ScriptPath = os.path.abspath(__file__)
ScriptDir = os.path.dirname(ScriptPath)
InputDir = os.path.join(ScriptDir, "data")
OutputDir = os.path.join(ScriptDir, "decrypted")
@physacco
physacco / firefox-proxy-config.md
Last active December 2, 2023 18:40
firefox配置socks5代理的方法

配置socks5代理的方法

打开 about:config, 修改下面这些项目:

network.proxy.type                       1
network.proxy.socks                      127.0.0.1
network.proxy.socks_port                 1080
network.proxy.socks_remote_dns           true
network.proxy.socks_version              5

network.proxy.no_proxies_on localhost, 127.0.0.1