This file contains hidden or 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
def previous_current_next(iterable): | |
"""Make an iterator that yields an (previous, current, next) tuple per element. | |
Returns None if the value does not make sense (i.e. previous before | |
first and next after last). | |
""" | |
iterable=iter(iterable) | |
prv = None | |
cur = iterable.next() | |
try: |
This file contains hidden or 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 io | |
from django.core.files.storage import default_storage as storage | |
def save(self, *args, **kwargs): | |
super().save(*args, **kwargs) | |
img_read = storage.open(self.image.name, 'r') | |
img = Image.open(img_read) |
This file contains hidden or 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
INSTALLED_APPS = [ | |
# My apps | |
'personal', | |
'account', | |
'blog', | |
# django apps | |
'django.contrib.admin', |
This file contains hidden or 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
const MAX_WIDTH = process.env.PHOTO_MAX_WIDTH || 800; | |
const QUALITY = process.env.PHOTO_QUALITY || 0.9; | |
const readPhoto = async (photo) => { | |
const canvas = document.createElement('canvas'); | |
const img = document.createElement('img'); | |
// create img element from File object | |
img.src = await new Promise((resolve) => { | |
const reader = new FileReader(); |