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
BenchmarkStringIndex1First 100000000 20.0 ns/op | |
BenchmarkStringIndex2First 100000000 19.8 ns/op | |
BenchmarkStringIndex1Last 50000000 59.4 ns/op | |
BenchmarkStringIndex2Last 50000000 45.7 ns/op | |
ok indexbench 9.413s |
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
$ pacaur -S --needed bup-git | |
:: Package(s) bup-git not found in repositories, trying AUR... | |
:: pylibacl is available in community | |
:: python2-pyxattr is available in community | |
AUR Targets (1): bup-git | |
Proceed with installation? [Y/n] | |
:: Edit bup-git PKGBUILD? [Y/n] n |
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
package main | |
import ( | |
"flag" | |
"fmt" | |
"io" | |
"os" | |
"path" | |
"runtime" | |
) |
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
$ echo "pAkH5a9ubW3Etf8SDO548F6ZjuMKNc0I4Cia1lonDv0.eyJhbGdvcml0aG0iOiJITUFDLVNIQTI1NiIsImlzc3VlZF9hdCI6MTM0NzkxMTYxNywicGFnZSI6eyJpZCI6IjI4NzQzNTk4MTM2OTUwNyIsImxpa2VkIjpmYWxzZSwiYWRtaW4iOnRydWV9LCJ1c2VyIjp7ImNvdW50cnkiOiJkZSIsImxvY2FsZSI6ImVuX1VTIiwiYWdlIjp7Im1pbiI6MTMsIm1heCI6MTd9fX0" |cut -d. -f2 |base64 -d |json_pp | |
base64: invalid input | |
{ | |
"algorithm" : "HMAC-SHA256", | |
"page" : { | |
"admin" : true, | |
"liked" : false, | |
"id" : "287435981369507" | |
}, | |
"user" : { |
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
# gcc -O3 -o cpu-perf-test -lrt cpu-perf-test.cxx && (for x in {1..7}; do sleep 0.3s; ./cpu-perf-test; done) && rm cpu-perf-test | |
#include <time.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
//const char *op_tag = "id "; long op(long x) { return x; } | |
const char *op_tag = "*2 "; long op(long x) { return x * 2; } | |
//const char *op_tag = "<<1"; long op(long x) { return x << 1; } | |
//const char *op_tag = "*27"; long op(long x) { return x * 27; } |
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
import gevent | |
#... | |
def test_reraise_01(): | |
try: | |
gevent.spawn(lambda: 1/0).join() | |
assert False, "ZeroDivisionError excepted" | |
except ZeroDivisionError: | |
pass |
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
# mount -t iso9660 -o loop,ro,noexec ~temoto/Downloads/archlinux-2012.06-1-archboot-x86_64.iso /tmp/arch/ | |
mount: /tmp/arch/: mount failed: No such file or directory | |
$ ls -l ~/Downloads/archlinux-2012.06-1-archboot-x86_64.iso | |
-rw-r--r-- 1 temoto users 375390208 Aug 20 00:39 /home/temoto/Downloads/archlinux-2012.06-1-archboot-x86_64.iso | |
$ ls -ld /tmp/arch | |
drwxr-xr-x 2 root root 4096 Aug 20 01:10 /tmp/arch |
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
# Problem: sa.union_all(*qs).order_by('y') will generate invalid SQL like this: | |
# SELECT ... ORDER BY x LIMIT 10 UNION ALL SELECT ... ORDER BY x LIMIT 10 ORDER BY y | |
# Order in inner queries could be required for LIMIT or DISTINCT ON (field). | |
# | |
# Solution: sqlalchemy should put all inner queries that contain order by or limit | |
# clauses into parenthesis, like this: | |
# SELECT ... UNION ALL (SELECT ... ORDER BY x LIMIT 10) ORDER BY y | |
# | |
# sqlalchemy.sql.compiler.SQLCompiler.visit_compound_select | |
# Fixed to surround subqueries with parens if they contain ORDER BY or LIMIT or OFFSET. |
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
@contextmanager | |
def transaction(pool='common_write'): | |
"""Context manager. | |
Executes block inside DB transaction. Returns cursor. | |
At the end of the block, the connection is returned to pool. | |
>>> with transaction() as cursor: | |
... rows = cursor.execute(...).fetchall() | |
... process(rows) | |
... cursor.execute(...) |
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
package main | |
import ( | |
cache "code.google.com/p/vitess/go/cache" | |
"fmt" | |
zmq "github.com/alecthomas/gozmq" | |
"hash" | |
"hash/fnv" | |
"os" | |
"time" |