Skip to content

Instantly share code, notes, and snippets.

@walterrenner
walterrenner / readme.md
Created October 14, 2015 12:55
Use project related mirgation modules

Keep your custom Migrations in your project

A proof of concept.

If you cant't/won't use the apps Migration files this workaround can be helpful for you.

We assume you have a clean Database without any Migrations applied and a Project named my_project that you are working on. Add the below snippet in your settings.py right after INSTALLED_APPS.

This tells django to use migration files from the module in my_project.migrations.<appname>.migrations.

@walterrenner
walterrenner / gist:f8e8d6b06a1f0c79bea6
Created December 17, 2015 10:30 — forked from abrookins/gist:1933635
A Sublime Text 2 Django project file with a test runner build system
{
"folders":
[
{
"path": "django_project_dir"
},
{
"path": "lib/python2.7"
}
],
@walterrenner
walterrenner / hack.md
Created January 4, 2016 08:36
some useful bash commands

count history commands

history | cut -c8- | sort | uniq -c | sort -rn | head
@walterrenner
walterrenner / german-iso-3166.csv
Last active February 1, 2025 01:01 — forked from malteos/german-iso-3166.csv
German ISO-3166 Country Codes CSV (deutsche Ländercodes)
AF Afghanistan
EG Ägypten
AL Albanien
DZ Algerien
AD Andorra
AO Angola
AI Anguilla
AQ Antarktis
AG Antigua und Barbuda
GQ Äquatorial Guinea
@walterrenner
walterrenner / split_excel.py
Created September 13, 2017 07:38
Split large Excel files into chunks of n
import argparse
import xlrd
import xlwt
def chunks(l, n):
"""Yield successive n-sized chunks from l."""
for i in range(0, len(l), n):
yield l[i:i + n]
@walterrenner
walterrenner / unicode.py
Created October 11, 2017 12:26
Dealing with unicode and strings in Python
# Deal exclusively with unicode objects as much as possible
# by decoding things to unicode objects when you first get them and
# encoding them as necessary on the way out.
# https://stackoverflow.com/a/6048203
>>> s = 'abc'
>>> type(s)
<type 'str'>
>>> u = u'abc' # note the u prefix