Skip to content

Instantly share code, notes, and snippets.

@mtigas
mtigas / LICENSE.txt
Created February 9, 2011 20:07
Script that allows batch-downloading a person's full Facebook photo collection.
Copyright 2011 Mike Tigas. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are
permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of
conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list
of conditions and the following disclaimer in the documentation and/or other materials
#!/bin/bash
#
# usat_import
# Fork by Mike Tigas
# Based on work by Ryan Nagle, Chris Groskopf and Brian Boyer
#
# Updated to allow import of multiple states into the same database.
# Unlike the original script, this *only* generates super-wide tables.
#
# Shapes are stored in WGS84 (EPSG:4326) for portability.
#import "CustomOverlayView.h"
#import "TileOverlay.h"
#import "Three20Network/Three20Network.h"
#pragma mark Private methods
@interface CustomOverlayView()
- (NSUInteger)zoomLevelForMapRect:(MKMapRect)mapRect;
- (NSUInteger)zoomLevelForZoomScale:(MKZoomScale)zoomScale;
- (NSUInteger)worldTileWidthForZoomLevel:(NSUInteger)zoomLevel;
- (CGPoint)mercatorTileOriginForMapRect:(MKMapRect)mapRect;
@mtigas
mtigas / pypy.rb
Created April 18, 2011 18:15
pypy homebrew recipe, using nightly on OSX 64bit
require 'formula'
require 'hardware'
class Pypy < Formula
if MacOS.prefer_64_bit?
url 'http://buildbot.pypy.org/nightly/trunk/pypy-c-jit-42951-88b090e851cc-osx64.tar.bz2'
md5 'f2fc482e8de56171f05ad83d92846acf'
version '1.5.0a'
else
url 'http://pypy.org/download/pypy-1.4.1-osx.tar.bz2'
@mtigas
mtigas / donottrack_middleware.py
Created April 25, 2011 22:03
Django middleware to aid in implementing support for "Do Not Track" HTTP headers.
"""
A Django middleware, to aid in implementing the HTTP header-based
"Do Not Track" mechanism described in [1] and a few of the myriad variations.
Known browsers utilizing this option include Firefox 4+, Internet Explorer 9+,
and Safari under Mac OS X 10.7.
This does nothing by itself. It remains the application's responsibility to
ensure that the `tracking_opt_out` attribute is used to toggle first party
tracking and disable or notify third parties of the user's preference.
#!/usr/bin/env python
import sys
def getint(data, offset, intsize):
"""Retrieve an integer (big-endian) and new offset from the current offset"""
value = 0
while intsize > 0:
value = (value<<8) + ord(data[offset])
offset = offset + 1
intsize = intsize - 1
@mtigas
mtigas / premature_optimization_middleware.py
Created April 28, 2011 20:50
Django SpacelessHtmlResponse
from django.utils.html import strip_spaces_between_tags
class SpacelessHtmlResponse(object):
"""
Equivalent to running {% spaceless %} template tag against a full HTML response.
"""
def process_response(self, request, response):
if response.get("Content-Type", "").startswith("text/html"):
response.content = strip_spaces_between_tags(response.content.strip())
return response
@mtigas
mtigas / gist:952344
Last active April 3, 2024 07:57
Mini tutorial for configuring client-side SSL certificates.

Client-side SSL

For excessively paranoid client authentication.


Updated Apr 5 2019:

because this is a gist from 2011 that people stumble into and maybe you should AES instead of 3DES in the year of our lord 2019.

some other notes:

@mtigas
mtigas / gist:959392
Created May 6, 2011 17:34
Aliases to help test a local or LAN server with "real world" internet connection speeds.
# Add to .bash_profile:
# Adds `slow_net` and `slow_net_off` commands to your terminal.
# * limits to 150KBps ~~ 1.2 Megabit internet
# * adds 200ms latency
alias slow_net="sudo ipfw pipe 1 config bw 150KByte/s delay 200ms && sudo ipfw add 1 pipe 1 src-port 80"
alias slow_net_off="sudo ipfw delete 1"
# Check out the base Django trunk into "django" directory.
svn co http://code.djangoproject.com/svn/django/trunk/ django
# ... update it to 1.2.5
svn switch http://code.djangoproject.com/svn/django/tags/releases/1.2.5/ django
# ... update to 1.3
svn switch http://code.djangoproject.com/svn/django/tags/releases/1.3/ django