Skip to content

Instantly share code, notes, and snippets.

View anthonysterling's full-sized avatar
:octocat:
Working on GitHub Actions

Anthony Sterling anthonysterling

:octocat:
Working on GitHub Actions
View GitHub Profile
<?php
/**
* Iterates over a CSV file using the first
* row (column names) as the array keys for
* each subsequent entry returned
*/
class AssociativeCsvFileIterator extends FilterIterator
{
protected
/**
@anthonysterling
anthonysterling / Autoloader.php
Created June 13, 2012 08:28
A CodeIgniter library which provides access, and functionality from, Symfony's UniversalClassLoader from within CodeIgniter.
<?php
/**
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
@anthonysterling
anthonysterling / vm-status.php
Created August 11, 2012 17:22
PHP Class to lookup Virgin Media services status
<?php
class VirginMediaStatus
{
const
SERVICE_ALL = 1,
SERVICE_BROADBAND = 2,
SERVICE_TV = 4,
SERVICE_PHONE = 8;
protected
@anthonysterling
anthonysterling / tunlr.yql.data.table.xml
Created September 4, 2012 20:44
Simple Tunlr.net YQL Data Table
<?xml version="1.0" encoding="UTF-8" ?>
<table xmlns="http://query.yahooapis.com/v1/schema/table.xsd">
<meta>
<description>Retrieves the IP adddresses for tunlr.net's DNS servers</description>
<author>Anthony Sterling</author>
</meta>
<bindings>
<select produces="JSON">
<execute><![CDATA[
var results = y.query("select content from html where url=\"http://tunlr.net/get-started/\" and xpath='//span[@style = \"font-size: xx-large;\"]'").results.*;
@anthonysterling
anthonysterling / lastfm.yql.data.table.xml
Created December 30, 2012 12:52
YQL Data Table to scrape last.fm "Top Tracks" by Tag.
<?xml version="1.0" encoding="UTF-8" ?>
<table xmlns="http://query.yahooapis.com/v1/schema/table.xsd">
<meta>
<description>Retrieves the Top Tracks, by tag, from Last.fm</description>
<author>Anthony Sterling</author>
</meta>
<bindings>
<select produces="JSON">
<inputs>
<key id="tag" as="tag" type="xs:string" paramType="query" required="true"/>
@anthonysterling
anthonysterling / destroy-vagrant.sh
Created May 22, 2013 09:48
Finds all running Vagrant instances, recursively, from with in the current folder. It then shuts them down, deletes the VM, and removes the .vagrant file.
#!/usr/bin/env bash
for config in `find . -type f -name .vagrant`
do
uuid=`cat "$config" | php -r 'echo json_decode(fgets(STDIN))->active->default;'`
if VBoxManage showvminfo $uuid > /dev/null 2>&1; then
if VBoxManage showvminfo $uuid --machinereadable | egrep -q 'VMState="running|paused|stuck"'; then
VBoxManage controlvm $uuid poweroff
fi
VBoxManage unregistervm $uuid --delete
rm -f "$config"
@anthonysterling
anthonysterling / AjaxifyEventbriteDeletePromotion.js
Created February 18, 2014 14:25
AjaxifyEventbriteDeletePromotion.js
deleteForm = function (id) {
var form = document.deleteDiscountForm;
form.discount.value = id;
console.log('Deleting ' + id + ' ...');
jQuery.post(window.location.href, jQuery(form).serialize());
}
@anthonysterling
anthonysterling / Vagrantfile
Last active April 29, 2020 15:28
Handy Vagrantfile for IE testing with Vagrant.
# Usage: IE={box} vagrant up
#
# Eg. IE=XPIE6 vagrant up
boxes = {
"XPIE6" => "http://aka.ms/vagrant-xp-ie6",
"XPIE8" => "http://aka.ms/vagrant-xp-ie8",
"VistaIE7" => "http://aka.ms/vagrant-vista-ie7",
"Win7IE8" => "http://aka.ms/vagrant-win7-ie8",
"Win7IE9" => "http://aka.ms/vagrant-win7-ie9",
@anthonysterling
anthonysterling / keybase.md
Created September 30, 2014 12:40
keybase.md

Keybase proof

I hereby claim:

  • I am anthonysterling on github.
  • I am anthonysterling (https://keybase.io/anthonysterling) on keybase.
  • I have a public key whose fingerprint is A316 F82A 8C37 5842 161B 7605 D89F 878F B669 73BC

To claim this, I am signing this object:

@anthonysterling
anthonysterling / provision-minio-droplets
Last active July 13, 2023 01:11
Simple bash script to create 4 Digital Ocean Droplets, each with Persistent Volumes, with a dedicated Load Balancer
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
function log {
local now=$(date +'%Y-%m-%d %H:%M:%S')
echo "[$now] $1"
}