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
<!doctype html> | |
<html> | |
<head> | |
<script src="http://httpbin.org/delay/10"></script> | |
<script>document.write("<plaintext>");</script> | |
<script src="preparsed.js"></script> | |
<title>Pre-Parser Test</title> | |
</head> | |
<body> | |
<p>Check the wire level requests generated by this page.<p> |
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
<html> | |
<head> | |
<script> | |
/** | |
* In 1s, `onError` will be called to 'recover' the original document. | |
*/ | |
onError = function() { | |
var s; | |
while (s = document.scripts[0]) s.parentNode.removeChild(s); |
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
# Generate cache busters using the MD5 digest of files rather than the default | |
# `mtime`. | |
asset_cache_buster do |_, file| | |
Digest::MD5.hexdigest(File.read(file.path)) | |
end |
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
var http = require('http'); | |
var zlib = require('zlib'); | |
var request = http.get({ | |
host: 'www.bonobos.com', | |
port: 80, | |
path: '/', | |
headers: {'accept-encoding': 'gzip'} | |
}); |
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
var rtype = /^(?:button|input)$/i; | |
jQuery.attrHooks.type.set = function(elem, value) { | |
// We can't allow the type property to be changed (since it causes problems in IE) | |
if (rtype.test(elem.nodeName) && elem.parentNode) { | |
// jQuery.error( "type property can't be changed" ); | |
// JB: Or ... can it!? | |
var $el = $(elem); | |
var insertionFn = 'after'; |
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
# http://notmysock.org/blog/hacks/a-twisted-dns-story.html | |
# http://blog.inneoin.org/2009/11/i-used-twisted-to-create-dns-server.html | |
# twistd -y dns.py | |
import socket | |
from twisted.internet.protocol import Factory, Protocol | |
from twisted.internet import reactor | |
from twisted.names import dns | |
from twisted.names import client, server |
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 django.core.exceptions import ObjectDoesNotExist | |
class InfoMiddleware(object): | |
''' | |
Record refer and user-agent info about this dude. | |
''' | |
def process_request(self, request): | |
if request.user.is_anonymous(): | |
if 'referer' not in request.session: |
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
def view(request, template_name): | |
def obj_iterator(): | |
for obj in Objs.objects.iterator(): | |
obj.do_something() | |
yield obj | |
ctx = { | |
'objs': obj_iterator | |
} | |
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
# Override BaseFCGIServer.error to use Django error handling. | |
# http://trac.saddi.com/flup/browser/flup/server/fcgi_base.py#L1210 | |
def patch_error(self, req): | |
import sys | |
from django.conf import settings | |
from django.core import urlresolvers | |
from django.core.handlers.wsgi import WSGIRequest | |
urlconf = settings.ROOT_URLCONF | |
urlresolvers.set_urlconf(urlconf) |
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
// BlackBerry Geolocation. Tested w/ 4.6.0.297. | |
// http://docs.blackberry.com/en/developers/deliverables/1143/browser_devguide.pdf | |
if (window.blackberry && blackberry.location && blackberry.location.GPSSupported) { | |
var AUTONOMOUS_AID_MODE = 2; | |
function win() { | |
clearTimeout(failTimeoutId); | |
blackberry.location.removeLocationUpdate(win); | |
alert(blackberry.location.latitude + " : " + blackberry.location.longitude); | |
} |