#Stay Standalone
A short script to prevent internal links to a "webapp" added to iPhone home screen to open in Safari instead of navigating internally.
| var page = new WebPage(), | |
| address, output, size; | |
| address = "http://www.metachunk.com/"; | |
| width = 1024; height = 600; | |
| output = "./screenshots/wat-"+width+"X"+height+".png"; | |
| page.viewportSize = { width: width, height: height }; | |
| if (phantom.args.length === 3 && phantom.args[1].substr(-4) === ".pdf") { |
| #coding: utf-8 | |
| from cStringIO import StringIO | |
| from email.mime.multipart import MIMEMultipart | |
| from email.mime.text import MIMEText | |
| from email.header import Header | |
| from email import Charset | |
| from email.generator import Generator | |
| import smtplib | |
| # Example address data |
#Stay Standalone
A short script to prevent internal links to a "webapp" added to iPhone home screen to open in Safari instead of navigating internally.
| #!/bin/sh | |
| # | |
| # Script to prepare and restore full and incremental backups created with innobackupex-runner. | |
| # | |
| # This script is provided as-is; no liability can be accepted for use. | |
| # | |
| INNOBACKUPEX=innobackupex-1.5.1 | |
| INNOBACKUPEXFULL=/usr/bin/$INNOBACKUPEX | |
| TMPFILE="/tmp/innobackupex-restore.$$.tmp" |
| from django.contrib.sessions.backends.base import SessionBase, CreateError | |
| from django.conf import settings | |
| from django.utils.encoding import force_unicode | |
| import redis | |
| class SessionStore(SessionBase): | |
| """ Redis store for sessions""" | |
| def __init__(self, session_key=None): | |
| self.redis = redis.Redis( |
| from django.db.models.signals import post_init | |
| def track_data(*fields): | |
| """ | |
| Tracks property changes on a model instance. | |
| The changed list of properties is refreshed on model initialization | |
| and save. | |
| >>> @track_data('name') |
| import simplejson | |
| from django.contrib.sessions.backends.base import SessionBase, CreateError | |
| from django_ext.redis_helper import get_redis | |
| class SessionStore(SessionBase): | |
| """ | |
| A Redis-based session store. |
| """ | |
| Here's how to run a command from Python piping a string in to stdin and reading the | |
| output back in to another string. It took me way too long to work this out. | |
| """ | |
| from subprocess import Popen, PIPE | |
| output = Popen( | |
| ['java', '-jar', 'yuicompressor-2.4.2.jar', '--type=css'], | |
| stdin=PIPE, stdout=PIPE |
| class QuerySetDoubleIteration(Exception): | |
| "A QuerySet was iterated over twice, you probably want to list() it." | |
| pass | |
| # "Skinny" here means we use iterator by default, rather than | |
| # ballooning in memory. | |
| class SkinnyManager(Manager): | |
| def get_query_set(self): | |
| return SkinnyQuerySet(self.model, using=self._db) |