Skip to content

Instantly share code, notes, and snippets.

@twik
twik / gist:1728512
Created February 3, 2012 06:25 — forked from gregnewman/gist:1653962
Homebrew forumula patched to allow fullscreen on Lion
cd /usr/local/Library/Formula
rm emacs.rb
wget https://raw.github.com/gist/1446720/36c7a3ab0ec8255e361dae11e0803cdf5cd09157/emacs.rb
brew install emacs --cocoa --lion
@twik
twik / flaskapp.py
Created June 11, 2012 19:55 — forked from kennethreitz/flaskapp.py
My typical flask app base
# -*- coding: utf-8 -*-
import os
from flask import Flask
from flask_heroku import Heroku
from flask_sslify import SSLify
from raven.contrib.flask import Sentry
from flask.ext.celery import Celery
@twik
twik / gist:3419347
Created August 21, 2012 20:55
avr decoder
from avro import io
from avro import datafile
from time import time
def load(filename):
fo = open(filename, "rb")
reader = datafile.DataFileReader(fo, io.DatumReader())
for i, record in enumerate(reader):
pass
@twik
twik / install_postgis_osx.sh
Created October 23, 2012 18:37 — forked from juniorz/install_postgis_osx.sh
Installing PostGIS on Mac OS X and Ubuntu
# Some good references are:
# http://russbrooks.com/2010/11/25/install-postgresql-9-on-os-x
# http://www.paolocorti.net/2008/01/30/installing-postgis-on-ubuntu/
# http://postgis.refractions.net/documentation/manual-1.5/ch02.html#id2630392
#1. Install PostgreSQL postgis and postgres
brew install postgis
initdb /usr/local/var/postgres
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
user jessed staff;
worker_processes 2;
events {
worker_connections 1024;
}
http {
include mime.types;
@twik
twik / gist:4669564
Created January 30, 2013 00:45
Text editor inside a browser. Copy and paste this into the url field.
data:text/html, %3Cstyle%20type%3D%22text%2Fcss%22%3E%23e%7Bposition%3Aabsolute%3Btop%3A0%3Bright%3A0%3Bbottom%3A0%3Bleft%3A0%3B%7D%3C%2Fstyle%3E%3Cdiv%20id%3D%22e%22%3E%3C%2Fdiv%3E%3Cscript%20src%3D%22http%3A%2F%2Fd1n0x3qji82z53.cloudfront.net%2Fsrc-min-noconflict%2Face.js%22%20type%3D%22text%2Fjavascript%22%20charset%3D%22utf-8%22%3E%3C%2Fscript%3E%3Cscript%3Evar%20e%3Dace.edit(%22e%22)%3Be.setTheme(%22ace%2Ftheme%2Fmonokai%22)%3Be.getSession().setMode(%22ace%2Fmode%2Fruby%22)%3B%3C%2Fscript%3E
#! /usr/bin/env python
import redis
import random
import pylibmc
import sys
r = redis.Redis(host = 'localhost', port = 6389)
mc = pylibmc.Client(['localhost:11222'])
@twik
twik / donotuse.py
Created August 16, 2013 17:19 — forked from e000/donotuse.py
##########################################################
# How to NEVER use Lambdas. An inneficient and yet educa-#
# tonal guide to the proper misuse of the lambda constru-#
# ct in Python 2.x. [DO NOT USE ANY OF THIS EVER] #
# by: e000 (13/6/11) #
##########################################################
## Part 1. Basic LAMBDA Introduction ##
# Well, it's worth diving straight into what lambdas are.
# Lambdas are pretty much anonymous "one line" functions
@twik
twik / gist:6519144
Created September 11, 2013 03:47
Backup all photos from Messages.app
#! /bin/sh
mkdir $HOME/Pictures/backup_Messages_photos/
find $HOME/Library/Messages/Attachments -iname \*.jp* | parallel -X cp -v -p {} $HOME/Pictures/backup_Messages_photos/
@twik
twik / gist:7916172
Created December 11, 2013 18:49
List the contents of folders recursively, sorted by modification time.
#! /usr/bin/env python
# See http://preshing.com/20130115/view-your-filesystem-history-using-python
import optparse
import os
import fnmatch
import time
# Parse options
parser = optparse.OptionParser(usage='Usage: %prog [options] path [path2 ...]')
parser.add_option('-g', action='store', type='long', dest='secs', default=10,