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
(function() { | |
/* Bookmarklet that displays the actual podcast feed | |
* URL when ran on an iTunes store page for a podcast. | |
* | |
* Simply grabs the Artist ID from the URL and does | |
* an iTunes Store API lookup to get the hidden (original) | |
* podcast feed URL (whatever format that may be in). | |
* | |
* @author: Darian Moody <mail@djm.org.uk> | |
* @date: Working as of Sun.22.Apr.2012 |
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
# I mean this: | |
* */12 * * * /path/to/virtualenv/bin/python /path/to/django/project/manage.py cleanup | |
# over this: | |
* */12 * * * source /path/to/virtualenv/bin/activate; /path/to/django/project/manage.py cleanup |
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
# Works on Scrapy v0.20 | |
from scrapy.crawler import Crawler | |
from scrapy.utils.project import get_project_settings | |
def get_spiders(): | |
""" Retrieves a dict of the spiders classes available to the current | |
scrapy keyed by their string-name. | |
""" | |
settings = get_project_settings() |
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 re | |
def camelcase_to_human_readable(camel_cased_string): | |
""" Converts a string from CamelCase to Human readable. | |
e.g SuperBadRobot -> Super Bad Robot | |
""" | |
return ' '.join(re.findall("([A-Z][^A-Z]*)", camel_cased_string)).strip() | |
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 | |
import sys | |
from os.path import basename, splitext | |
from urlparse import urlparse | |
import requests | |
from bs4 import BeautifulSoup | |
def extract_full_size_url_from_tag(image_tag): |
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
#!/usr/bin/env python -i | |
""" | |
A local interactive IPython shell for Google App Engine on Mac OSX. | |
Usage: | |
cd /to/project/folder/with/app.yaml | |
python gae_shell.py | |
Notes: |
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
FROM python:2.7 | |
# Force stdin, stdout and stderr to be totally unbuffered. | |
ENV PYTHONUNBUFFERED 1 | |
# For Pillow to have freetype support. | |
RUN ln -s /usr/include/freetype2 /usr/include/freetype | |
RUN mkdir -p /usr/src/app | |
WORKDIR /usr/src/app |
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
# Bad | |
class Join(object): | |
""" | |
>>> join_by_commas = Join(',') | |
>>> join_by_commas(['o', 'm', 'g']) | |
'o,m,g' | |
""" | |
def __init__(self, separator=u' '): | |
self.separator = separator |
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
Reading zip file to memory | |
Uploading zip file to AWS Lambda eu-west-1 with parameters: | |
{ FunctionName: 'xxx-staging-1-0-0', | |
FunctionZip: <Buffer 50 478 0b 00 ...>, | |
Handler: 'index.handler', | |
Mode: 'event', | |
Role: 'arn:aws:iam::xxx:role/xxx', | |
Runtime: 'nodejs', | |
Description: 'Resizes images for the xxx project.', | |
MemorySize: '512', |
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
export function chunkMap (map, chunkSize) { | |
const chunkedMaps = [] | |
const mapAsArray = Array.from(map) | |
for (var i = 0; i < map.size; i += chunkSize) { | |
let chunked = mapAsArray.slice(i, i + chunkSize) | |
chunkedMaps.push(new Map(chunked)) | |
} | |
return chunkedMaps | |
} |
OlderNewer