Skip to content

Instantly share code, notes, and snippets.

@rob-murray
rob-murray / mr-c-twitter-data.rb
Created September 17, 2012 18:46
basic script to scrape twitter for tweets specific to custom filter
require "twitter"
require "logger"
require "csv"
require "geocoder"
# Need to get:
# all mr_c posts
# if is reply to then who mr_c replied to
# from that who can then work out where
@rob-murray
rob-murray / load_oslocator.sql
Created September 29, 2012 10:35
Simple SQL script to load os locator data into MySQL
delimiter $$
DROP TABLE IF EXISTS OSDATA.locator;
CREATE TABLE OSDATA.locator (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`classification` varchar(45) NOT NULL,
`centx` int(11) NOT NULL DEFAULT '0',
`centy` int(11) NOT NULL DEFAULT '0',
@rob-murray
rob-murray / yahoo_climacon_code.rb
Last active October 13, 2015 01:57
Simple class to return the climacon character for the yahoo weather api code
#
# Simple map to return the character required for correct
# climacon based on yahoo weather code.
# https://gist.github.com/rob-murray/4120977
#
# @params {integer} the Yahoo weather code ID
# @returns {string} the Climacon character
#
# @see http://adamwhitcroft.com/climacons/font/,
# https://developer.yahoo.com/weather/documentation.html#codes
(function() {
// create global namespace
window.game = {};
// add some data
game.player = {
name: 'rob',
score: 5
};
@rob-murray
rob-murray / Unused_Printer_Drivers.vbs
Last active December 10, 2015 18:38
VBScript to interrogate WMI to collect the current attached printers, printer drivers installed and list the unused drivers. So that they can be removed if necessary in the knowledge that no queues will be affected.
'================================
'
' VBScript Source File -- Created with SAPIEN Technologies PrimalScript 3.0
'
' NAME: Unused_Printer_Drivers.vbs
'
' AUTHOR: Robert Murray
' DATE : 20/10/2008
' SEE: http://robertomurray.co.uk/blog/2008/how-to-list-all-unused-printer-drivers-on-a-print-server-using-vbscript/
'
@rob-murray
rob-murray / openlayers-wms-os_openspace-Example
Created January 7, 2013 17:22
Example usage of https://github.com/rob-murray/openlayers-wms-os_openspace -- A new Openlayers WMS Layer for using Ordnance Survey Openspace map tiles
<script type="text/javascript">
var map, layer;
var key = "YOUR_KEY";
var e = 437303;
var n = 115542;
var zoom = 5;
function init(){
@rob-murray
rob-murray / ui-message-queue-example.js
Last active December 10, 2015 20:08
ui-message-queue AKA User Message Queue Javascript implementation
var options, myQ;
var TEN_SECS = 10000;
// Set up options
options = {
outputElementId: "output-id",
delay: TIME_IN_MSECS,
emptyDisplayString: "STRING"
};
@rob-murray
rob-murray / ror-example.rb
Created January 8, 2013 17:29
Example of Ruby on Rails to get dataset and return to view
@travels = Travels.all(:order => "id DESC")
respond_to do |format|
format.html # index.html.erb
format.json { render :json => @travels }
end
@rob-murray
rob-murray / select-next-ip.sql
Created January 8, 2013 17:31
Select the next available IP address using Postgres inet and cidr types
SELECT sub.ip FROM
(SELECT set_masklen(((generate_series(1,
(2 ^ (32 - masklen('10.10.100.0/24'::cidr)))::integer - 2) +
'10.10.100.0/24'::cidr)::inet), 32) as ip) AS sub
WHERE sub.ip NOT IN
(SELECT ip_address from ip_table)
AND sub.ip > set_masklen('10.10.100.0/24', 32)+10
AND sub.ip < set_masklen(broadcast('10.10.100.0/24')::inet, 32)-5;
@rob-murray
rob-murray / create-next-ip-function.sql
Created January 8, 2013 17:33
Create a Postgres function to return the next IP address using inet and cidr types
CREATE FUNCTION nextips_for(cidr) RETURNS SETOF inet AS
$$
SELECT sub.ip FROM (SELECT set_masklen(((generate_series(1, (2 ^ (32 -
masklen($1::cidr)))::integer - 2) +
$1::cidr)::inet), 32) as ip) AS sub
WHERE sub.ip NOT IN
(SELECT ip_address from ip_table)
AND sub.ip &gt; set_masklen($1, 32)+10
AND sub.ip &lt; set_masklen(broadcast($1)::inet, 32)-5;
$$ LANGUAGE SQL STABLE STRICT;