Skip to content

Instantly share code, notes, and snippets.

View lukasgraf's full-sized avatar

Lukas Graf lukasgraf

  • OPENGIS.ch
  • Bern, Switzerland
View GitHub Profile
@lukasgraf
lukasgraf / configure.zcml
Created October 11, 2015 16:02
CSRF debug helper: Trigger CSRF protection
<configure
xmlns:browser="http://namespaces.zope.org/browser">
<browser:page
name="trigger-csrf"
for="Products.CMFPlone.interfaces.IPloneSiteRoot"
class=".trigger.TriggerCSRFProtection"
permission="cmf.ManagePortal"
/>
@lukasgraf
lukasgraf / session_example.py
Created October 27, 2015 20:54
Using requests sessions
import requests
urls = ['https://en.wikipedia.org/wiki/%s' % n for n in range(100)]
# Code that creates a new connection for every request
for url in urls:
r = requests.get(url)
data = r.text
print len(data)
@lukasgraf
lukasgraf / com.py
Created March 11, 2016 18:48
Logging Demo
from log import setup_logger
class Communicator(object):
def __init__(self, logger=None):
if logger is None:
logger = setup_logger(__name__)
self.log = logger