Skip to content

Instantly share code, notes, and snippets.

@uraimo
uraimo / dnsovertls.md
Last active March 22, 2024 20:55
Configure your Mac to use DNS over TLS
// usage: var mytable = new Sorty(table);
(function(){
var Row = function(el) {
this.values = $.map($(el).find('td'), function(e) {
var el = $(e);
var attr = el.attr('data-sort');
return attr ? parseFloat(attr) : el.text();
});
this.el = $(el);
page = require('webpage').create()
page.onConsoleMessage = (msg) ->
console.log 'CONSOLE:' + msg
page.onResourceRequested = (params, request) ->
isJavaScript = params['url'].slice(-3) is '.js'
isJQuery = (params['url'].indexOf 'jquery') isnt -1
if isJavaScript and not isJQuery
@jeremyjbowers
jeremyjbowers / views.py
Created February 21, 2012 22:56
Django class-based view for PyMongo.
"""
I am sure everyone has something like this already.
I think PyDanny may have even built this into Django-Mongonaut.
But I needed to have this without installing any extra stuff.
Please enjoy version 0.0.3 of my class-based list/detail views for PyMongo.
"""
from bson.objectid import ObjectId
from common.mongo import MongoConnection
from django.conf import settings
from django.views.generic.base import View
@palewire
palewire / LOCATING_THE_STORY.textile
Created January 30, 2012 23:59
Locating the story: The latest in mapping.

Locating the story: The latest in mapping

A collection of links for a NICAR 2012 presentation. It will suggest broad themes for the past year, and try to support them with examples from work in the field. This is a work in progress. Feel free to crap on it, or add your own ideas.

Escape from Google Maps

  • Google changed the rules of the game. There are now usage limits. Read about them here
  • TileMill, custom tiles, need examples
  • Links to ranty blog posts from Nestoria guy and others
  • One replacement is simple line maps drawn using HTML5 technologies like SVG, Canvas and VML. You saw this example a lot in election maps during the GOP primaries, like NYT, WaPo, HuffPo, LAT
@acdha
acdha / chunked_iterator.py
Created December 7, 2011 23:02
Python iterator using arbitrary slices: handy for processing objects like django-haystack SearchQuerySets which trigger backend I/O on slicing
from itertools import count
def chunked_iterator(iterable, chunk_size):
"""Given a slice-able yield individual items but consume them in chunk_size
batches so we can e.g. retrieve records from Solr in 50-100 batches
rather than the default 10
Note that unlike the itertools grouper example we must use slice notation
to trigger things like Haystack's sliced __getitem__ to set our own batch
size
@myersjustinc
myersjustinc / countyFIPS.js
Created September 21, 2011 21:55
Mappings between five-digit county FIPS codes and their corresponding counties
// Source: http://www.census.gov/geo/www/ansi/countylookup.html
var countyToFIPS = {
'Alabama': {
'Autauga County': '01001',
'Baldwin County': '01003',
'Barbour County': '01005',
'Bibb County': '01007',
'Blount County': '01009',
'Bullock County': '01011',
@palewire
palewire / dorling.py
Created September 20, 2011 08:26
Takes a GeoDjango queryset and creates a cartogram of circles based on the Dorling algorithm.
import math
from django.contrib.gis.geos import Point
class Cartogram(object):
"""
Takes a GeoDjango queryset and creates a cartogram of circles based on
the Dorling algorithm.
User must provide a queryset and strings pointing to the data attribute
require 'rubygems'
require 'rest-client'
g = "http://go"
o = "o"
loop do
url = g + o + "gle.com"
p "trying " + url
p RestClient.get(url).headers
@dcramer
dcramer / track_data.py
Created December 6, 2010 19:15
Tracking changes on properties in Django
from django.db.models.signals import post_init
def track_data(*fields):
"""
Tracks property changes on a model instance.
The changed list of properties is refreshed on model initialization
and save.
>>> @track_data('name')