Skip to content

Instantly share code, notes, and snippets.

Avatar

Wesley Childs mrchilds

  • Hampshire
View GitHub Profile
@mrchilds
mrchilds / gist:3150241
Created Jul 20, 2012
Mysql CSV Import
View gist:3150241
Example File
AB101AA,394251,806376,57.1482995075,-2.09663094048
Import file from command line:
$ mysqlimport -u root -p --local --fields-terminated-by=',' DATABASE FILENAME
@mrchilds
mrchilds / gist:3164367
Created Jul 23, 2012
Mysql - Add New User With Specific DB Permissions
View gist:3164367
#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:3394025
Created Aug 19, 2012
Django Unit Test - Ajax
View gist:3394025
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:3776003
Created Sep 24, 2012
Django Performance Fact Finding
View gist:3776003
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:5886088
Created Jun 28, 2013
Puppet - Templates - Join list
View gist:5886088
# Useful when creating lists in config files...
<%= my_list.join(',') %>
View gist:5957577
# 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..."
View gist:6523737
from django.core.cache import cache
cache_key = 'CM:recent-jobs'
cache.delete(cache_key)
@mrchilds
mrchilds / gist:6573907
Last active Dec 23, 2015
Simple Fabric Script
View gist:6573907
# 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:6573925
Created Sep 15, 2013
Simple hubot plugin
View gist:6573925
# 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:6573934
Created Sep 15, 2013
Example Supervisor Config
View gist:6573934
[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"
You can’t perform that action at this time.