This is a very trivial demo that shows the basic usage of cgo.
Build and Run:
$ go build main.go
$ ./main
hello, cgo
3
| import time | |
| import random | |
| import leveldb | |
| Data1 = ' ' * 100 | |
| Data2 = ' ' * 10000 | |
| def test_write(db, data, count): | |
| size = 0 | |
| for i in range(count): |
| 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 |
| -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]), |
| // Test the effect of sync.Once. | |
| // See another example: http://golang.org/pkg/sync/#Once | |
| package main | |
| import ( | |
| "fmt" | |
| "sync" | |
| "runtime" | |
| ) |
This is a very trivial demo that shows the basic usage of cgo.
Build and Run:
$ go build main.go
$ ./main
hello, cgo
3
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
| package main | |
| import ( | |
| "io" | |
| "os" | |
| ) | |
| type XReader struct { | |
| io.Reader | |
| Cipher []byte |
| // 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); |
| 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") |