Skip to content

Instantly share code, notes, and snippets.

import subprocess
def string_replace_in_file(file_name_with_path, replacements=[]):
'''sed runs all the replacements in a single pass'''
sed_cmd = ['sed', '-i']
for l in replacements:
find_str = l['find'].replace('/', '\/')
replace_str = l['replace'].replace('/', '\/')
sed_expr = "-e s/%s/%s/g" % (find_str, replace_str)
@jambu
jambu / redis_session_backend.py
Created July 11, 2012 07:45 — forked from mikeyk/redis_session_backend.py
A redis backend for Django Sessions, tested on Django 1.3+
from django.contrib.sessions.backends.base import SessionBase, CreateError
from django.conf import settings
from django.utils.encoding import force_unicode
import redis
class SessionStore(SessionBase):
""" Redis store for sessions"""
def __init__(self, session_key=None):
self.redis = redis.Redis(
"""
This fabric file makes setting up and deploying a django application much
easier, but it does make a few assumptions. Namely that you're using Git,
Apache and mod_wsgi and your using Debian or Ubuntu. Also you should have
Django installed on your local machine and SSH installed on both the local
machine and any servers you want to deploy to.
_note that I've used the name project_name throughout this example. Replace
this with whatever your project is called._
@jambu
jambu / gmail-scrollbars.css
Created March 9, 2012 02:17 — forked from Cifro/gmail-scrollbars.css
New Gmail like scrollbars for webkit browsers
/* Gmail style scrollbar */
::-webkit-scrollbar {
width: 12px
}
::-webkit-scrollbar-thumb {
border-width: 1px 1px 1px 2px
}
::-webkit-scrollbar-track {
border-width: 0
}