Skip to content

Instantly share code, notes, and snippets.

View zachwill's full-sized avatar

Zach Williams zachwill

View GitHub Profile
@ericclemmons
ericclemmons / hackernews.de-pagify.js
Created March 7, 2011 01:32
Example recipe for adding "infinite scroll" to Hackernews
// README: https://github.com/ericclemmons/de-pagify
//
// Step 0 - Visit http://news.ycombinator.com/
// Step 1 - Inject jQuery (http://www.learningjquery.com/2009/04/better-stronger-safer-jquerify-bookmarklet)
// Step 2 - Inject De-Pagify (https://github.com/ericclemmons/de-pagify/raw/master/bookmarklet.jquery.min.js)
// Step 3 - Run the following in the console:
jQuery('td > table:eq(1)').depagify('td.title:last a', {
filter: 'tr',
threshold: 'td.title:last a',
@henare
henare / mw-to-gollum.rb
Created March 10, 2011 02:41
Imports a MediaWiki XML export into a Gollum wiki
#!/usr/bin/env ruby
require 'rubygems'
require 'hpricot'
require 'gollum'
wiki = Gollum::Wiki.new('openaustralia.wiki')
file = File.open("OpenAustralia-20110309232515.xml", "r")
doc = Hpricot(file)
@YenTheFirst
YenTheFirst / index.html
Created May 26, 2011 17:57 — forked from mlevans/index.html
Displaying Map Tiles from TileStream
<!Doctype html>
<html>
<head>
<title>311 Density</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="https://github.com/CloudMade/Leaflet/raw/master/dist/leaflet.css" />
<!--[if lte IE 8]><link rel="stylesheet" href="https://github.com/CloudMade/Leaflet/raw/master/dist/leaflet.ie.css" /><![endif]-->
</head>
<body>
@lackac
lackac / 0_intro.coffee
Created June 6, 2011 15:59
vows + should.js + sinon.js (presentation for budapest.js, June 6, 2011)
vows.describe("Presentation")
.addBatch
"László Bácsi from Secret Sauce Partners, Inc.":
topic: "vows + should.js + sinon.js"
"should vow to do BDD": (tools) ->
tools.should.include "vows"
tools.should.include "should"
tools.should.include "sinon"
.export(budapest.js)
@onyxfish
onyxfish / test_cache.py
Created June 28, 2011 21:30
Python unittest-based cache testing rig for Varnish + Wordperss
#!/usr/bin/env python
import cookielib
import json
import re
import random
import unittest
import requests
from wordpress_xmlrpc import Client, WordPressComment, WordPressPost
@ironsjp
ironsjp / cls.js
Created July 18, 2011 14:42
cache script and css to localStorage (same domain only)
/**
* cache script and css to localStorage (same domain only)
*
* $CLS.style("a.css");
*
* $CLS.script("jquery-1.5.2.min.js").wait()
* .script("a.js")
* .script("b.js")
* .script("c.js")
* .wait(function() {
CREATE FUNCTION albums_vector_update() RETURNS TRIGGER AS $$
BEGIN
IF TG_OP = 'INSERT' THEN
new.search_vector = to_tsvector('pg_catalog.english', COALESCE(NEW.title, ''));
END IF;
IF TG_OP = 'UPDATE' THEN
IF NEW.title <> OLD.title THEN
new.search_vector = to_tsvector('pg_catalog.english', COALESCE(NEW.title, ''));
END IF;
END IF;
@nrabinowitz
nrabinowitz / quantize.js
Created July 25, 2011 17:19
Javascript module for color quantization, based on Leptonica
/*!
* quantize.js Copyright 2008 Nick Rabinowitz.
* Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
*/
// fill out a couple protovis dependencies
/*!
* Block below copied from Protovis: http://mbostock.github.com/protovis/
* Copyright 2010 Stanford Visualization Group
* Licensed under the BSD License: http://www.opensource.org/licenses/bsd-license.php
@valyagolev
valyagolev / Instructions.markdown
Created August 18, 2011 19:33
Virtualenv in new Terminal windows/tabs

Run these commands in your console, they will edit necessary files:

echo 'basename "$VIRTUAL_ENV" > ~/.last_venv' >> $VIRTUALENVWRAPPER_HOOK_DIR/postactivate
echo 'rm ~/.last_venv' >> $VIRTUALENVWRAPPER_HOOK_DIR/postdeactivate

Then open your ~/.bashrc or ~/.profile or whatever your shell uses and append:

if [ -e ~/.last_venv ]; then
    workon `cat ~/.last_venv`

fi

// An example of mixing colors using the Less CSS parser.
// This specific example warms the color #222 with a yellow.
var parser = new(less.Parser);
function print_tree(event, tree) {
console.log(tree.toCSS());
}
parser.parse('@dark: #222; @yellow: #fcd20a; .my{ color: mix(@yellow, @dark, 6%); }', print_tree);