Skip to content

Instantly share code, notes, and snippets.

View lfalanga's full-sized avatar
🏠
Working from home.

Leandro Falanga lfalanga

🏠
Working from home.
  • Buenos Aires, Argentina.
View GitHub Profile
@lfalanga
lfalanga / django-south
Created February 21, 2013 20:04
Django-South useful commands.
Normal Migration
1. The developer (you) change the models.py file, updating the application's data model.
2. Run manage.py schemamigration app_name --auto to create a migration file for generation N+1.
3. Run manage.py migrate app_name to update the database schema and migrationhistory table to generation N+1.
Initial Migration
1. The developer (you) creates the first models.py file, defining the application's data model.
2. Run manage.py schemamigrate app_name --initial to create a migration file for generation 1.
3. Run manage.py migrate app_name to create the database schema and migrationhistory table to generation 1.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
</head>
<body>
@lfalanga
lfalanga / foo.py
Last active December 20, 2019 02:24
import sys, os
sys.path.append('/path/to/your/project') # The directory that contains settings.py
# Set up the Django settings/environment
from django.core.management import setup_environ
from myproject import settings
setup_environ(settings)
import sys, os
try:
raise NotImplementedError("No error")
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
error_desc = str(exc_type), fname, str(exc_tb.tb_lineno)
print(' - '.join(error_desc))
@lfalanga
lfalanga / nfs
Created April 22, 2013 13:28
Mount NFS volume on windows.
mount \\nfs_server\share * -u:username -p:pass
export PYTHONPATH=$PYTHONPATH:/lib/python
export PYTHONPATH=$PYTHONPATH:$HOME/lib/python
echo $PYTHONPATH
#!/usr/bin/env bash
# Written by William Ting for the following blog post:
# http://williamting.com/posts/2012/04/18/set-up-python-and-django-on-dreamhost/
rcfile="${HOME}/.bashrc"
version="2.7.3"
setuptools_version="2.7"
tmp_dir="${HOME}/tmp-${RANDOM}"
if [[ ${#} == 0 ]]; then
@lfalanga
lfalanga / startapp.sh
Created April 25, 2013 21:19
Create Django app.
python manage.py startapp polls
@lfalanga
lfalanga / postfix.sh
Last active December 16, 2015 18:59
Most useful postfix commands.
# Start - Stop - Restart postfix server.
/etc/init.d/postfix start|stop|restart
# Postfix restart in Mac OS X 10.8 Mountain Lion
sudo launchctl unload /System/Library/LaunchDaemons/org.postfix.master.plist
sudo launchctl load /System/Library/LaunchDaemons/org.postfix.master.plist
# Delete mail queue in MacOSX
sudo postsuper -d ALL
@lfalanga
lfalanga / 0_reuse_code.js
Last active August 29, 2015 14:22
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console