Skip to content

Instantly share code, notes, and snippets.

View ianb's full-sized avatar

Ian Bicking ianb

View GitHub Profile
this.get('#/view/:id', function (context) {
$.ajax({
url: './api/view/'+this.params.id,
dataType: 'json',
success: function (result) {
renderPage('page-view', result);
}
});
});
$.ajax({
url: "./content/about.html",
dataType: "html",
success: function (result) {
$('#body').html(result);
}
});
def safe_str(*objs, **kw):
tmpl = ''.join(_safe(o) for o in objs)
if kw:
tmpl = tmpl % dict((name, _safe(key)) for name, key in kw.items())
return tmpl
def _safe(o):
if isinstance(o, unicode):
return o.encode('utf8')
return o
@ianb
ianb / compress_html.py
Created February 8, 2011 19:41
Inlines scripts and stylesheets and uses htmlcompressor on the result
#!/usr/bin/env python
try:
from lxml import html
except ImportError:
raise ImportError("You must have lxml installed to use this tool")
import optparse
import urlparse
import urllib
import sys
import subprocess
The origin should be an ASCII URL, that is, non-ASCII characters
should be normalized down to ASCII.
We are relying on urlmatch.js's normalization of :80 etc, not testing
that directly (because it makes the tests hard to run). We should
verify that all URLs are being normalized in all code paths.
Widgets are allowed in the code but not noted in the spec, need to be
readded. Takes a path and a preferred size, like {"widget": {"path":
"/widget.html", "width": 100, "height": 100}}. Height and width are
The origin should be an ASCII URL, that is, non-ASCII characters
should be normalized down to ASCII.
LH: The UA should handle idna for us. I think this is a noop.
IB: Hmm... yeah, now that I think about it. It could be a little assert sometime if we want,
just to make sure the UA is not weird. We don't care about non-ASCII anywhere but the
origin, and the origin isn't in the manifest, so we're okay.
We are relying on urlmatch.js's normalization of :80 etc, not testing
#!/bin/sh
HOST=appdir1.vm1.labs.sjc1.mozilla.com
ssh $HOST "sudo -u www bash -c 'cd /home/www/code ; git pull ; touch wsgi/openwebapp-directory.wsgi'"

Installation

Sync

You may want to setup your own Sync server; instructions here.

The default backend is just a simple SQLite database. You may want to edit etc/sync.conf and set sqluri to something like mysql://sync:sync@localhost/sync (after installing MySQLdb, and maybe deleting lib/python2.6/no-global-site-packages.txt)

Frontend

@ianb
ianb / init-ignore.js
Created August 17, 2011 19:17
Example of ignoring some console messages
exports.init_tests = function () {
require('harness').add_pointless_error(function (message) {
if (/\[JavaScript.*\/(jquery|base32)/.test(message)) {
return true;
}
});
};
@ianb
ianb / gist:1222633
Created September 16, 2011 17:33
Web Intent use case brainstorm

Use Cases

Screen scrape microdata:

  • grab an ical event (send)
  • grab an hcard
  • atom feed
  • make note of an hreview (actually I can't think of what you'd do with an hreview)
  • ? generic grabbing, or we specifically figure out support for particular kinds of data (i.e., microformats.org specs)