Skip to content

Instantly share code, notes, and snippets.

View clemesha's full-sized avatar

Alex Clemesha clemesha

View GitHub Profile
ACCESS_KEY='YOUR AMAZON API KEY'
SECRET='YOUR AMAZON SECRET'
BUCKET_NAME='database_backup_bucket' #note that you need to create this bucket first
from boto.s3.connection import S3Connection
from boto.s3.key import Key
def save_file_in_s3(filename):
conn = S3Connection(ACCESS_KEY, SECRET)
bucket = conn.get_bucket(BUCKET_NAME)
"1) install: http://wiki.github.com/bard/mozrepl
"2) turn on "Mozrepl" in Firefox "Tools"
"3) put below in .vimrc
autocmd BufWriteCmd *.html,*.css,*.gtpl,*.sass,*.erb :call ReloadFirefox()
function! ReloadFirefox()
if &modified
write
silent !echo 'BrowserReload();content.window.scrollTo(content.window.pageXOffset, content.window.pageYOffset);repl.quit();' | nc localhost 4242 2>&1 > /dev/null
endif
import sys
import time
import json
from glob import glob
from urlparse import urlparse
from itertools import groupby
from collections import defaultdict
DAY = 15
@clemesha
clemesha / crop_resize_osx_hack.py
Created October 7, 2011 10:02
Download, resize image without ruining aspect ration. OSX specific
#!/usr/bin/env python
"""
Quick hack to download an image, then resize to a smaller image
that does not ruin the aspect ratio of the original image.
NOTE: The script is OS X specific: uses commands 'sips' and 'file'.
"""
import sys
import commands #deprecated in Python 3 - use 'subprocess' module
@clemesha
clemesha / flaskapp.py
Created June 11, 2012 09:21 — 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
@clemesha
clemesha / with.py
Created July 27, 2012 20:54
Python's with statements are beautiful
with open('site.log') as infile, open('err.log', 'w') as outfile:
for line in infile:
if 'ERROR' in line:
outfile.write(line)