This file contains hidden or 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
| #!/bin/sh | |
| for i in $(seq 10); do | |
| seq $(((i-1)*100)) $((i*100)) >$i | |
| done |
This file contains hidden or 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 python3 | |
| def f(): | |
| for _ in range(1000**2): | |
| pass | |
| import time | |
| t0 = time.time() | |
| f() |
This file contains hidden or 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
| #!/bin/sh | |
| DUMP_FILE="dump" | |
| while inotifywait -e modify,attrib $DUMP_FILE; do | |
| while lsof $DUMP_FILE; do | |
| echo "waiting..." && sleep 1 | |
| done | |
| cp $DUMP_FILE $DUMP_FILE.$(date "+%Y-%m-%d--%T") | |
| done |
This file contains hidden or 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 datetime | |
| import random | |
| import time | |
| import tornado.ioloop | |
| import tornado.web | |
| TIME = "%Y-%m-%d %H:%M:%S" | |
| # patch |
This file contains hidden or 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
| class Dict(dict): | |
| def __missing__(self, k): | |
| return k | |
| namespace = Dict() | |
| eval("{a:1, b:c, 3:3, _:4}", None, namespace) | |
| # T_T... I'm too late, see library/stdtypes.html#str.format_map | |
| >>> class Default(dict): |
This file contains hidden or 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 os | |
| import os.path | |
| def walk(directory, dir_filter=None, file_filter=None): | |
| """return a list of all files in this directory, sorted""" | |
| all_files = [] | |
| for root, dirs, files in os.walk(directory): | |
| dirs[:] = sorted(filter(dir_filter, dirs)) | |
| all_files.extend(map(lambda f: os.path.abspath(os.path.join(root, f)), | |
| sorted(filter(file_filter, files)))) |
This file contains hidden or 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
| def list_all_same_type(type_conv): | |
| def conv(v): | |
| return [conv(i) for i in v] if isinstance(v, list) else type_conv(v) | |
| return conv |
This file contains hidden or 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
| eval_orig = eval | |
| def patch_eval(): | |
| if eval is not eval_orig: | |
| return False | |
| from functools import lru_cache | |
| c = lru_cache(maxsize=1000)(compile) | |
| e = eval_orig |
This file contains hidden or 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
| a, b, *c = 1,2,3,4,5 | |
| *a, b = 1,2,3,4 | |
| a, *b, c = 1,2,3,4,5 | |
| [i for i, *_ in [[0], [1, 2], [3, 4, 5]]] | |
| lst = [(0,), (1,), (2,), (3,), (4,), (5,), (6,), (7,), (8,), (9,)] | |
| assert [i for i, in lst] == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] |
This file contains hidden or 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
| create table users( | |
| id integer primary key, | |
| zone integer not null, | |
| user text not null, | |
| name text not null, | |
| password text default '', | |
| born real default 0.0, | |
| ban real default 0.0, | |
| login real default 0.0, | |
| logout real default 0.0, |
OlderNewer