Skip to content

Instantly share code, notes, and snippets.

Tomas Henriquez hassek

Block or report user

Report or block hassek

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Testing.md

Automated testing

Fixtures vs Factories

  • Anything that may be modified is not a good choice for fixtures but for factories instead
  • Fixtures hide the testing logic, don't use it for building use cases, instead use it for easing the testing process.
  • Fixtures still has some use cases to ease big data representations and objects that should never change (emails, user metrics, etc).

Saving vs not saving in the DB

I like to save everything on the DB until it becomes a problem, this avoids a

View Narrow_Region_1
python << endpython
def run_current_test(level='test', on_terminal=False):
import vim
command = "./manage.py test %"
cb = vim.current.buffer
cw = vim.current.window
original_position = vim.current.window.cursor
View .vimrc.after
set nobackup
set nowritebackup
"make the yank use the system clipboard
"set clipboard=unnamed
set tabstop=2 softtabstop=2 shiftwidth=2 textwidth=0
au BufRead,BufNewFile *.html set filetype=htmldjango
set tags+=./tags;$HOME
View .bash_profile
export PATH=/opt/local/bin:/opt/local/sbin:/usr/local/Cellar/ruby/1.9.3-p194/bin:/usr/local/share/npm/bin:$PATH
export PATH=/usr/local/bin:/usr/local/sbin:$PATH
export PYTHONPATH=${PYTHONPATH}:$HOME/gsutil/boto:$HOME/gsutil:/usr/local/Cellar/xapian/1.2.7/bin:/usr/local/Cellar/readline/6.2.2/:
export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad
if [ -f `brew --prefix`/etc/bash_completion ]; then
. `brew --prefix`/etc/bash_completion
fi
View .bash_profile
export PATH=/opt/local/bin:/opt/local/sbin:/usr/local/Cellar/ruby/1.9.3-p194/bin:/usr/local/share/npm/bin:$PATH
export PATH=/usr/local/bin:/usr/local/sbin:/usr/local/Cellar/python26/2.6.7/bin:/usr/local/Cellar/python/2.7.3/bin:/usr/local/share/python:$PATH
export PYTHONPATH=${PYTHONPATH}:$HOME/gsutil/boto:$HOME/gsutil:/usr/local/Cellar/xapian/1.2.7/bin:/usr/local/Cellar/readline/6.2.2/:
export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad
if [ -f `brew --prefix`/etc/bash_completion ]; then
. `brew --prefix`/etc/bash_completion
fi
@hassek
hassek / gist:4080169
Created Nov 15, 2012
Get rabbit enqueued tasks and if rabbit is up
View gist:4080169
def get_rabbit_status():
try:
conn = BrokerConnection(
userid=settings.BROKER_USER,
password=settings.BROKER_PASSWORD,
hostname=settings.BROKER_HOST,
port=settings.BROKER_PORT,
virtual_host=settings.BROKER_VHOST
)
conn.connect()
View wsgi.py
"""
WSGI config for fitvaina project.
This module contains the WSGI application used by Django's development server
and any production WSGI deployments. It should expose a module-level variable
named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover
this application via the ``WSGI_APPLICATION`` setting.
Usually you will have the standard Django WSGI application here, but it also
might make sense to replace the whole Django WSGI application with a custom one
@hassek
hassek / nginx.conf
Created Jul 18, 2012
nginx configuration
View nginx.conf
#user nobody;
worker_processes 1;
error_log /var/log/nginx/error.log;
#access_log /var/log/nginx/access.log;
pid /var/run/nginx.pid;
events {
worker_connections 300;
View fabfile_demo.py
#To be able to use this, please do a symbolic link into project root:
#cd yourproject
#ln -s environments/my_own_fabfile.py fabfile.py
from fabric.api import env, local, run, cd, sudo
from fabric.decorators import hosts
env.project_root = '~/WebSites/PROJECT'
#from fabric.contrib import django
env.user = "USER"
View hook.sh
#!/bin/sh
if test "$(git diff --name-only HEAD@{1} | ack '500|404|home.html|static-content')"
then
echo "running ./manage.py generatemedia to update files"
python myproject/manage.py generatemedia --nodebug
git add -A myproject/_generated_media/*
git add -A static-content/*
git commit -m "updating media (automatic update by git merge hook)"
fi
You can’t perform that action at this time.