Skip to content

Instantly share code, notes, and snippets.

View jshiell's full-sized avatar

Jamie Shiell jshiell

View GitHub Profile
@jshiell
jshiell / sehs
Created November 24, 2011 11:56
Scala equals/hashCode/toString Live Template
override def toString = new ToStringBuilder(this)
.toString
override def equals(obj: Any) = obj match {
case other: $CLASSNAME$ => other.getClass == getClass &&
new EqualsBuilder()
.isEquals
case _ => false
}
@jshiell
jshiell / exercise.clj
Created March 23, 2012 12:35
Clojure Exercises
; http://aperiodic.net/phil/scala/s-99/
; P01 - find the last element of a list
(defn p01 [the-list]
(if (empty? (rest the-list))
(first the-list)
(recur (rest the-list))
)
)
@jshiell
jshiell / fix_fxg.rb
Created May 18, 2012 14:22
Fix malformed FXG files
#!/usr/bin/ruby
if ARGV.length == 0
puts "Usage: #{__FILE__} <name of FXG to de-fubar>"
exit 1
end
filename = ARGV[0]
out = File.open("#{filename}.fixed", 'w')
@jshiell
jshiell / tcdump.rb
Created May 18, 2012 14:29
Get status from a TeamCity server.
require 'rubygems'
require 'nokogiri'
require 'open-uri'
def get_teamcity_status(server_host)
doc = Nokogiri::HTML(open("http://#{server_host}/externalStatus.html"))
build_count = doc.css('table.tcTable').size
failure_count = 0
fatal_count = doc.css('span.teamCityErrorMessage').size
@jshiell
jshiell / nagiosdump.rb
Created May 18, 2012 14:31
Dump status from Nagios.
require 'rubygems'
require 'nokogiri'
require 'open-uri'
def get_nagios_status(server_host, username = 'monitor', password = 'monitor')
doc = Nokogiri::HTML(open("http://#{server_host}/nagios/cgi-bin/status.cgi?servicestatustypes=28&hoststatustypes=15", :http_basic_authentication => [username, password]))
hosts = []
last_title = nil
@jshiell
jshiell / ehs.java
Created July 26, 2012 08:44
IntelliJ IDEA live template for Apache Commons Lang 3 Equals/HashCode/ToString
@Override
public boolean equals(final Object obj) {
if (obj == null) {
return false;
}
if (obj == this) {
return true;
}
if (obj.getClass() != getClass()) {
return false;
@jshiell
jshiell / Unbinder.java
Created August 6, 2012 07:31
Unbind and delete a queue from a RabbitMQ node.
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import java.io.IOException;
public class Unbinder {
public static void main(final String[] args) {
final ConnectionFactory factory = new ConnectionFactory();
@jshiell
jshiell / rabbitmq-web-stomp-https.patch
Created January 17, 2013 12:49
A patch for rabbitmq-web-stomp to allow for HTTPS connections.
diff -r 54ce482842cf src/rabbit_ws_sockjs.erl
--- a/src/rabbit_ws_sockjs.erl Tue Nov 20 13:40:31 2012 +0000
+++ b/src/rabbit_ws_sockjs.erl Thu Jan 17 12:48:54 2013 +0000
@@ -26,7 +26,13 @@
-spec init() -> ok.
init() ->
Port = get_env(port, 55674),
+ HttpsPort = get_env(http_port, 55675),
SockjsOpts = get_env(sockjs_opts, []) ++ [{logger, fun logger/3}],
+ HttpsEnabled = get_env(ssl_enabled, false),
@jshiell
jshiell / icinga-on-centos.sh
Last active February 27, 2016 16:10
Icinga on CentOS 6.4 via RPM
# These are very quick & dirty notes on getting Icinga installed on Centos 6.5 via RPMs,
# as most documentation seems to be based around source installation. It's mostly recovered from
# my history as I worked it out, so no guarantees are offered.
# Make EPEL available
sudo rpm -Uvh http://mirror.bytemark.co.uk/fedora/epel/6/i386/epel-release-6-8.noarch.rpm
# Install HTTPd
sudo yum install httpd
sudo service https start
@jshiell
jshiell / gist:e8405fe9d27b58afcb2b
Created April 9, 2015 19:06
A quick & dirty script to annotate GPX with fake time data, so you can import it into Strava.
#!/usr/bin/env ruby
require 'rexml/document'
require 'rexml/element'
doc = REXML::Document.new(File.open('London_Classic_2015.gpx', 'r'))
second = 0
min = 0
hour = 1