Skip to content

Instantly share code, notes, and snippets.

@pricco
pricco / SVN_Git_Mirror.md
Created July 23, 2012 15:46 — forked from ticean/SVN_Git_Mirror.md
SVN Git Mirror

Create Git Mirror from SVN Repository

This guide will demonstrate how to mirror an SVN into a Git repo. You're the target audience if you're an SVN user, just getting started with Git and need to coax your project team over to Git.

The branching scenario has been simplified for clarity.

References

@pricco
pricco / sequential.py
Created August 1, 2012 14:12
MongoKit: Auto Increment
from mongokit import Document
class Sequential(Document):
__collection__ = 'sequential'
structure = {
'_id': basestring,
'next': long
}
indexes = [{ 'fields': ['_id'], 'unique': True }]
@pricco
pricco / fields.py
Created August 8, 2012 21:08
MultipleFileField & MultipleImageField <input type=file multiple=multiple>
from django import forms
from django.utils.translation import ugettext_lazy as _
from django.utils.datastructures import MultiValueDict, MergeDict
from django.core import validators
from django.core.exceptions import ValidationError
try:
from cStringIO import StringIO
except ImportError:
from StringIO import StringIO
@pricco
pricco / env_run.sh
Created August 20, 2012 03:34 — forked from mrowl/env_run.sh
Script for running sandboxed apps from outside the virtualenv environment. Useful when managing apps with supervisor.
#!/bin/bash
# Runs any command (the args) in the virtualenv environment where this script resides.
# You need to change the ACTIVATE_PATH variable
# depending on where your virtualenv activate file is relative to this script.
# The WORKING_DIR var controls the directory from which the command will be run.
# I put this in a bin folder at the top level of my app.
# my virtualenv structure:
# /my_env
# /my_env/bin ( with the venv activate script )
# /my_env/my_app
@pricco
pricco / gist:3440266
Created August 23, 2012 18:53 — forked from caseman/gist:3428752
Ctor: Lightweight Javascript Constructors with Inheritance

Ctor: Lightweight Javascript Constructors with Inheritance

Author: Casey Duncan @iamnotcasey

This Javascript constructor with inheritance pattern is designed as a lightweight alternative to other methods I've seen while still providing a nice abstraction as a 13 line function that can be easily inlined into your code.

@pricco
pricco / qurl.py
Last active July 22, 2016 22:01
Django Template Tag: Url query string modifier
"""qurl is a tag to append, remove or replace query string parameters from an url (preserve order)"""
import re
from django.template import Library, Node, TemplateSyntaxError
from urlparse import urlparse, parse_qsl, urlunparse
from django.utils.encoding import smart_str
from urllib import urlencode
register = Library()
@pricco
pricco / common.py
Created April 2, 2013 18:32
Remove accents django filter.
import unicodedata
from django import template
register = template.Library()
@register.filter
def remove_accents(value):
nkfd_form = unicodedata.normalize('NFKD', unicode(value))
return u"".join([c for c in nkfd_form if not unicodedata.combining(c)])
from os.path import splitext
from django.core.exceptions import ValidationError
from django.utils.translation import ugettext_lazy as _
from django.template.defaultfilters import filesizeformat
class FileValidator(object):
"""
Validator for files, checking the size, extension and mimetype.
@pricco
pricco / history.sh
Last active August 1, 2022 02:20
List commits of all subdirectories for the specified date: ./history.sh 2013-12-28
exec 2> /dev/null
original=`pwd`
function history {
d=$1
author=$2
for i in $(find . -type d -print -maxdepth 3); do
cd "${i}"
if [ -d ".git" ]; then
h=`git rev-list --after "${d}T00:00:00" --before "${d}T23:59:59" --tags --branches --remotes --author=${author} --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' | sed '/^commit/ d'`
@pricco
pricco / loaders.py
Created May 19, 2014 19:31
Wrapper for loading templates from "templates" directories in the specified apps.
"""
Wrapper for loading templates from "templates" directories in the specified
apps.
>>> {% extends 'grappelli,admin:admin/change_list.html' %}
"""
import os
import sys