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
#!/usr/bin/env python | |
import sys | |
from bottle import get, run, response | |
PORT = int(sys.argv[1]) | |
STATUS = int(sys.argv[2]) | |
@get('/old') | |
def index(): |
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
#!/usr/bin/env python | |
import sys | |
port = int(sys.argv[1]) | |
import requests | |
s = requests.session() | |
base_url = 'http://localhost:%d' % port | |
print '-------- request /old' |
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
# | |
# example output with redirect cache and 301 response | |
# | |
# first request to /old | |
127.0.0.1 - - [11/Jun/2014 13:45:13] "GET /old HTTP/1.1" 301 6 | |
127.0.0.1 - - [11/Jun/2014 13:45:13] "GET /new HTTP/1.1" 301 6 | |
127.0.0.1 - - [11/Jun/2014 13:45:13] "GET /newer HTTP/1.1" 301 6 | |
127.0.0.1 - - [11/Jun/2014 13:45:13] "GET /newest HTTP/1.1" 200 6 | |
# 3 more requests to /old |
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/sh | |
if "true" : '''\' | |
then | |
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
source $DIR/venv/bin/activate | |
exec python "$0" "$@" | |
exit 127 | |
fi | |
''' |
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
#!/usr/bin/env python | |
from cleantar import single_prefix | |
import sys | |
import os | |
import time | |
single, msg = single_prefix(sys.argv[1]) | |
if single: | |
print 'tar file is clean; just one prefix; will untar',; sys.stdout.flush() | |
for i in range(5, 0, -1): |
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
#!/usr/bin/env python | |
import hashlib | |
from math import ceil, log | |
def hasher(x, n): | |
ret = [] | |
h = hashlib.sha1() | |
h.update(x) | |
for i in range(n): |
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
#!/usr/bin/env python | |
# based on slice example from | |
# https://medium.com/@tucnak/why-go-is-a-poorly-designed-language-1cc04e5daf2#.pr6pifnky | |
from itertools import count | |
def log(item, log_counter=count(start=1)): | |
print next(log_counter), item |
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 math | |
import sys | |
import asyncio | |
from functools import partial | |
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QGridLayout, QProgressBar | |
from quamash import QEventLoop | |
class MyWidget(QWidget): |
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 math | |
import sys | |
import asyncio | |
from functools import partial | |
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QGridLayout, QProgressBar | |
from PyQt5.QtNetwork import QNetworkAccessManager, QNetworkRequest | |
from PyQt5.QtCore import QUrl | |
from quamash import QEventLoop |
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
#!/usr/bin/env python | |
import os | |
import sys | |
import subprocess | |
import re | |
regexes = map(re.compile, [ | |
r'(IMG|PANO)_(?P<YEAR>\d{4})(?P<MONTH>\d{2})(?P<DAY>\d{2})_(?P<HOUR>\d{2})(?P<MINUTE>\d{2})(?P<SECOND>\d{2})(?P<EXTRA>.*).jpg', |