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
// ==UserScript== | |
// @name SCP Foundation reading helper | |
// @namespace http://hrnz.net/ | |
// @version 0.1 | |
// @description Adds simple buttons to SCP page to allow easy paging. | |
// @author Martin Thurau <martin.thurau@gmail.com> | |
// @match http://www.scp-wiki.net/scp-* | |
// @grant unsafeWindow | |
// @grant GM_addStyle | |
// @grant GM_setValue |
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
class Range(object): | |
"""Represents an integer range""" | |
regex = re.compile(r'(?P<low>\d+|-\d+)?\.\.(?P<high>\d+|-\d+)') | |
def __init__(self, low, high): | |
self.low = low | |
self.high = high |
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 pympler import summary, muppy | |
import psutil | |
# source: http://www.mobify.com/blog/sqlalchemy-memory-magic/ | |
def get_virtual_memory_usage_kb(): # pragma: no cover | |
""" | |
The process's current virtual memory size in Kb, as a float. | |
""" |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 urllib2 import urlopen | |
from BeautifulSoup import BeautifulSoup | |
data = urlopen('''http://www.hydro.eaufrance.fr/stations/O7502510&procedure=tousmois''').read() | |
soup = BeautifulSoup(data) | |
table = soup.find('table', {'summary': "valeurs mensuelles et annuelles"}) | |
for tr in table.findAll('tr'): | |
line = [] | |
for td in tr.findAll('td'): |
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
# -*- coding: utf-8 -*- | |
import cookielib | |
from urllib2 import HTTPCookieProcessor, build_opener | |
from urllib import urlencode | |
from BeautifulSoup import BeautifulSoup | |
# the login data | |
login_data = { | |
'login_username': u'USERNAME', | |
'login_password': u'PASSWORD', |
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/python | |
# -*- coding: utf-8 -*- | |
import sys | |
import os.path | |
import pprint | |
sys._old_excepthook = sys.excepthook | |
def assert_hook(exc_type, exception, traceback): |
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
forbidden_starts = filter(bool, | |
''' | |
000 | |
00100 | |
0010100 | |
00101011 | |
001011 | |
00110 | |
00111000 | |
0011101 |
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
class func_and_method_decorator(object): | |
'''A clased based decorator that takes parameters and works on plain functions | |
and instance methods''' | |
def __init__(self, *args, **kwargs): | |
'''The init function is called when a module where the decorator is used | |
is imported. It gets passed all parameters that are given to decorator | |
definition. I.e. | |
@func_and_method_decorator(foo='bar') |
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 test() { | |
} |
OlderNewer