Skip to content

Instantly share code, notes, and snippets.

View chrismay's full-sized avatar

Chris May chrismay

  • Warwickshire, UK
View GitHub Profile
<?xml version="1.0"?>
<!--
ADOBE SYSTEMS INCORPORATED
Copyright 2005-2007 Adobe Systems Incorporated
All Rights Reserved.
NOTICE: Adobe permits you to use, modify, and distribute this file
in accordance with the terms of the license agreement accompanying it.
package com.yaymedia.openvue;
import java.util.Collections;
import java.util.List;
import com.wowza.wms.amf.AMFDataList;
import com.wowza.wms.application.IApplicationInstance;
import com.wowza.wms.client.IClient;
import com.wowza.wms.module.ModuleBase;
import com.wowza.wms.request.RequestFunction;
import com.yaymedia.openvue.domain.CompositeWhiteboardEventListener;
@chrismay
chrismay / pre-commit
Created March 14, 2011 16:10
git pre-commit hook to syntax-check files
git diff --cached --name-status | while read st file; do
# skip deleted files
if [ "$st" == 'D' ]; then continue; fi
# do a check only on the puppet files
if [[ "$file" =~ ".pp" ]]·
then
echo "syntax checking \"$file\""·
if ! puppet --confdir=/tmp --vardir=/tmp --parseonly --ignoreimport "$file"
then
echo "puppet syntax check failed for file: $file"
@chrismay
chrismay / nagios-log-to-statsd.pl
Created April 5, 2011 15:30
Crappy little perl script to extract perfdata from nagios and send it to graphite.
use Net::StatsD::Client;
use strict;
my $client = Net::StatsD::Client->new(host=>"your-statsd-host-here");
while(<>){
my ($host,$service,$perfdata) = split(/~/);
$host =~ s/\./-/g;
$service =~ s/ /_/g ;
my $prefix= "nagios." . $host . "." . $service;
@chrismay
chrismay / zfs-to-graphite
Created April 6, 2011 07:40
list the ZFS datasets on a host and send graphite data on how full each one is.
#!/opt/csw/bin/ruby
#
#
require 'socket'
def normalize_size(size)
multiples={'K' => (1024),
'M' => (1024 * 1024),
'G' => (1024 * 1024 * 1024),
'T' => (1024 * 1024 *1024 *1024)
@chrismay
chrismay / iostat_to_graphite.rb
Created April 12, 2011 16:37
send Solaris iostats to Graphite
#!/opt/csw/bin/ruby
#
# run with something like iostat -nx 10 | iostat_to_graphite.rb
#
require 'socket'
graphite_host='graphite'
graphite_port=2003
@chrismay
chrismay / gist:958645
Created May 6, 2011 08:46
cloudfront_warmer_oneline.rb
url_to_ips = cloudfront_urls.collect{|url|[url,dns_servers.collect{|server| dns.resolve(server,url.host)}.flatten]}.collect{|(url,ips)| ips.collect{|ip|
[url.to_s,ip,Net::HTTP::start(ip,80){ |http| http.get(url.path,{"Host"=>url.host}).code}]
}}.flatten(1)
def toQuadList()= {
def lrQuadsFromLine(line: List[Int], accumulator: List[List[Int]]): List[List[Int]] = {
if (line.length < 4)
accumulator
else
lrQuadsFromLine(line.tail, accumulator :+ line.slice(0, 4))
}
data.flatMap(line => lrQuadsFromLine(line, List.empty))
}
@chrismay
chrismay / Sudoku.scala
Created September 4, 2014 07:51
Sudoku solver in scala. Doesn't quite work; it repeatedly finds the same solutions instead of only finding each unique solution once.
object Sudoku extends App {
val ints = (1 to 9).toSet
val start = List(
0, 0, 0, 0, 0, 0, 0, 6, 0,
0, 0, 0, 0, 5, 3, 0, 0, 9,
5, 2, 0, 0, 0, 8, 0, 1, 0,
0, 0, 1, 0, 6, 0, 0, 2, 4,
2, 0, 0, 0, 0, 0, 0, 0, 8,
#!/usr/bin/env python
# Git clone all my gists
import json
import urllib
from subprocess import call
from urllib import urlopen
import os
USER = os.environ['USER']