Skip to content

Instantly share code, notes, and snippets.

@olasitarska
olasitarska / pgessays.py
Created November 18, 2012 10:11
Builds epub book out of Paul Graham's essays.
# -*- coding: utf-8 -*-
"""
Builds epub book out of Paul Graham's essays: http://paulgraham.com/articles.html
Author: Ola Sitarska <ola@sitarska.com>
Copyright: Licensed under the GPL-3 (http://www.gnu.org/licenses/gpl-3.0.html)
This script requires python-epub-library: http://code.google.com/p/python-epub-builder/
"""
@jbilcke
jbilcke / common-coffee
Created December 8, 2011 17:26
common-coffee
# with common-node
httpclient = require "httpclient"
exports.app = ->
status: 200
headers: {}
body: new httpclient.HttpClient(url: "http://google.com").finish().body
# without
http = require "http"
http.createServer((req, res) ->
@tbranyen
tbranyen / backbone_pushstate_router.js
Last active February 25, 2024 21:38
hijack links for pushState in Backbone
// All navigation that is relative should be passed through the navigate
// method, to be processed by the router. If the link has a `data-bypass`
// attribute, bypass the delegation completely.
$(document).on("click", "a[href]:not([data-bypass])", function(evt) {
// Get the absolute anchor href.
var href = { prop: $(this).prop("href"), attr: $(this).attr("href") };
// Get the absolute root.
var root = location.protocol + "//" + location.host + Application.root;
// Ensure the root is part of the anchor href, meaning it's relative.
var http = require('http');
var Buffer = require('buffer').Buffer;
http.createServer(function (req, res) {
var n = 1024, b;
for (var i = 1; i <= 30; i++)
b = new Buffer(n);
res.writeHead(200, {"Content-Type": "text/plain"});
res.end(b);
}).listen(8000);