Skip to content

Instantly share code, notes, and snippets.

@powellc
powellc / gogs.conf
Created October 28, 2014 14:29
Gogs Upstart Script
#
# upstart script for gogs (Go Git Service)
#
author "tsv"
description "gogs upstart script"
start on (local-filesystems and net-device-up)
stop on shutdown
@powellc
powellc / fabfile.py
Created February 1, 2010 00:22 — forked from heckj/fabfile.py
Forked for my own vps info.
#!/usr/bin/env python
from __future__ import with_statement # needed for python 2.5
from fabric.api import *
from fabric.contrib.console import confirm
# ================================================================
# NOTE:
# using this fabfile expects that you have the python utility
# fabric installed locally, ssh access to reamea.com, and your
# ssh public key associated with the account 'mboza@reamea.com'
#!/bin/bash
# The purpose of this file is to, as quickly as possible, set up a home directory
# with all the creature comforts I expect.
#
# For this to work:
# 1. Add ssh keys to github and personal git repo
# 2. sudo aptitude install zsh git-core
mkdir $HOME/.virtualenvs
# terminfo and termcap for nice 256 color terminal
# allow bold colors - necessary for some reason
attrcolor b ".I"
# tell screen how to set colors. AB = background, AF=foreground
termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'
# erase background with current bg color
defbce "on"
@powellc
powellc / .zshrc
Created September 15, 2010 16:33
export TERM=xterm-256color
# Default the box color to red, but change to differentiate boxes or VPSs
export BOXCOLOR="%{$fg[red]%}"
# Path to your oh-my-zsh configuration.
export ZSH=$HOME/.oh-my-zsh
# Set to the name theme to load.
# Look in ~/.oh-my-zsh/themes/
#!/bin/bash
###
### This script simply parses ifconfig and loads a box's main IP into a shell variable
###
OS=`uname`
IP="" # store IP
case $OS in
Linux) IP=`ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}' | grep 24 `;;
diff --git a/src/adzone/managers.py b/src/adzone/managers.py
index 347e85e..271e36d 100644
--- a/src/adzone/managers.py
+++ b/src/adzone/managers.py
@@ -8,8 +8,15 @@ class AdManager(models.Manager):
Returns a random advert that belongs to the specified category and zone
"""
- try:
- ad = self.get_query_set().filter(category__slug=ad_category, zone__slug=ad_zone).order_by('?')[0]
@powellc
powellc / run.py
Created March 7, 2011 20:21
A development script to run django with gevent instead of flup
#!/usr/bin/python
import sys
sys.path.append('<path_to_virtualenv>')
from gevent import monkey; monkey.patch_all()
from gevent.wsgi import WSGIServer
import os
import traceback
from django.core.handlers.wsgi import WSGIHandler
from django.core.management import call_command
@powellc
powellc / gist:de1b1a73cf814b16e39f
Created October 5, 2015 15:20
Toggl-Button-Todoist
// ==UserScript==
// @name Toggl-Button GitHub
// @namespace https://github.com/jurgenhaas/toggl-button-greasemonkey
// @version 1.3
// @include http*://github.com/*
// @grant GM_xmlhttpRequest
// @grant GM_addStyle
// @grant GM_getResourceText
// @grant GM_getValue
// @grant GM_setValue
@powellc
powellc / msql_backup_all.sh
Last active December 11, 2015 17:08
MySQL backup script for nightly dumps that clean up after a certain number of days and keep a symlink to the latest one so you can easily setup a webserver to provide dumps for development purposes
#!/bin/bash
DB_BACKUP="/var/backups/databases/"
LATEST_DIR="/var/backups/databases/latest/"
DB_USER="root"
DB_PASSWD="secretttt"
HN=`hostname | awk -F. '{print $1}'`
# Remove backups older than 10 days