Skip to content

Instantly share code, notes, and snippets.

View rcoup's full-sized avatar

Robert Coup rcoup

View GitHub Profile
@rcoup
rcoup / aws_usage.py
Created June 1, 2010 21:46
A script to query the Amazon Web Services (S3/EC2/etc) usage reports programmatically.
#!/usr/bin/env python
"""
A script to query the Amazon Web Services usage reports programmatically.
Ideally this wouldn't exist, and Amazon would provide an API we can use
instead, but hey - that's life.
Basically takes your AWS account username and password, logs into the
website as you, and grabs the data out. Always gets the 'All Usage Types'
To generate
<RasterSymbolizer>
<RasterColorizer default-mode="linear" default-color="white" epsilon="0.001">
<stop color="blue" value = "-1000" />
<stop color="red" value = "-500" mode = "discrete" />
<stop color="yellow" value = "0" />
<stop value = "5" />
<stop color="red" value = "10" />
<stop color="green" value = "15" />
@rcoup
rcoup / blocksync.py
Last active May 8, 2024 09:30
Block device sync between remote hosts. Based off http://www.bouncybouncy.net/programs/blocksync.py
#!/usr/bin/env python
"""
Synchronise block devices over the network
Copyright 2006-2008 Justin Azoff <justin@bouncybouncy.net>
Copyright 2011 Robert Coup <robert@coup.net.nz>
License: GPL
Getting started:
@rcoup
rcoup / gdal_retile.py.diff
Created March 26, 2012 20:23
gdal_retile parallel experiment
--- swig/python/scripts/gdal_retile.py 2011-11-30 14:28:34.528230721 +1300
+++ swig/python/scripts/gdal_retile.py 2011-12-02 14:25:54.106882681 +1300
@@ -44,6 +44,32 @@
import os
import math
+from Queue import Queue
+
+class DummyPool(object):
+ def __init__(self, *args, **kwargs):
@rcoup
rcoup / nickserv_auth.diff
Created April 15, 2012 23:11
Patch for nagircbot 0.0.33 to support NickServ authentication
--- orig/nagircbot-0.0.33/anna.cpp 2011-01-18 23:39:10.000000000 +1300
+++ anna.cpp 2012-04-16 10:49:13.080360702 +1200
@@ -50,6 +50,7 @@
char *nick = "nagircbot";
char *user = "nagircbot";
char *password = NULL;
+char *nickserv_password = NULL;
int one_line = 1;
char *username = "Nagios IRC Bot " VERSION ", (C) www.vanheusden.com"; /* complete username */
int verbose = 255; /* default is log everything */
@rcoup
rcoup / strip-utf8-bom.vbs
Created April 26, 2012 00:50
WScript to strip UTF-8 BOM from a text/CSV file
' Usage: strip-utf8-bom.vbs file.csv
' Notes:
' this isn't suitable for large files unless you have a lot of memory - ADODB.Stream reads the entire file into
' memory, then builds the output buffer in memory as well. #stupid
If WScript.Arguments.Count <> 1 Then
WScript.Echo "Usage: strip-utf8-bom.vbs file.csv"
WScript.Quit
End If
@rcoup
rcoup / nearblack-parallel.sh
Last active October 6, 2015 21:48
Parallel version of GDAL's nearblack tool for stripping black/white borders from images.
#!/bin/bash
USAGE="Runs GDAL nearblack utility over files in a directory tree in parallel.
Usage: $0 SOURCE/ DEST/ [nearblack options]
Recommended/default nearblack options:
-setalpha -white -nb 0 -near 0 -of GTiff -co COMPRESS=DEFLATE -co TILED=YES
See more details on nearblack at: http://www.gdal.org/nearblack.html
@rcoup
rcoup / ephemeral-setup.sh
Created August 7, 2012 22:49 — forked from alq666/bootstrap.sh
Raid0 bootstrap for ephemeral EC2 disks
# On EC2, /mnt is usually already on
mounted=$(mount | grep /mnt | wc -l)
if [ $mounted -eq 1 ]; then
umount -l /mnt
fi
# Install mdadm and xfsprogs unattended
DEBIAN_FRONTEND=noninteractive apt-get -y install mdadm xfsprogs
# Create a RAID0 volume with 256KiB stripes, ignore what's already on the device
@rcoup
rcoup / loggly.py
Created September 12, 2012 02:17
Loggly CLI interface - standalone (Just Python). Pages results automatically so you can easily grab >2000 rows.
#!/usr/bin/env python
"""
Loggly CLI interface - standalone (Just Python). Deals with paging results automatically so you can easily grab >2000 rows.
Run `loggly.py --help` to see usage information.
TODO:
* Support XML format results (ie. combining multiple pages of results together)
* Facet support
@rcoup
rcoup / test1-fd.xml
Created October 1, 2012 19:41
ESRI FileGDB/FGDB API - Null/Empty Geometries Test
<esri:DataElement xsi:type='esri:DEFeatureDataset' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xs='http://www.w3.org/2001/XMLSchema' xmlns:esri='http://www.esri.com/schemas/ArcGIS/10.1'>
<CatalogPath>\test1</CatalogPath>
<Name>test1</Name>
<ChildrenExpanded>false</ChildrenExpanded>
<DatasetType>esriDTFeatureDataset</DatasetType>
<Versioned>false</Versioned>
<CanVersion>false</CanVersion>
<Extent xsi:nil="true"/>
<SpatialReference xsi:type='esri:ProjectedCoordinateSystem'>
<WKT>PROJCS["WGS_1984_UTM_Zone_20N",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",-63.0],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0],AUTHORITY["EPSG",32620]]</WKT>