Skip to content

Instantly share code, notes, and snippets.

View mattman's full-sized avatar

Matt Didcoe mattman

View GitHub Profile
@mattman
mattman / WAPOL-crimescaper.rb
Last active December 17, 2015 08:59
A Ruby script that makes use of the power of Selenium to drive a search of the WA Police Crime Statistics search page and returns a JSON structure of the crime statistics. To make headless use: https://github.com/leonid-shevtsov/headless (it's a five second process - follow the instructions in the headless `README` file) To output to a CSV: Use …
#!/usr/local/bin/ruby
# Selenium script to scrape the WA Police Crime Statistics search
# Author: Matt Didcoe <matt@mattdidcoe.com>
# Last Modified: 2013-05-16 18:39
# Input: CSV file of ABS suburbs
# Output: JSON of ABS Suburb Code, Suburb Name and year summary statistics
require 'rubygems'
require 'logger'
require 'csv'
My traceroute [v0.75]
ruby-2.local (0.0.0.0) Sun Nov 1 11:35:56 2009
Change Packet Size: 0
Size Range: 28-4470, < 0:random.
Host Loss% Snt Last Avg Best Wrst StDev
1. <<my router>> 0.0% 64 1.7 3.9 0.8 19.7 4.6
2. lo1.l1-45sgt-7206-e.wa.amnet.net.au 0.0% 63 6.9 11.7 6.7 45.1 7.6
3. rahrahree.amnet.net.au 0.0% 63 9.3 18.6 6.4 200.7 31.9
4. ge1-1.br01.wa.amcom.net.au 0.0% 63 8.7 19.2 6.5 126.8 28.8
5. aarnet.ix.waia.asn.au 0.0% 63 7.3 12.6 6.4 62.2 9.4
require 'httparty'
class SMS
include HTTParty
def self.send(game, player)
if !player.mobile.nil?
message = "Hey #{player.name_first},\nYour game for today has changed! Details are\n Time: #{game.played_at.strftime("%H:%M")}\n Venue:#{game.venue.loc_name}"
message = CGI::escape(message)
url = "http://sms.didcoe.id.au/sendto/#{api}/#{player.mobile}/#{message}"
res = get(url)
@mattman
mattman / README
Created June 16, 2009 09:33 — forked from ocean/README
The below Sinatra code works with URLs like:
/c/blahblah
and
/c/http://blah.com/something.php
or
/c/google.com
class LegacyBase < ActiveRecord::Base
establish_connection(
:adapter => "mysql",
:host => "localhost",
:username => "",
:password => "",
:database => "ws_prosecutions"
)
end
/**
* Write a description of class TextAnalyser here.
*
* @author Matt Didcoe
* @version 0.1
*/
import java.lang.*;
import java.util.*;
public class TextAnalyser {
#!/bin/sh
# cd into matching gem directory ("cd -" friendly)
cdgem() {
local gempath=$(gem env gemdir)/gems
if [[ $1 == "" ]]; then
cd $gempath
return
fi
@mattman
mattman / gist:87359
Created March 29, 2009 11:21
.bashrc
# -----------
# General
# -----------
alias ..='cd ..'
alias ll='ls -lh'
alias la='ls -la'
alias ps='ps -ax'
alias du='du -hc'
alias cd..='cd ..'
alias today='date +"%A, %B %d, %Y"'
@mattman
mattman / gist:87080
Created March 28, 2009 10:33
daylight saving crossover fail
>> Chronic.parse("noon")..Chronic.parse("noon tomorrow")
=> Sat Mar 28 12:00:00 0900 2009..Sun Mar 29 11:00:00 0800 2009
>> Chronic.parse("noon")..Chronic.parse("one oclock tomorrow")
=> Sat Mar 28 12:00:00 0900 2009..Sun Mar 29 12:00:00 0800 2009