Skip to content

Instantly share code, notes, and snippets.

@agamdua
agamdua / diff_wigners
Last active December 23, 2015 17:59
Testing Wigner from sympy
1c1
< r"""
---
> """
3a4,5
> form http://pydoc.net/Python/sympy/0.7.1/sympy.physics.wigner/
>
12,13c14
< References
< ~~~~~~~~~~
''' We are facing a problem.
tl;dr: We want to add a new table to the database, without losing previous data.
On adding a new model to models.py, syncdb doesn't create the table. However, if we create a new db, it works.
This is surprising, because we didn't think that adding a new table is a 'schema migration' that syncdb cannot handle.
Hence, we don't think South will help here.
Is there something I'm missing/getting wrong?
from lettuce import before, after, world
from splinter.browser import Browser
from django.test.utils import setup_test_environment, teardown_test_environment
from django.core.management import call_command
from django.db import connection
from django.conf import settings
from django.test.simple import DjangoTestSuiteRunner
from django.contrib.auth.models import User
import logging
from __future__ import unicode_literals
'''
About __future__ from the docs:
-------------------------------
1. A future statement is a directive to the compiler that a particular module should be compiled using
syntax or semantics that will be available in a specified future release of Python.
2. The future statement is intended to ease migration to future versions of Python that introduce
incompatible changes to the language.
3. It allows use of the new features on a per-module basis before the release in
@agamdua
agamdua / decorators.py
Last active December 26, 2015 05:09
decorators source
########################## LICENCE ###############################
# Copyright (c) 2005-2012, Michele Simionato
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
# Redistributions of source code must retain the above copyright
@agamdua
agamdua / file1.txt
Created December 30, 2013 10:35
Created via API
Demo
@agamdua
agamdua / ngRepeat-example.html
Last active August 29, 2015 13:56
Simple example illustrating basic usage of the ngRepeat directive (AngularJS)
<div ng-controller="ExampleCtrl1">
<div ng-repeat="book in books">
{{ $index+1 }} {{ book }}
</div>
</div>
@agamdua
agamdua / fabfile.py
Created March 12, 2014 17:14 — forked from kecs/fabfile.py
from fabric.api import env, local, run, require, cd, sudo
import os
from fabric.context_managers import cd
env.project_name = 'weight'
def prod():
"Use the actual webserver"
@agamdua
agamdua / template-base.py
Created May 1, 2014 13:36
Template class from base.py in Django
class Template(object):
def __init__(self, template_string, origin=None, name=None):
try:
template_string = force_text(template_string)
except UnicodeDecodeError:
raise TemplateEncodingError("Templates can only be constructed "
"from unicode or UTF-8 strings.")
if settings.TEMPLATE_DEBUG and origin is None:
origin = StringOrigin(template_string)
self.nodelist = compile_string(template_string, origin)
@agamdua
agamdua / compile_string.py
Created May 1, 2014 13:39
From django.templates.base
def compile_string(template_string, origin):
"Compiles template_string into NodeList ready for rendering"
if settings.TEMPLATE_DEBUG:
from django.template.debug import DebugLexer, DebugParser
lexer_class, parser_class = DebugLexer, DebugParser
else:
lexer_class, parser_class = Lexer, Parser
lexer = lexer_class(template_string, origin)
parser = parser_class(lexer.tokenize())
return parser.parse()