Wednesday, August 27, 2014

Alembic Cheat Sheet - Python/SQLAlchemy

alembic revision --autogenerate -m "<your message>"
alembic upgrade head

Problem: FAILED: Target database is not up to date.
Solution: alembic upgrade head

Problem: No such revision '5000106def16'
Solution: 
  1. sqlite3 db.sqlite3
  2. drop table alembic_version; (and exit, ctrl+d)
  3. alembic upgrade head

Failed to fetch http://security.ubuntu.com

W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/quantal-security/main/binary-amd64/Packages  404  Not Found [IP: 91.189.91.14 80]

This is happening because you're on an unsupported/old version of Ubuntu.

One way to fix it:
  1. nano /etc/apt/sources.list
  2. Change all entries referring to http://archive.ubuntu.com/ubuntu to http://old-releases.ubuntu.com/ubuntu

Thursday, August 21, 2014

Best Python Tricks

https://gist.github.com/JeffPaine/6213790

Most of the examples involve making your code much faster by using iterators instead of creating copies of the data. Example: xrange

Here's the video: https://www.youtube.com/watch?v=OSGv2VnC0go

CSS Selectors - ~ + >

http://css-tricks.com/child-and-sibling-selectors/

That's an excellent article describing what angle brackets, plus signs, and tildes do in CSS selectors. The illustrations make it especially clear.

Wednesday, August 6, 2014

Wednesday, July 30, 2014

Overwriting module with same version in Heroku - Python

I needed to install a newer version of a module from a github commit, but it had the same version number. Heroku just used the cached version of the module and didn't overwrite it with the newer version.

The easiest fix for this:

  1. Create a file in your application's root directory called "runtime.txt" with only "python-3.4.1" written inside.
  2. Add, commit, and push the new runtime.txt
  3. Change runtime.txt back to "python-2.7.6"
  4. Add, commit, and push to clear your virtualenv and reinstall all modules