Skip to content

Instantly share code, notes, and snippets.

@mabroor
mabroor / fabfile.py
Created March 21, 2011 17:44 — forked from fiee/fabfile.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
fabfile for Django
------------------
see http://morethanseven.net/2009/07/27/fabric-django-git-apache-mod_wsgi-virtualenv-and-p/
modified for fabric 0.9/1.0 by Hraban (fiëé visuëlle)
several additions, corrections and customizations, too
@mabroor
mabroor / db_backup.sh
Created July 18, 2011 09:22 — forked from mynameisrufus/db_backup.sh
Postgres backup script (rails focused)
# Postgres backup script
# mynameisrufus
#
# Cron tab examples:
#
# daily keeping the last 5 days (run at 1:00AM, 2 minutes after the hour)
#
# 02 1 * * * postgres /script/db_backup.sh daily /var/backups/db $DATABASE_OWNER 5 >> /var/backups/db/backup.log 2>&1
#
#
@mabroor
mabroor / shrinkpdf.sh
Created January 25, 2012 15:05
Shrink the size of a big pdf
#!/bin/sh
# usage:
# sh shrinkpdf.sh yourfile.pdf
# credit:
# http://www.alfredklomp.com/programming/shrinkpdf/
gs -q -dNOPAUSE -dBATCH -dSAFER \
-sDEVICE=pdfwrite \
-dCompatibilityLevel=1.3 \
-dPDFSETTINGS=/screen \
@mabroor
mabroor / selenium_with_python.rst
Created April 15, 2012 19:25 — forked from virtix/selenium_with_python.rst
Selenium with Python

Selenium with Python

Author: Baiju Muthukadan
Email:baiju.m.mail AT gmail.com
Version: 0.5.0
def run_pg_fouine():
info = host_info[env.host_string]
db_name = info.tags.get('Name')
sudo('perl -pi -e "s/log_min_duration_statement = .*/log_min_duration_statement = 0/" /etc/postgresql/9.*/main/postgresql.conf')
sudo('/etc/init.d/postgresql reload')
time.sleep(30)
sudo('perl -pi -e "s/log_min_duration_statement = .*/log_min_duration_statement = 500/" /etc/postgresql/9.*/main/postgresql.conf')
sudo('/etc/init.d/postgresql reload')
run('tail -n 100000 /var/log/postgresql/postgresql-9.*-main.log > /tmp/pgfouine.txt')
run('gzip -f /tmp/pgfouine.txt')
@mabroor
mabroor / Procfile
Created May 25, 2012 03:19 — forked from jacobian/Procfile
Hosting Private password protected Sphinx Docs
web: gunicorn -w4 -b0.0.0.0:$PORT app:app
@mabroor
mabroor / dictlist2csv.py
Created May 29, 2012 15:11
How to convert a list of dicts to a CSV file
def dict2csv(dictlist, csvfile):
"""
Takes a list of dictionaries as input and outputs a CSV file.
"""
f = open(csvfile, 'wb')
fieldnames = dictlist[0].keys()
csvwriter = csv.DictWriter(f, delimiter=',', fieldnames=fieldnames)
csvwriter.writerow(dict((fn, fn) for fn in fieldnames))
@mabroor
mabroor / Installing OpenCV
Created July 14, 2012 14:33
Getting Started with OpenCV
$ brew install opencv
# Add the following line to your ~/.bash_profile
export PYTHONPATH="/usr/local/lib/python2.7/site-packages:$PYTHONPATH"
@mabroor
mabroor / gist:3160062
Created July 22, 2012 15:51 — forked from EspadaV8/gist:1357237
Script to import Geonames into PostgreSQL taken from http://forum.geonames.org/gforum/posts/list/15/926.page
#!/bin/bash
#===============================================================================
#
# FILE: getgeo.sh
#
# USAGE: ./getgeo.sh
#
# DESCRIPTION: run the script so that the geodata will be downloaded and inserted into your
# database
#
# -*- coding: utf-8 -*-
import Image
def resize_and_crop(img_path, modified_path, size, crop_type='top'):
"""
Resize and crop an image to fit the specified size.
args:
img_path: path for the image to resize.