Skip to content

Instantly share code, notes, and snippets.

Everything is pip 1.4+ all downloads starting 2014-01-02 and ending with 2014-04-13.

SELECT python_type, array_to_string(python_release[0:2], '.') AS python_release, COUNT(*)
FROM (
    SELECT
        python_type,
        string_to_array(
            (
                CASE WHEN (python_release IS NULL OR python_release = '')
from celery import Celery
app = Celery(broker="redis://...")
@app.task
def my_task():
pass
my_task.delay()
Version: Manage version number based on git revisions and tags
This is "ok", although I don't like that it uses the installed setuptools
metadata instead of writing a file to the sdist. However generating
arbitrary versions from git is basically an unsolvable problem and I'm not
convinced that attempting to do is actually useful (thinking of the dev
mode versions).
AUTHORS: Generate AUTHORS file from git log
connection = engine.connect()
transaction = connection.begin()
with connection.connect() as conn:
conn.execute(
""" UPDATE accounts_user
SET password = %(password)s
WHERE username = %(username)s
""",
password=new_hash,
@dstufft
dstufft / welp.txt
Last active August 29, 2015 13:58
Python uses the os.py module as a sort of sentinel value to determine where the
stdlib is. It will look in a relative directory first. So if you have a file
structure like…
.
├── bin
│ └── python
└── lib
└── python2.6
└── os.py
$ python -m sysconfig
Platform: "macosx-10.9-x86_64"
Python version: "3.4"
Current installation scheme: "posix_prefix"
Paths:
data = "/Users/dstufft/.pyenv/versions/3.4.0"
include = "/Users/dstufft/.pyenv/versions/3.4.0/include/python3.4m"
platinclude = "/Users/dstufft/.pyenv/versions/3.4.0/include/python3.4m"
platlib = "/Users/dstufft/.pyenv/versions/3.4.0/lib/python3.4/site-packages"
$ python setup.py
no previously-included directories found matching 'documentation/_build'
zip_safe flag not set; analyzing archive contents...
__pycache__.six.cpython-34: module references __file__
__pycache__.six.cpython-34: module references __path__
Installed /Users/dstufft/projects/cryptography/six-1.6.1-py3.4.egg
Searching for cffi>=0.8
Reading https://pypi.python.org/simple/cffi/
Best match: cffi 0.8.2
# thing = Can be a bytes instance, or something that yields bytes instances
for x in thing:
if isinstance(x, int):
x = bytes((x,))
# Do the actual work
pass
$ ls virtualenv/
pypy python2.7 python3.2.5 python3.4
pypy-2.2.1 python2.7.6 python3.2_with_system_site_packages python3.4.0
python2.6 python2.7_with_system_site_packages python3.3
python2.6.9 python3.2 python3.3.5
Available versions:
2.4
2.4.1
2.4.2
2.4.3
2.4.4
2.4.5
2.4.6
2.5
2.5.1