Skip to content

Instantly share code, notes, and snippets.

View toast38coza's full-sized avatar

Christo Crampton toast38coza

View GitHub Profile
@toast38coza
toast38coza / github_repo.py
Created February 9, 2016 18:05
An Ansible module for managing github repos
#!/usr/bin/python
DOCUMENTATION = '''
---
module: github_repo
short_description: Manage your repos on Github
'''
EXAMPLES = '''
- name: Create a github Repo
@toast38coza
toast38coza / docker-cleanup.yml
Created February 8, 2016 20:46
Some commands for cleaning up after Docker
# hat-tip: http://blog.yohanliyanage.com/2015/05/docker-clean-up-after-yourself/
# cleanup docker:
docker rm -v $(docker ps -a -q -f status=exited)
docker rmi $(docker images -f "dangling=true" -q)
docker run -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/docker:/var/lib/docker --rm martin/docker-cleanup-volumes
@toast38coza
toast38coza / pre-push
Created February 5, 2016 08:26
pre-push hook. Run django tests inside docker before pushing
#!/bin/bash
docker-compose run web python manage.py test
RESULT=$?
if [ $RESULT -ne 0 ]; then
echo ""
echo ""
echo "\******************"
echo "Oh hell no!"
echo "The tests have failed. Cancelling push"
echo "------------------"
- hosts: localhost
vars:
- kong_admin_base_url: "http://api.example.com:8001"
- kong_base_url: "http://api.example.com:8000"
- kong_consumers:
- username: Jason
key: 123
tasks:
- name: Register APIs
@toast38coza
toast38coza / .travis
Last active October 30, 2015 11:03
Travis script for testing an Ansible playbook
---
language: python
python: "2.7"
env:
- SITE=test.yml
before_install:
- sudo apt-get update -qq
@toast38coza
toast38coza / pandas-snippets.py
Last active October 9, 2015 15:40
Some useful snippets for analyzing data with pandas
"""
DataFrame:
project_id hours overtime day
0 3 4 False 2015-10-07
1 3 6 False 2015-10-07
2 3 7 False 2015-10-07
3 2 5 False 2015-10-07
4 2 4 False 2015-10-07
5 1 4 False 2015-10-07
@toast38coza
toast38coza / jenkins-webhook.json
Created June 24, 2015 07:48
Creating github service webhooks with Ansible uri_module
{
"name": "jenkins",
"active": true,
"events": [
"push"
],
"config": {
"jenkins_hook_url": "http://ci.jenkins-ci.org/github-webhook/"
}
}
@toast38coza
toast38coza / commands
Last active March 3, 2022 11:30
Simple systemd unit for running a django app
# start / stop / restart / status
systemctl start test
systemctl stop test
systemctl restart test
systemctl status test
# logs use journalctl:
# tail the logs for unit `django`
journalctl -f -u django
@toast38coza
toast38coza / ansiible-cheatsheet
Created June 4, 2015 12:08
Some useful ansible commands
# Get the ansible facts
ansible -i {inventory_file} -u {username} -m setup {hostname}
@toast38coza
toast38coza / get_unique_port
Last active August 29, 2015 14:21
Given a variable `http_port` stored in redis, incr the value and return the new port
redis-cli incr http_port | cut -c1-8