Patch to `/usr/libexec/path_helper` to prevent hangs with long `PATH`s. | |
--- path_helper_bak 2009-05-07 15:54:37.000000000 +0200 | |
+++ path_helper 2009-06-04 10:51:39.000000000 +0200 | |
@@ -15,7 +15,7 @@ | |
for f in "$DIR" "$DIR".d/* ; do | |
if [ -f "$f" ]; then | |
for p in $(< "$f") ; do | |
- [[ "$NEWPATH" = *(*:)${p}*(:*) ]] && continue | |
+ egrep -q "(^|${SEP})${p}($|${SEP})" <<<"$NEWPATH" && continue | |
[ ! -z "$NEWPATH" ] && SEP=":" |
import simplejson as json | |
import lxml | |
class objectJSONEncoder(json.JSONEncoder): | |
"""A specialized JSON encoder that can handle simple lxml objectify types | |
>>> from lxml import objectify | |
>>> obj = objectify.fromstring("<Book><price>1.50</price><author>W. Shakespeare</author></Book>") | |
>>> objectJSONEncoder().encode(obj) | |
'{"price": 1.5, "author": "W. Shakespeare"}' | |
""" |
<!DOCTYPE html> | |
<!-- Helpful things to keep in your <head/> | |
// Brian Blakely, 360i | |
// http://twitter.com/brianblakely/ | |
--> | |
<head> | |
<!-- Disable automatic DNS prefetching. | |
A template engine in 42 lines of code.
I was thinking of a way to generate HTML without using strings as embedding strings in Javascript is a pain if they are multi-lined. There isn't a nice triple quote like there exists in Python.
So I took my inspiration from Lisp HTML generators that use S-expressions to generate HTML. I thought, hell, S-expressions are just a bunch of nested lists, I could do the same thing in Javascript.
GitHub supports several lightweight markup languages for documentation; the most popular ones (generally, not just at GitHub) are Markdown and reStructuredText. Markdown is sometimes considered easier to use, and is often preferred when the purpose is simply to generate HTML. On the other hand, reStructuredText is more extensible and powerful, with native support (not just embedded HTML) for tables, as well as things like automatic generation of tables of contents.
# -*- coding: utf-8 -*- | |
import os | |
from flask import Flask | |
from flask_heroku import Heroku | |
from flask_sslify import SSLify | |
from raven.contrib.flask import Sentry | |
from flask.ext.celery import Celery |
from Framework.Log.Log import logger | |
from contextlib import contextmanager | |
from time import time | |
@contextmanager | |
def timed(message): | |
'''' | |
with timed('testing division'): | |
4 / 2 | |
'''' |
One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.
Most workflows make the following compromises:
-
Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the
secure
flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection. -
Use production SSL certificates locally. This is annoying