Skip to content

Instantly share code, notes, and snippets.

View davesque's full-sized avatar

David Sanders davesque

  • Seattle, WA
View GitHub Profile
@davesque
davesque / rename_to_time.py
Created February 12, 2013 03:38
Rename files based on timestamp info
#!/usr/bin/env python
from dateutil import parser
from dateutil.tz import gettz
import csv
import os
import sys
FORMAT = '%Y-%m-%d %H.%M.%SZ.pdf'
@davesque
davesque / rename.py
Last active December 12, 2015 08:59
Adjust file names based on time zone info
#!/usr/bin/env python
from dateutil import parser
from dateutil.tz import gettz
import csv
import os
import sys
FORMAT = '%Y-%m-%d %H.%M.%SZ.pdf'
@davesque
davesque / strip_tag.py
Created January 25, 2013 19:38
Django template tag to strip or trim leading and trailing characters.
import ast
from django import template
register = template.Library()
class StripNode(template.Node):
"""
Strips leading and trailing characters in the enclosed content.
@davesque
davesque / nginx.conf
Created January 7, 2013 18:35
Basic nginx conf
user www-data;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
@davesque
davesque / uwsgi.sh
Created January 7, 2013 18:34
Daemonize uwsgi
#!/bin/bash
#/etc/init.d/uwsgi
daemon=/usr/local/bin/uwsgi
pid=/var/run/uwsgi.pid
args="--master --emperor /etc/vassals/ --uid www-data --daemonize /var/log/uwsgi/uwsgi.log"
case "$1" in
start)
echo "Starting uwsgi"
@davesque
davesque / vassal.ini
Created January 7, 2013 18:33
Uwsgi ini file for django
[uwsgi]
socket = /tmp/example.com.sock
; Worker processes
master = 1
processes = 4
; Virtualenv and home directory
virtualenv = /var/virtualenvs/example.com
chdir = /var/www/example.com
@davesque
davesque / host.conf
Created January 7, 2013 18:30
Nginx host file for django and uwsgi
server {
listen 80;
server_name example.com;
charset utf-8;
location /static/ {
alias /var/www/example.com/static/;
}
@davesque
davesque / bright.py
Created December 20, 2012 00:22
Adjusts the brightness of the laptop display
#!/usr/bin/env python
import argparse
from fractions import Fraction
MAX_BRIGHTNESS_FILE = '/sys/class/backlight/intel_backlight/max_brightness'
BRIGHTNESS_FILE = '/sys/class/backlight/intel_backlight/brightness'
if __name__ == '__main__':
@davesque
davesque / shuffle.py
Created November 23, 2012 21:28
Shuffle the lines of a file
#!/usr/bin/env python
import sys
import random
if __name__ == '__main__':
contents = sys.stdin.readlines()
random.shuffle(contents)
sys.stdout.write(''.join(contents))
@davesque
davesque / quicktab.vim
Created November 12, 2012 19:11
Quickly set tab space size in vim
" With pathogen: place in ~/.vim/bundle/quicktab/plugin
" Without pathogen: place in ~/.vim/plugin
" Sets tab size to `size`.
function! QuickTabSet(size)
let &tabstop = a:size
let &softtabstop = a:size
let &shiftwidth = a:size
echo 'Changed tab size to '.a:size.' spaces'
endfunction