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
| def f(): | |
| print(__name__) | |
| print(type(__builtins__)) | |
| f() | |
| if __name__=="__main__": | |
| import show_builtins_type |
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
| # -*- coding: utf-8 -*- | |
| import inspect | |
| import sys | |
| import timeit | |
| from functools import partial, wraps | |
| from timeit import default_timer as timer | |
| __version__ = "0.3.0" | |
| #!/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" |
| import sys | |
| from subprocess import call | |
| for i in range(11): | |
| print("1e%d:" % i) | |
| sys.stdout.flush() | |
| call([sys.executable, '-m', 'timeit', | |
| '-s', 'import numpy as np; a = np.zeros(10**%d, dtype=bool)' % i, | |
| 'a.all()']) # all() should return after the first check (zeros) |
| #!/usr/bin/env python3 | |
| import locale | |
| import os | |
| import sys | |
| envname = "PYTHONIOENCODING" | |
| print("{}:\t{}".format(envname, os.environ.get(envname))) | |
| for set_locale in [False]: |
| #!/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 |
| #!/usr/bin/env python | |
| """Show messages in two new console windows simultaneously. | |
| See http://stackoverflow.com/q/19479504 | |
| """ | |
| import sys | |
| import platform | |
| from subprocess import Popen | |
| messages = 'This is Console1', 'This is Console2' |
| #!/usr/bin/env python | |
| """Demo for [gobject.timeout_add_seconds fails after system hibernation][1] | |
| [1]: http://stackoverflow.com/q/19882390/ | |
| """ | |
| import time | |
| import gtk, glib | |
| def callback(): | |
| print(time.asctime()) |
| /* 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 | |
| */ |