Skip to content

Instantly share code, notes, and snippets.

Avatar

Mike Tigas mtigas

View GitHub Profile
@uraimo
uraimo / dnsovertls.md
Last active Oct 4, 2020
Configure your Mac to use DNS over TLS
View dnsovertls.md
View Sorty.js
// 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);
View tracker.coffee
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 Feb 21, 2012
Django class-based view for PyMongo.
View views.py
"""
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 Jan 30, 2012
Locating the story: The latest in mapping.
View LOCATING_THE_STORY.textile

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 Dec 7, 2011
Python iterator using arbitrary slices: handy for processing objects like django-haystack SearchQuerySets which trigger backend I/O on slicing
View chunked_iterator.py
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 Sep 21, 2011
Mappings between five-digit county FIPS codes and their corresponding counties
View countyFIPS.js
// 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 Sep 20, 2011
Takes a GeoDjango queryset and creates a cartogram of circles based on the Dorling algorithm.
View dorling.py
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
View how-many-os.rb
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 Dec 6, 2010
Tracking changes on properties in Django
View track_data.py
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')
You can’t perform that action at this time.