Skip to content

Instantly share code, notes, and snippets.

View halkeye's full-sized avatar

Gavin Mogan halkeye

View GitHub Profile
@halkeye
halkeye / production.rb
Created June 7, 2014 05:05
For production Capistrano deploys, we can't use our own internal git server because the one off amazon box doesn't have access to the internal network. Hacked in a solution to create a port forward to talk back to our network. Works in this case so sharing.
require 'net/ssh'
#set :ssh_options, :verbose => :debug
set :user, 'labuser'
set :repo_url, "ssh://eti@localhost:9000/#{fetch(:application)}.git"
$gateway_ssh = {}
namespace :ssh do
task :git_start do
on roles(:all) do
hostname = host.hostname.to_s
@halkeye
halkeye / production.rb
Created January 25, 2014 00:08
For production Capistrano deploys, we can't use our own internal git server because the one off amazon box doesn't have access to the internal network. Hacked in a solution to create a port forward to talk back to our network. Works in this case so sharing.
set :repo_url, "ssh://git@localhost:9000/#{fetch(:application)}.git"
module SSHKit; module Backend
class Netssh < Printer
alias_method :orig_ssh, :ssh
def ssh
ret = orig_ssh
@@created_remote ||= ret.forward.remote(22, 'gitserver', 9000)
return ret
end
@halkeye
halkeye / unittest.pl
Created October 4, 2013 22:10
Ugly code for generating random word and random character for a unittest
sub rw { my $word = "$_[0]"; $word =~ s/(.)/rc($1)/ge; $word;}
sub rc { return ((rand(1)*2+1)%2) ? lc($_[0]): uc($_[0]); }
@halkeye
halkeye / beep.sh
Created October 2, 2013 19:08
Very simple little script I use inside of screen/tmux window to notify me of output
#!/usr/bin/env perl
print "$_\007" while (<>);
@halkeye
halkeye / updateWPPlugin.py
Last active December 21, 2015 09:49
Simple little script I use to update wordpress plugins
#!/usr/bin/env python
# Simple little script I use to update wordpress plugins
# Author: Gavin Mogan <[email protected]>
#
# Usage:
# for i in ~/wp-plugins/*; do svn sw $(updateWPPlugin $i) $i; done
# Changelog:
# Ignore any tag that has characters other than 0-9 and .
# This usually means that its a beta tag
#!/bin/sh
rm /etc/udev/rules.d/70-persistent-net.rules
cd /etc/sysconfig/network-scripts/
TMP=`mktemp`
TEST=`ifconfig | grep eth | awk '{ print $5}'`; sed "s/HWADDR.*/HWADDR\=$TEST/g" ifcfg-eth0 > $TMP; mv $TMP ifcfg-eth0
#!/bin/bash
DRY_RUN=
DATABASE=
cd /tmp/
mysqldump --skip-dump-date --opt --flush-logs --single-transaction ${DATABASE} bzcat -zc > ${DATABASE}.sql.bz2
for i in `seq 5 -1 2`; do
PREV_I=$(expr $i - 1)
<?php
require 'facebook-php-sdk/src/facebook.php';
ini_set('display_errors', true);
require '/home/halkeye/git/rob_facebook_poster/config.php';
/* FIXME - put your stuff here */
$facebook = new Facebook(array(
'appId' => $config['FACEBOOK_APP_ID'],
'secret' => $config['FACEBOOK_APP_SECRET'],
));
@halkeye
halkeye / transmissionStats.rb
Created November 29, 2012 05:10
transmission stats collectd
#!/usr/bin/env ruby
#
# Written by Gavin Mogan ([email protected])
require 'rubygems'
require 'transmission-rpc'
# Enable auto flush
STDOUT.sync = true
@halkeye
halkeye / xbmcStats.rb
Created November 29, 2012 03:33 — forked from anonymous/file1.txt
XBMC collectd stats collection
#!/usr/bin/env ruby
#
# Written by Gavin Mogan ([email protected])
require 'rubygems'
require 'mysql2'
# Enable auto flush
STDOUT.sync = true