Skip to content

Instantly share code, notes, and snippets.

@bjdixon
bjdixon / .vimrc
Last active August 29, 2015 13:56
Vim config
set autoindent
filetype indent on
filetype on
:set nu
syntax on
set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab
set smarttab
@bjdixon
bjdixon / scipy-install
Created February 21, 2014 04:07
Install SciPy stack on ubuntu/debian
sudo apt-get install python-numpy python-scipy python-matplotlib ipython ipython-notebook python-pandas python-sympy python-nose
@bjdixon
bjdixon / TouchpadOff
Created March 6, 2014 05:32
Touchpad on/off (ubuntu on lenovo carbon)
synclient TouchpadOff=2
synclient TouchpadOff=1
@bjdixon
bjdixon / bootstrap-equal-height-columns
Created April 2, 2014 16:44
bootstrap equal height columns
.row {
display: table;
}
[class*="col-"] {
float: none;
display: table-cell;
vertical-align: top;
}
@bjdixon
bjdixon / .gitignore
Created April 6, 2014 05:04
.gitignore for python
__pycache__
*.py[cod]
*.py~
@bjdixon
bjdixon / Beautiful-Idiomatic-Python
Last active August 29, 2015 13:58
Beautiful, Idiomatic Python or Don't do this, do this - Raymond Hettinger presentation (pycon 2013)
Replace traditional index manipulation with Python’s core looping idioms.
Learn advanced techniques with for-else clauses and the two argument form of iter().
Clarify function calls with keyword arguments.
Tuple packing and unpacking
Don’t under‐estimate the advantages of updating state variables at the same time. It eliminates an entire class of errors due to out­of-order updates. It allows high level thinking: “chunking”.
Decorators and Context Managers
Helps separate business logic from administrative logic. Clean, beautiful tools for factoring code and improving code reuse. Good naming is essential.
@bjdixon
bjdixon / fabfile.py
Created April 21, 2014 15:58
fabfile for deployment. (fab fabfile.py deploy:host=name.of.server.com)
from fabric.contrib.files import append, exists, sed
from fabric.api import env, local, run
from os import path
import random
REPO_URL = 'https://github.com/username/repo.git'
SITES_FOLDER = '/home/username/sites/'
PROJECT_NAME = 'projectName'
def deploy():
@bjdixon
bjdixon / create_mysql_db
Last active August 29, 2015 14:01
create mysql database with owner for django
$ mysql -h host -u user -p
mysql> CREATE DATABASE dbname;
mysql> USE dbname
mysql> GRANT USAGE ON *.* TO dbuser@localhost IDENTIFIED BY 'password';
mysql> GRANT ALL PRIVILEGES ON dbname.* TO 'dbuser'@'localhost';
mysql> quit
@bjdixon
bjdixon / create_funfactory_project
Created May 11, 2014 06:38
Create a funfactory project called blog
$ virtualenv venv
$ source venv/bin/activate
$ pip install funfactory
$ funfactory --python=2.7 --pkg=blog
create mysql database
add to blog/settings/local.py
@bjdixon
bjdixon / git_init
Created May 16, 2014 17:40
Init git and push to github
$ git init
$ git add .
$ git commit -m "initial commit"
$ git remote add origin git@github.com:bjdixon/project_name.git
$ git push -u origin master