Skip to content

Instantly share code, notes, and snippets.

View affix's full-sized avatar
:shipit:
Code never lies, Comments might though

Keiran Smith affix

:shipit:
Code never lies, Comments might though
View GitHub Profile
@affix
affix / OpenShift Origin Puppet Deploy
Created March 14, 2014 17:00
Deploy a Broker/Node with Puppet
class { 'openshift_origin' :
roles => ['broker','named','activemq','datastore','node'],
broker_hostname => 'broker.',
node_hostname => 'broker.',
named_hostname => 'broker.',
datastore_hostname => 'broker.',
activemq_hostname => 'broker.',
bind_key => 'YOUR_KEY',
@affix
affix / blocksync.py
Last active August 29, 2015 14:14 — forked from rcoup/blocksync.py
#!/usr/bin/env python
"""
Synchronise block devices over the network
Copyright 2006-2008 Justin Azoff <justin@bouncybouncy.net>
Copyright 2011 Robert Coup <robert@coup.net.nz>
License: GPL
Getting started:

Keybase proof

I hereby claim:

  • I am Affix on github.
  • I am affix (https://keybase.io/affix) on keybase.
  • I have a public key whose fingerprint is B143 C0B3 D2C8 158D 0DFF 7CB0 3DF1 24CD EDE8 E0CA

To claim this, I am signing this object:

@affix
affix / autoblock-twitter.py
Created November 25, 2012 14:56
Auto Block Twitter mentions who you do not follow
#!/usr/bin/env python
# autoblock-twitter.py
# Automatically block twitter users who mention you in a tweet that you do not follow.
# I wrote this as my user is @cli and I was constantly getting unrelated spam mentions
# License : GPLv2+
# Author : Keiran "Affix" Smith <Affix_AT_affix_DOT_me>
import tweepy
consumer_key=""
@affix
affix / latlondistance.rb
Created November 10, 2015 03:03
Calculate the distance between two GPS Co-Ordinates with Ruby
def distance_between(lat1,lon1,lat2,lon2, miles=false)
r = 6371; # Kilometers
dLat = to_radian(lat2-lat1);
dLon = to_radian(lon2-lon1);
lat1 = to_radian(lat1);
lat2 = to_radian(lat2);
a = Math.sin(dLat/2) * Math.sin(dLat/2) +
Math.sin(dLon/2) * Math.sin(dLon/2) * Math.cos(lat1) * Math.cos(lat2);
@affix
affix / osx-10.11-setup.md
Created November 20, 2015 17:26 — forked from jrgcubano/osx-10.11-setup.md
Mac OS X 10.11 El Capitan Setup

Mac OS X 10.11 El Capitan

Custom recipe to get OS X 10.11 El Capitan running from scratch, setup applications and developer environment. This is very similar (and currently mostly the same) as my 10.10 Yosemite setup recipe (as found on this gist https://gist.github.com/kevinelliott/0726211d17020a6abc1f). Note that I expect this to change significantly as I install El Capitan several times.

I use this gist to keep track of the important software and steps required to have a functioning system after a semi-annual fresh install. On average, I reinstall each computer from scratch every 6 months, and I do not perform upgrades between distros.

This keeps the system performing at top speeds, clean of trojans, spyware, and ensures that I maintain good organizational practices for my content and backups. I highly recommend this.

You are encouraged to fork this and modify it to your heart's content to match your own needs.

<?php
/**
* @copyright 2012 TheHydroImpulse, Daniel Fagnan
* @version 0.1
* @todo Add an overwite ability. Among other things.
* @note Use this as you wish. Extend it, Mash it. Enjoy it.
*/
server {
listen 80;
server_name www.example.com;
root /var/www/vhosts/example.com/public/;
location /
{
index index.php index.html index.htm;
}
@affix
affix / dumpit.py
Last active December 30, 2015 23:59
dumpit.py a python alternative to mysqldump. I wrote this after an innodb corruption and mysqdump kept crashing for me. This seemed to export all the data correctly although a little slower. It seems to be more fault tollerant.
#!/usr/bin/env python
#
# dumpit.py
# An Alternative to mysqldump written in Python
# Requires MySQLdb Python Module.
#
# Author : Keiran 'Affix' Smith
# Email : affix@affix.me
# Web : http://affix.me
# Copyright 2013 Keiran Smith
public function DistAB($lata, $lona, $latb, $lonb)
{
$delta_lat = $latb - $lata ;
$delta_lon = $lonb - $lona ;
$earth_radius = 6372.795477598;
$alpha = $delta_lat/2;
$beta = $delta_lon/2;
$a = sin(deg2rad($alpha)) * sin(deg2rad($alpha)) + cos(deg2rad($lata)) * cos(deg2rad($latb)) * sin(deg2rad($beta)) * sin(deg2rad($beta)) ;