Skip to content

Instantly share code, notes, and snippets.

@dAnjou
dAnjou / flask-upload
Created June 5, 2012 12:35
Flask upload example
<VirtualHost *>
ServerName example.com
WSGIDaemonProcess www user=max group=max threads=5
WSGIScriptAlias / /home/max/Projekte/flask-upload/flask-upload.wsgi
<Directory /home/max/Projekte/flask-upload>
WSGIProcessGroup www
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
@zed
zed / .gitignore
Created August 25, 2012 22:42
call Python callback from a non-python thread in a C extension module
/c_extension_module*.so
/build/*
/.do_built*
/log
/all.did
@zed
zed / .gitignore
Created August 30, 2012 10:45
b2a_bin in Cython (a-la binascii.hexlify but for binary ("01") strings)
/b2a_bin.c
/b2a_bin.html
/b2a_bin*.so
/build/*
@zed
zed / test_utc_to_dst.py
Created October 5, 2012 08:55
can't get correct time during DST using dateutil (pytz works)
# based on https://launchpadlibrarian.net/94884626/testUtcToDst.patch
# from https://bugs.launchpad.net/dateutil/+bug/944123
import unittest
from datetime import datetime, timedelta
import dateutil.tz
import dateutil.zoneinfo
import pytz
tzname = "America/Toronto"
anonymous
anonymous / test_normalize_from_utc.py
Created November 5, 2012 11:06
Test whether tz.normalize() is necessary when converting from pytz.utc.
#!/usr/bin/env python
"""Test whether tz.normalize() is necessary when converting from pytz.utc.
The example from the docs [1] uses `au_tz.normalize()` but it seems
unnecessary:
>>> utc_dt = datetime.utcfromtimestamp(1143408899).replace(tzinfo=utc)
>>> utc_dt.strftime(fmt)
'2006-03-26 21:34:59 UTC+0000'
>>> au_tz = timezone('Australia/Sydney')
@zed
zed / .gitignore
Created November 8, 2012 21:37
Download comments from projecteuler.net for given problem range, user.
/.cachedir/
/comments-*.json
@zed
zed / progressbar-nothreads.py
Created November 13, 2012 18:47
start/stop tkinter progressbar on start/end of a subprocess without using threads
import sys
from subprocess import Popen
from Tkinter import Tk, StringVar
import ttk
START, STOP = "start", "stop"
# just some arbitrary command for demonstration
cmd = [sys.executable, '-c', """import sys, time
print("!")
@zed
zed / test_arrow_timezone.py
Last active April 5, 2018 20:56
Notes on `arrow` library.
#!/usr/bin/env python3
"""Notes on `arrow` library.
* inconsitent (fixed)
>>> a = arrow.get(datetime(2012, 4, 7, 0, 30, 00), 'America/New_York')
>>> a.datetime.tzname() == a.tzinfo.tzname(a.datetime) # fixed
True
@zed
zed / count-words-performance.py
Created December 1, 2012 03:21
Python: measure time performance of counting words in corpus/gutenberg
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
http://stackoverflow.com/q/13655169
"""
import doctest
import inspect
import os
import sys
import timeit
/big.txt
/reporttime$py.class