This file contains 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
""" | |
Convert numbers from base 10 integers to base X strings and back again. | |
Sample usage: | |
>>> base20 = BaseConverter('0123456789abcdefghij') | |
>>> base20.from_int(1234) | |
'31e' | |
>>> base20.to_int('31e') | |
1234 |
This file contains 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
""" | |
1. GET | |
extract csrf token <input type='hidden' name='csrfmiddlewaretoken' value='1RNvCJoYdwKwtoOAd7kM73sBKJxhzN50' /> | |
2. POST https://www.pix-star.com/accounts/login/ | |
next:/ | |
username:... | |
password:... | |
csrfmiddlewaretoken:1RNvCJoYdwKwtoOAd7kM73sBKJxhzN50 | |
- keep the cookies | |
3. POST album ID to https://www.pix-star.com/album/is2/downloading2/ |
This file contains 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 logging, sys | |
logging.basicConfig(stream=sys.stdout, level=logging.DEBUG) |
This file contains 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
browser_mapping = ( | |
('MSIE 7.*Trident/4.0', 'Internet Explorer 8.0'), | |
('MSIE 6.0', 'Internet Explorer 6.0'), | |
('MSIE 7.0', 'Internet Explorer 7.0'), | |
('MSIE 8.0', 'Internet Explorer 8.0'), | |
('MSIE 9.0', 'Internet Explorer 9.0'), | |
('MSIE 10.0', 'Internet Explorer 10.0'), | |
('Trident/7.0; rv:11.0','Internet Explorer 11.0'), | |
('droid', 'Android'), | |
('Chrome', 'Chrome'), |
This file contains 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
select * from Table FORCE INDEX (primary) | |
where /* lots of complex where clauses */ | |
order by id desc limit 10; |
This file contains 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
from django.conf import settings | |
from django.http import HttpResponse | |
from django.conf.urls import url | |
settings.configure( | |
DEBUG = True, | |
SECRET_KEY = 'yourrandomsecretkey', | |
ROOT_URLCONF = __name__, | |
MIDDLEWARE_CLASSES = (), | |
) |
This file contains 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/bash | |
# Create scratch with 'virtualenv --python=python2.7 scratch && scratch/bin/pip install ipython' | |
scratch/bin/pip install $1 | |
scratch/bin/ipython -c "import $1; print '\nimported $1'" -i |
This file contains 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
2014-10-22: https://pypi.python.org/packages/source/l/librabbitmq/librabbitmq-1.5.2.tar.gz#md5=842aea204fcfb5d7a541ae72d5ad38bc | |
2014-10-28: https://pypi.python.org/packages/source/r/raven/raven-3.5.2.tar.gz#md5=a3fe6c823d01cca0802b78d43cc4953a | |
2014-10-31: https://pypi.python.org/packages/source/e/exam/exam-0.10.5.tar.gz#md5=cb5a5848f3779283054d5556a6c16f55 |
This file contains 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 cProfile, pstats, StringIO | |
pr = cProfile.Profile() | |
pr.enable() | |
# ... do something ... | |
pr.disable() | |
s = StringIO.StringIO() | |
sortby = 'cumulative' | |
ps = pstats.Stats(pr, stream=s).sort_stats(sortby) |
This file contains 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
function generateChart(figures) { | |
// figures is an object mapping labels to numbers | |
var cht = 'p'; // Chart type: pie | |
var chs = '460x200'; // Image dimensions | |
var chd = []; // Chart data | |
var chl = []; // Corresponding labels | |
var min = 0; | |
var max = 0; | |
$.each(figures, function(label, value) { | |
chl[chl.length] = label; |
OlderNewer