Skip to content

Instantly share code, notes, and snippets.

@mtigas
mtigas / backup_dir.sh
Created Feb 9, 2010
Script that creates a tarball backup of a directory, compressed with xz (LZMA2) and encrypted with GPG. Uploads backup to S3 storage space.
View backup_dir.sh
#!/bin/bash
# Script that creates a tarball backup of a directory,
# compressed with xz (LZMA2) and encrypted with GPG.
# Resulting backup is then uploaded onto my Amazon S3
# storage space.
#
# Requires:
# * GNU Tar 1.22
# * XZ Utils 4.999.9beta
# * GNU Privacy Guard
View gist:363931
mtigas@nationbrowse:~$ ab -n 100 -c 10 http://mike.tig.as/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking mike.tig.as (be patient).....done
Server Software: nginx/0.7.62
Server Hostname: mike.tig.as
View zip_import.py
# See http://www.census.gov/tiger/tms/gazetteer/zips.txt
import csv
from places.models import ZipCode
from django.contrib.gis.geos import fromstr as geo_from_str
state_cache = dict()
reader = csv.reader(open('zips.txt'),delimiter=',',quotechar='"')
for row in reader:
View libx264-max2.ffpreset
# My excessive ffmpeg conversion preset for high quality H264 files.
#
# Generally follows the "max" preset, with some values completely cracked
# out (me_range=32 *is* excessive). Leaves refs at 4 (since iPhone/iPad
# does not support higher values) and 8x8 DCT is disabled so that we
# end up with a file that is in the H264 Main profile.
#
# Save this as ~/.ffmpeg/libx264-max2.ffpreset
#
# Example use. (CRF determines filesize: lower CRF->higher quality and larger file. 22-24 results in ~1.5 to 2.0 Mbps.)
View gist:623484
# regex for matching timestamp out of skype log
\[\d{2}/\d{2}/\d{2} \d{1,2}\:\d{2}\:\d{2} [AP]M\]
View video_convert.sh
#!/bin/bash
# Using `ffmpeg` to convert an arbitrary video file to an ipad-compatible M4V (h264+AAC)
# file. Mac-specific since libfaac has occasional audio glitches and the `afconvert` command
# is of a much higher quality (since it uses the system's Quicktime libs).
# Assumes ffmpeg and x264 (and other libs ffmpeg uses to decode various video formats
# you want) are installed.
#
# Easy mode:
# * Install homebrew: http://github.com/mxcl/homebrew
View logging.py
from reviewgallery.settings.development.defaults import *
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'formatters': {
'default': {
'format': '%(name)s-%(levelname)s -- %(message)s'
}
},
@mtigas
mtigas / timezones.py
Created Nov 29, 2010
Contains method to find the system local timezone.
View timezones.py
#!/usr/bin/python
#
# Copyright 2009 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@mtigas
mtigas / key_strength_patch.py
Created Dec 15, 2010
Monkey patch to add key strengthening to django.contrib.auth user passwords.
View key_strength_patch.py
"""
Adds key strengthening (via sha384 + large number of hash iterations) to the
default Django password implementation.
The number of iterations is stored along with the hash so that in the future,
the number of rounds can be increased for new passwords in the same system.
Standard Django hashes look like:
algo$salt$hash
@mtigas
mtigas / tap_detect.sh
Created Jan 26, 2011
Shell script to detect whether your network connection is being tapped by your IT department or ISP.
View tap_detect.sh
#!/bin/bash
# I take absolutely no responsibility for anything that happens when you run this.
while true; do
curl -s "http://www.google.com/?q=hardcore+porn" > /dev/null &\
curl -s "http://www.google.com/?q=kiddie+porn" > /dev/null &\
echo -n "."
sleep 5