Skip to content

Instantly share code, notes, and snippets.

View andreasofthings's full-sized avatar
💾
saved

Andreas Neumeier andreasofthings

💾
saved
View GitHub Profile
@andreasofthings
andreasofthings / gist:3e2d6bb224ffbac7fc28541248a21f38
Created September 28, 2021 17:12
iterate over the standard django-restframework list endpoint and get all results, until no `next` is available
def query(endpoint, token):
import json
import requests
headers = {'Authorization': 'Token %s' % (token)}
http = requests.get(endpoint, headers=headers)
response = json.loads(http.text)
next = response['next']
result = response['results']
while(next):
import Image
import base64
import StringIO
output = StringIO.StringIO()
im = Image.open("test.png") # Your image here!
im.save(output, format='PNG')
output.seek(0)
output_s = output.read()
b64 = base64.b64encode(output_s)
open("test.html","w+").write('<img src="data:image/png;base64,{0}"/>'.format(b64))
import io
from django.http import HttpResponse
import matplotlib.pyplot as plt
def graph_view(request):
image_file = io.BytesIO()
plt.scatter([1, 2, 3, 4], [6, 10, 12, 1])
@andreasofthings
andreasofthings / keybase.md
Created December 29, 2014 12:11
keybase.md

Keybase proof

I hereby claim:

  • I am aneumeier on github.
  • I am andreasn (https://keybase.io/andreasn) on keybase.
  • I have a public key whose fingerprint is 01F6 E873 6847 85BE 0814 1866 7262 F9F8 3240 B159

To claim this, I am signing this object:

#!/usr/bin/env python3.7
#-*- coding: utf-8
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
"""
Docstrings use ReStructuredText
"""