Ubuntu's analog of robcowie / postgis_timezone_db.markdown
sudo apt-get install python-software-properties
sudo apt-add-repository ppa:ubuntugis/ppa
sudo apt-get update
sudo apt-get install postgresql-9.1-postgis
| """time.process_time() and time.perf_counter() for Python 2 on Ubuntu.""" | |
| import ctypes | |
| import errno | |
| from ctypes.util import find_library | |
| from functools import partial | |
| CLOCK_PROCESS_CPUTIME_ID = 2 # time.h | |
| CLOCK_MONOTONIC_RAW = 4 | |
| clockid_t = ctypes.c_int |
| ###################################################################### | |
| # CURRENT AWARE LOCAL DATETIME | |
| ###################################################################### | |
| from datetime import datetime | |
| from tzlocal import get_localzone | |
| local_tz = get_localzone() | |
| local_dt = datetime.now(local_tz) |
Ubuntu's analog of robcowie / postgis_timezone_db.markdown
sudo apt-get install python-software-properties
sudo apt-add-repository ppa:ubuntugis/ppa
sudo apt-get update
sudo apt-get install postgresql-9.1-postgis
| #!/usr/bin/env python | |
| """Merge sort a singly linked linear list.""" | |
| import random | |
| from itertools import product | |
| # Linked list is either empty or a value and a link to the next list | |
| empty = None # empty list | |
| class LL(object): | |
| __slots__ = "value", "next" |
git add HISTORY.md
git commit -m "Changelog for upcoming release 0.1.1."
bumpversion patch
| #!/usr/bin/env python3 | |
| """Emulate bash: | |
| $ cat /tmp/fifo.tub & | |
| $ gunzip -c /tmp/filedata.dat.gz > /tmp/fifo.tub | |
| http://stackoverflow.com/questions/19859283/python-subprocess-hangs-with-named-pipes | |
| """ | |
| import os | |
| from contextlib import contextmanager |
| /* pipe/fork/dup2/execve exercise. | |
| The results are similar to: `sort -u --parallel 2 < input_file` | |
| http://stackoverflow.com/questions/19876980/create-2-child-processes-to-sort-words-of-a-file-using-pipe | |
| Usage: | |
| $ gcc -o sort-parallel-uniq *.c && ./sort-parallel-uniq < input_file | |
| */ |
| #!/usr/bin/env python | |
| """Demo: use a socket as subprocesses stdin/stdout. | |
| http://stackoverflow.com/a/19961290 | |
| """ | |
| import socket | |
| from contextlib import closing | |
| from subprocess import Popen, PIPE | |
| host = "stackoverflow.com" |
| /** Pipeline between three processes. | |
| http://stackoverflow.com/q/20056084/ | |
| See @chill's answer: http://stackoverflow.com/a/8092270 | |
| */ | |
| #include <assert.h> | |
| #include <errno.h> | |
| #include <stdio.h> | |
| #include <stdlib.h> |
| #!/usr/bin/env python | |
| """Print words containing the same letter at least three times in a row. | |
| http://stackoverflow.com/questions/20170022/elongated-word-check-in-sentence | |
| """ | |
| import re | |
| words = open('/usr/share/dict/words') | |
| #NOTE: support only ascii letters | |
| elongated = re.compile(r'(?i)([a-z])\1{2,}').search |