Skip to content

Instantly share code, notes, and snippets.

# Redis proof-of-concept for geo searching
# Created by Berry Groenendijk on 2010-04-30.
# Copyright 2010 - personal project. All rights reserved.
import redis
from random import Random
View wtc
#!/usr/bin/env ruby
require 'open-uri'
require 'rubygems'
require 'nokogiri'
uri = ""
doc = Nokogiri::HTML.parse(open(uri).read)
coordt /
Created Dec 1, 2010
A Fabric fabfile that allows you to check which packages are not like the others on a set of servers.
from __future__ import with_statement
from fabric.api import env, run, settings, hide
from fabric.decorators import hosts, runs_once
venv = "/home/websites/.virtualenvs/twtv3/"
env.user = 'webdev'
env.hosts = [
jatorre / v_get_tile.plsql
Created Dec 15, 2010
A function to create a PostGIS geometry out of a Google Tile X/Y/Z definition
View v_get_tile.plsql
-- Function: v_get_tile(integer, integer, integer)
-- DROP FUNCTION v_get_tile(integer, integer, integer);
CREATE OR REPLACE FUNCTION v_get_tile(x integer, y integer, z integer)
RETURNS geometry AS
origin_shift CONSTANT FLOAT := 20037508.342789244;
initial_resolution CONSTANT FLOAT := 156543.03392804062;
wulczer / gist:1343455
Created Nov 6, 2011
txpostgres + websockets example
View gist:1343455
Run a websocket and HTTP server on port 7000. The web page served over HTTP
connects to the websocket server and waits for database notifications.
After loading the page, connect to your database and run
=# NOTIFY data, 'some text';
which should make 'some text' appear in the textarea.
madrobby /
Created Nov 14, 2011
Backbone i18n with CoffeeScript
# before this file is loaded, a locale should be set:
# In a browser environment, you can use:
# ```<script>__locale='en';</script>```
# In a server environment (specifically node.js):
# ```global.__locale = 'en';```
# normalize in-app locale string to "en" or "de-AT"
parts = @__locale.split('-')
mbostock / .block
Last active Sep 20, 2018 — forked from mbostock/.block
Clustered Force Layout II
View .block
license: gpl-3.0
methane / gist:2185380
Created Mar 24, 2012
Tornado Example: Delegating an blocking task to a worker thread pool from an asynchronous request handler
View gist:2185380
from time import sleep
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
from tornado.web import Application, asynchronous, RequestHandler
from multiprocessing.pool import ThreadPool
_workers = ThreadPool(10)
def run_background(func, callback, args=(), kwds={}):
def _callback(result):
akhenakh / gist:2894704
Created Jun 8, 2012
async callback from threads with Tornado
View gist:2894704
import functools
import time
import threading
import logging
import Queue
import hunspell
import tornado.web
import tornado.websocket
import tornado.locale
mbostock / index.js
Created Aug 7, 2012
Google Hurdles
View index.js
function key(type, code) {
var e = document.createEvent("Event");
e.initEvent(type, true, true);
e.keyCode = code;
setInterval(function() {
key("keydown", 37);
key("keypress", 37);