Skip to content

Instantly share code, notes, and snippets.

View varikin's full-sized avatar
🏠
Working from home

John Shimek varikin

🏠
Working from home
View GitHub Profile
/*
* Simple code snippet to apply a "* denotes required field" below the Django Admin page title, ex "Change [Model]"
* It also appends a "[field name]*" to all fields that are required.
* And finally it makes all the labels for required fields nice a red.
** Note: make sure to reference jquery in templates/admin/base_site.html <script type="text/javascript" src="{{ STATIC_URL }}js/jquery-latest.pack.js"></script>
# Bash snippet to open new shells in most recently visited dir.
# Useful if you want to open a new terminal tab at the present
# tab's location.
#
# Put this in your .bashrc or whatever.
pathed_cd () {
if [ "$1" == "" ]; then
cd
else
#!/usr/bin/env python
from datetime import datetime, timedelta
import httplib2
from lxml import etree
import sys
import time
from urllib import urlencode
API_KEY = "api_key_goes_here"
import os
import shutil
import md5
def find_duplicate_files(dirs):
all_files = {}
for dir in dirs:
for dirname, dirs, filenames in os.walk(dir):
if '.svn' in dirs:
dirs.remove('.svn')
function net_match ( $network , $ip ) {
$ip_arr = explode ( '/' , $network );
$network_long = ip2long ( $ip_arr [ 0 ]);
$x = ip2long ( $ip_arr [ 1 ]);
$mask = long2ip ( $x ) == $ip_arr [ 1 ] ? $x : 0xffffffff << ( 32 - $ip_arr [ 1 ]);
$ip_long = ip2long ( $ip );
return ( $ip_long & $mask ) == ( $network_long & $mask );
}
function net()
My problems with Lion:
Full screen apps suck on multiple monitors because the second monitor is blank and I can't do anything about it. On the other hand, on my MBA, fullscreen apps rock.
My MBA has crashed (kernel panics) a couple times. Could be Lion, could be hardware.
Initially, had issues with wifi reconnecting after waking up. Seems to be fixed now.
I use to use the three finger swipe to go back both in the browser and in the Twitter app. Now this swipe changes desktops. I could reset that but it annoys me.
@varikin
varikin / fabfile.py
Created February 20, 2012 23:41
A sort of hand crafted fabfile that servers my needs
from os.path import join
from fabric.api import env, require, run, cd
# Fabfile to deploy a Django app. To use run:
#
# fab staging deploy
#
# or
#
# fab prod deploy
@varikin
varikin / django.wsgi
Created February 20, 2012 23:45
Example WSGI file for mod_wsgi
import os, sys, site
# Adds the virtualenv library to the path
ENV_PATH = os.path.realpath(os.path.join(os.path.dirname(__file__), '..', '..', '..'))
site.addsitedir(os.path.join(ENV_PATH, 'lib','python2.6','site-packages'))
# Adds the project to the path
# Note that depending on the location of this file, PROJECT_PATH might change
PROJECT_PATH = os.path.realpath(os.path.join(os.path.dirname(__file__), '..', '..'))
sys.path.append(PROJECT_PATH)
@varikin
varikin / vhost
Created February 20, 2012 23:52
Example Apache virtual host file for mod_wsgi
<VirtualHost *:80>
ServerAdmin admin@example.com
ServerName example.com
LogLevel warn
ErrorLog /path/to/logs/project_error.log
CustomLog /path/to/logs/project_access.log combined
# Ensures Apache servers static files
# These should match STATIC_ROOT and STATIC_URL
@varikin
varikin / gist:2719936
Created May 17, 2012 16:16
Adium with 100%CPU and 5.5 GB of RAM
This file has been truncated, but you can view the full file.
Sampling process 621 for 3 seconds with 1 millisecond of run time between samples
Sampling completed, processing symbols...
Analysis of sampling Adium (pid 621) every 1 millisecond
Process: Adium [621]
Path: /Applications/Adium.app/Contents/MacOS/Adium
Load Address: 0x100000000
Identifier: com.adiumX.adiumX
Version: 1.5 (1.5)
Code Type: X86-64 (Native)
Parent Process: launchd [206]