Skip to content

Instantly share code, notes, and snippets.

View johanmeiring's full-sized avatar

Johan Meiring johanmeiring

View GitHub Profile
@johanmeiring
johanmeiring / gist:935dc22ba8224184095824f9c7c80257
Created April 6, 2016 20:29
Ansible on Windows via Vagrant
vagrant init withinboredom/Trusty64
vagrant ssh
sudo apt-get update
sudo apt-get install -y language-pack-en git python-dev python-pip libkrb5-dev
sudo locale-gen en_US.UTF-8
cd /home/vagrant && git clone git://github.com/ansible/ansible.git --recursive
sudo pip install paramiko PyYAML Jinja2 httplib2 six "pywinrm>=0.1.1" kerberos
echo "source /home/vagrant/ansible/hacking/env-setup" >> /home/vagrant/.bashrc
@johanmeiring
johanmeiring / build-vms.sh
Created February 9, 2015 06:15
VirtualBox Ubuntu VM creation from command line
#!/bin/bash
# Example file line:
# VM name,Group,MAC Address,RAM,Procs,HDD,VRDP port
# sf-mc-01,Group,080027EF99DD,512,1,6000,9007
if [[ ! -e $1 ]]; then
echo "File $1 not found."
exit 1
fi
@johanmeiring
johanmeiring / photototo.py
Last active August 29, 2015 14:06
Walk through dir, collect JPGs, copy to destination with timestamp as name, with duplicate detection.
import exifread
import os
import re
import shutil
in_dir = "path"
out_dir = "path"
clean = False

Keybase proof

I hereby claim:

  • I am johanmeiring on github.
  • I am johanmeiring (https://keybase.io/johanmeiring) on keybase.
  • I have a public key whose fingerprint is 5572 17A5 BD5B 42C9 71B0 D40F A5CA 6E4F CBA6 3188

To claim this, I am signing this object:

@johanmeiring
johanmeiring / models.py
Created September 16, 2013 14:22
Basic Custom User Model for Django 1.5
from django.db import models
from django.utils import timezone
from django.contrib.auth.models import BaseUserManager, AbstractBaseUser, PermissionsMixin
class UserManager(BaseUserManager):
def create_user(self, email, first_name, surname, password=None):
if not email:
raise ValueError('Users must have an email address')
@johanmeiring
johanmeiring / pingsubnet.sh
Created August 8, 2013 08:28
Ping a subnet and record reachable IPs in a file.
#!/bin/bash
COUNTER=1
rm ips
while [[ $COUNTER -lt 255 ]]; do
ping 192.168.254.$COUNTER -c 1 -W 1 && echo "192.168.254.$COUNTER" >> ips
COUNTER=$(( $COUNTER + 1 ))
done
@johanmeiring
johanmeiring / migrate_all.sh
Created March 12, 2013 08:33
Basic bash script to create migrations for all apps in a Django project. File to be placed in the root directory of the project. Requires South.
#!/bin/bash
for file in $(\
find . -maxdepth 1 -type d | \
egrep -v "\.$" | \
sed -r 's/\.\///'); do
python manage.py schemamigration $file --auto
done
exit 0
@johanmeiring
johanmeiring / gist:3952290
Created October 25, 2012 12:23
Backup file rotation
#!/bin/bash
DEST=/root/BACKUPS
# Code to actually create backup files goes here...
# Check if we need to rotate the backup files.
FC=`ls ${DEST}/*.tar | wc -l`
if [[ $FC -gt 6 ]]; then
echo "Too many backup files. Deleting oldest one..."
DELETE_FILE=`ls -tr ${DEST}/*.tar | head -1`
@johanmeiring
johanmeiring / checkreplication.sh
Created July 3, 2012 09:06
MySQL Replication Status Checker
#!/bin/bash
# MySQL Replication Status Checker
# This script will run the SHOW SLAVE STATUS query on the specified server, and then report it if Last_IO_Errno or Last_SQL_Errno do not equal 0.
# Most effective when used as a cron job that runs once every minute.
# Version 0.1
# DB Info
DBHOST=localhost
USERNAME=root
PASSWORD=lolololol
@johanmeiring
johanmeiring / gist:3002458
Created June 27, 2012 08:32
"git lg" alias for pretty git log
# From http://garmoncheg.blogspot.com/2012/06/pretty-git-log.html
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --"