Skip to content

Instantly share code, notes, and snippets.

View aapris's full-sized avatar

Aapo Rista aapris

  • Helsinki, Finland
View GitHub Profile

Keybase proof

I hereby claim:

  • I am aapris on github.
  • I am aapris (https://keybase.io/aapris) on keybase.
  • I have a public key whose fingerprint is C06C C956 FA69 D9C7 2F71 01EF 20A9 AA27 8D69 8920

To claim this, I am signing this object:

@aapris
aapris / serialize_django_request.py
Last active March 5, 2019 13:20
Serialize Django>=2.2 HttpRequest
"""
Sometimes you need to pass forward HttpRequest, which is not directly serializable.
serialize_django_request() takes Django HttpRequest as an argument, extracts
HttpRequest.headers (available since Django 2.2), HttpRequest.body and most interesting
values out from HttpRequest.META and returns them in a dict which is json, msgpack etc.
serializable.
"""
from django.http.request import HttpRequest
@aapris
aapris / pretty_4sq.py
Last active September 3, 2016 16:02
Pretty print your Foursquare history
# Pretty print your Foursquare history
# remember to "pip install requests ics" into you virtualenv
import sys
import requests
from ics import Calendar
ics_data = requests.get(sys.argv[1]).text
cal = Calendar(ics_data)
for e in cal.events:
print("{} | {}".format(e.begin.format('YYYY-MM-DD HH:mm:ss ZZ'), e.name.lstrip('@ ')))

Keybase proof

I hereby claim:

  • I am aapris on github.
  • I am aapris (https://keybase.io/aapris) on keybase.
  • I have a public key whose fingerprint is A35E 3622 48AD 67F6 6BEB FE71 7C58 6186 743C 17BF

To claim this, I am signing this object: