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 | |
import os | |
import time | |
import zmq | |
name = "main" | |
#endpoint = "ipc://test-pub-sub-double-bind.ipc" | |
endpoint = "tcp://127.0.0.1:5004" |
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
ZeroMQ -> file writer |
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
-- Types: ticket_query, ticket_result | |
-- Functions: ticket_search_1, ticket_unique_sellers | |
drop type ticket_query cascade; | |
create type ticket_query as ( | |
cities_from text[], | |
cities_to text[], | |
date_direct date, | |
date_back_min date, | |
date_back_max date, |
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
$ xmonad --recompile | |
Error detected while loading xmonad configuration file: /home/temoto/.xmonad/xmonad.hs | |
xmonad.hs:81:54: | |
Couldn't match expected type `Data.Monoid.Endo WindowSet' | |
with actual type `()' | |
Expected type: X (Data.Monoid.Endo WindowSet) | |
Actual type: X () | |
In the first argument of `liftX', namely | |
`(withDisplay $ \ d -> io (lowerWindow d w))' |
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" |
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
# 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
# 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
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
# 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; } |