Skip to content

Instantly share code, notes, and snippets.

View mrchilds's full-sized avatar

Wesley Childs mrchilds

View GitHub Profile
@mrchilds
mrchilds / gist:6573934
Created September 15, 2013 20:02
Example Supervisor Config
[program:hubot]
command=/srv/hubot/bin/hubot --adapter hipchat
user=hubot
autostart=true
autorestart=true
directory=/srv/hubot/
environment=HUBOT_AUTH_ADMIN="XYZ",HUBOT_HIPCHAT_PASSWORD="XYZ",HUBOT_HIPCHAT_TOKEN="XYZ",HUBOT_HIPCHAT_JID="XYZ",HUBOT_HIPCHAT_ROOMS="ROOMS"
@mrchilds
mrchilds / gist:6573925
Created September 15, 2013 20:01
Simple hubot plugin
# Description:
# Deploy branches to staging.
#
# Commands:
# hubot deploy <branch> to <environment>
# hubot show branches
{spawn, exec} = require 'child_process'
module.exports = (robot) ->
@mrchilds
mrchilds / gist:6573907
Last active December 23, 2015 03:29
Simple Fabric Script
# Deploy branch to staging
from fabric.api import cd, env, parallel, run, task
from fabric.decorators import roles
# Define your servers
env.roledefs = {
'staging-web-servers': ['s-web-01.example.com',
's-web-03.example.com',
's-web-03.example.com'],
@mrchilds
mrchilds / gist:6523737
Created September 11, 2013 13:37
Clear
from django.core.cache import cache
cache_key = 'CM:recent-jobs'
cache.delete(cache_key)
# Using conf.py (currently in master)
# Jenkins config...
# Wes Code (e.g. before any help)
#!/bin/bash
source /home/ubuntu/production/bin/activate
cd /srv/
echo "Generating 'doc' folder..."
@mrchilds
mrchilds / gist:5886088
Created June 28, 2013 16:39
Puppet - Templates - Join list
# Useful when creating lists in config files...
<%= my_list.join(',') %>
@mrchilds
mrchilds / gist:3776003
Created September 24, 2012 13:40
Django Performance Fact Finding
Very quick way to get some timing info...
import time
class Timer():
def __enter__(self): self.start = time.time()
def __exit__(self, *args): print time.time() - self.start
with Timer():
some_code()
@mrchilds
mrchilds / gist:3394025
Created August 19, 2012 09:50
Django Unit Test - Ajax
from django.utils import simplejson
#Go to a url
response = self.client.get(self.url)
foobar = simplejson.loads(response.content)
print foorbar['item']
@mrchilds
mrchilds / gist:3164367
Created July 23, 2012 15:56
Mysql - Add New User With Specific DB Permissions
#Connect to mysql command line...
$ mysql -u root -p
#Create user
$ create user USERNAME;
#Assign Permissions
$ grant PERMISSIONS on DATABASE.* to 'USERNAME'@'localhost' identified by 'PASSWORD';
@mrchilds
mrchilds / gist:3150241
Created July 20, 2012 11:25
Mysql CSV Import
Example File
AB101AA,394251,806376,57.1482995075,-2.09663094048
Import file from command line:
$ mysqlimport -u root -p --local --fields-terminated-by=',' DATABASE FILENAME