Skip to content

Instantly share code, notes, and snippets.

View lrowe's full-sized avatar

Laurence Rowe lrowe

  • San Francisco, CA
View GitHub Profile
#cloud-config
# Debug log
output: {all: '| tee -a /var/log/cloud-init-output.log'}
package_upgrade: true
packages:
- screen
- git
- curl
@lrowe
lrowe / index.html
Last active December 17, 2015 04:29
Problem with pushState and back button in Safari/Chrome.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Cache-Control" content="no-cache, no-store" />
<script>
function navigate() {
var missing_url = window.location.pathname + '/missing'
window.history.pushState({test:'test'}, 'new page', missing_url);
// Reloading will return the 404
window.location.reload();
@lrowe
lrowe / pyramid-view-predicates.rst
Created April 25, 2013 22:49
This is an attempt at a formal description of Pyramid's view predicate system in order to find possible avenues for optimization.

Pyramid view predicates

This is an attempt at a formal description of Pyramid's view predicate system in order to find possible avenues for optimization. It was prompted by concern over the approach currently taken to fix #768_.

An alternative implementation approach is suggested using adapter registry subscribers.

@lrowe
lrowe / gist:5191160
Created March 18, 2013 21:53
favicon subrequest for pyramid
def static_resources(config):
config.add_static_view('static', 'static', cache_max_age=STATIC_MAX_AGE)
favicon_path = '/static/img/favicon.ico'
if config.route_prefix:
favicon_path = '/%s%s' % (config.route_prefix, favicon_path)
config.add_route('favicon.ico', 'favicon.ico')
def favicon(request):
subreq = request.copy()
@lrowe
lrowe / routing.rst
Last active December 15, 2015 02:49

Improve routing

Goals:
  • Improve performace by not testing routes unnecessarily
  • Provide an ordering of routes based on specificity of a route pattern.

Routing in other systems

/*global document, jQuery */
(function($) {
$(function() {
var g, renderer;
var width = $(document).width() - 20;
var height = $(document).height() - 60;
g = new Graph();
@lrowe
lrowe / gist:3627672
Created September 4, 2012 22:53
bin/test -s plone.app.portlets -t testHeadingLinkRootedItemGone
Error in test testHeadingLinkRootedItemGone (plone.app.portlets.tests.test_navigation_portlet.TestRenderer)
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/case.py", line 327, in run
testMethod()
File "/data/devel/plone/4.3/src/plone.app.portlets/plone/app/portlets/tests/test_navigation_portlet.py", line 595, in testHeadingLinkRootedItemGone
link = view.heading_link_target()
File "/data/devel/plone/4.3/src/plone.app.portlets/plone/app/portlets/portlets/navigation.py", line 175, in heading_link_target
nav_root = self.getNavRoot()
File "/data/buildout/eggs/plone.memoize-1.1.1-py2.7.egg/plone/memoize/instance.py", line 51, in memogetter
val=func(*args, **kwargs)
@lrowe
lrowe / agent.rb
Created August 1, 2012 14:19
Ruby file causes SublimeLinter to crash
require 'tempfile'
require 'net/ntlm'
require 'kconv'
require 'webrobots'
##
# An HTTP (and local disk access) user agent. This class is an implementation
# detail and is subject to change at any time.
class Mechanize::HTTP::Agent
@lrowe
lrowe / selenium-update.diff
Created April 4, 2012 17:05
[PATCH] Update selenium server version to 2.20.0. Tweak formula.
From 753e7a27d4650199c75e1476b821ac998213a797 Mon Sep 17 00:00:00 2001
From: Laurence Rowe <laurence@lrowe.co.uk>
Date: Wed, 4 Apr 2012 17:06:56 +0100
Subject: [PATCH] Update version to 2.20.0. Tweak formula.
* Use #{version} instead of a hardcoded version in the caveats.
* Use a sha1 checksum instead of md5 as it is listed on google code.
---
Library/Formula/selenium-server-standalone.rb | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)