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
#Resizes an image and keeps aspect ratio. Set mywidth to the desired with in pixels. | |
import PIL | |
from PIL import Image | |
mywidth = 300 | |
img = Image.open('someimage.jpg') | |
wpercent = (mywidth/float(img.size[0])) | |
hsize = int((float(img.size[1])*float(wpercent))) |
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
import urllib2 | |
import json | |
import string | |
#Python script to get google fonts json feed, parse it and print the info. | |
#Can be useful for automatically generating stylesheet links for Google Fonts. | |
KEY = 'YOURGOOGLEFONTSAPIKEY' | |
f = urllib2.urlopen('https://www.googleapis.com/webfonts/v1/webfonts?key='+KEY) |
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
import os | |
from datetime import datetime | |
import time | |
import slugify | |
#Generate timestamps for post id and date. | |
ts = time.time() | |
timeid = datetime.fromtimestamp(ts).strftime('%Y-%m-%d') | |
timestamp = datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S') |