Skip to content

Instantly share code, notes, and snippets.

View halkeye's full-sized avatar

Gavin Mogan halkeye

View GitHub Profile
@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 / 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 / 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
import grails.converters.JSON
// Automatically generated. Make future change here.
definition(
name: "gavin_test_pushes",
namespace: "gavin",
author: "Gavin",
description: "Description goes here",
category: "Fun & Social",
@halkeye
halkeye / cloudflare_ips_nginx.sh
Last active October 5, 2016 20:00
Pull cloudflare ips for nginx
# cat /etc/nginx/conf.d/cloudflare.conf
# sh cloudflare_ips_nginx.sh > /etc/nginx/conf.d/cloudflare.conf && service nginx configtest && service nginx reload
echo "# Cloudflare"
for ip in $(curl -s https://www.cloudflare.com/ips-v4); do
echo "set_real_ip_from $ip;"
done
for ip in $(curl -s https://www.cloudflare.com/ips-v6); do
echo "set_real_ip_from $ip;"
done
@halkeye
halkeye / gist:ac60f9edde682b316449
Created November 19, 2014 08:01
Ugly attempt at mocking out static class
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
namespace UnitTestStatic
{
public class Utilities : IUtilities
{
private static IUtilities _instance = new Utilities();
private Utilities() { }
#!/usr/bin/env ruby
#
# check-supervisor-socket
#
#
# DESCRIPTION:
# Check that all supervisor processes are running using its UNIX domain socket. See unix_http_server section in
# http://supervisord.org/configuration.html.
#
# OUTPUT:
@halkeye
halkeye / main.go
Last active August 29, 2015 14:14
package main
import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
@halkeye
halkeye / Gemfile
Created February 14, 2015 07:10
Simple set of scripts to create nfo files from a bunch of youtube-dl files
source 'https://rubygems.org'
gem 'youtube_it', '2.4.0'
# parses strings such as: 07-31 09:56:08
DATESTAMP_CP [0-9]{2}-[0-9]{2} %{TIME}
# parses strings such as: '\u001b\[0m' or '^[[0m' or '\e[0m'
METACHAR_CP ((\\u001b|\^\[|\e)\[\d+m)?
# assigns regular expression that matches Java classes to a new variable name.
FACILITY_CP %{JAVACLASS}