Skip to content

Instantly share code, notes, and snippets.

View nicholasdunbar's full-sized avatar

Nicholas Dunbar nicholasdunbar

View GitHub Profile
@nicholasdunbar
nicholasdunbar / policyExampleAwsUtil.json
Last active December 13, 2015 08:02
Example of a policy applied to a back up user in amazon AWS for the script https://gist.github.com/nicholasdunbar/0f9bc264fe8eaa95cd7f (only use s3:DeleteObject on your back up bucket if you have versioning turned on)
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1426742219000",
"Effect": "Allow",
"Action": [
"s3:AbortMultipartUpload",
"s3:GetObject",
"s3:GetObjectAcl",
@nicholasdunbar
nicholasdunbar / exampleOutput.json
Last active August 29, 2015 14:18
Example of JSON output from awsUtil.php list-timestamps example-of-a-backup-bucket-name "*.log" The script can be found here https://gist.github.com/nicholasdunbar/0f9bc264fe8eaa95cd7f
{"backup.log": {
"1427577934": {
"full-date": "2015-03-28T21:25:34.000Z",
"unix-timestamp": 1427577934,
"version-type": "VERSIONS",
"version-id": "Q7fGH4csueuuYZTd7UnosKCrwZZunfYg"
},
"1427577797": {
"full-date": "2015-03-28T21:23:17.000Z",
"unix-timestamp": 1427577797,
@nicholasdunbar
nicholasdunbar / aws.properties
Last active August 29, 2015 14:17
php based command line utility for restoring files from a back-up bucket to a target bucket.
#this is a property file that is used in awsUtil.php and
#can be used by https://github.com/MoriTanosuke/glacieruploader
#should you want to use it some where in your backup solution
# you will want to use user credentials that are limited by a policy like the one found here:
#https://gist.github.com/nicholasdunbar/70772946be646966dec1
accessKey=EXAMPLEOFAKEY
secretKey=ex3a2m9plkeof8a9s8e9c7ret2ke8y
@nicholasdunbar
nicholasdunbar / inlineANTProperty.xml
Last active August 29, 2015 14:11
Example of creating a variable in ANT, variables in ANT are called properties
<?xml version="1.0"?>
<project default="main" basedir=".">
<!-- This is the example of creating a variable or inline property, directly in the build file-->
<property name="CRONTAB_PATH" value="/some/dir/"/>
</project>
@nicholasdunbar
nicholasdunbar / replaceVarANT.xml
Last active August 29, 2015 14:11
Example of how to replace a token with a variable or inline property in ANT
<property name="CRONTAB_PATH" value="/some/dir/"/>
<task name="generateCrontab">
<copy file="crontab"
tofile="crontabTest.txt"
overwrite="true">
<filterchain>
<replacetokens>
<token key="cronPath" value="${CRONTAB_PATH}"/>
</replacetokens>
@nicholasdunbar
nicholasdunbar / propReplace.xml
Last active August 29, 2015 14:11
Example of a replacing a token in ANT from a property file
<copy file="crontab"
tofile="crontabTest.txt"
overwrite="true">
</copy>
<replace file="crontabTest.txt"
propertyFile="dev2.properties">
<replacefilter token="@cronPath@"
property="cronPath"/>
</replace>
<!--
@nicholasdunbar
nicholasdunbar / DetectOSOutsideTask.xml
Last active August 29, 2015 14:10
If you want to run a different logics based on the operating system in your ANT build.xml file here are two ways to do it.
<?xml version="1.0" encoding="UTF-8"?>
<!--Use ANT to trigger different tasks based on what OS is being used. See the code
snipit bellow if you don't want to create a new task just to switch some small piece
of logic depending on the operating system.-->
<project name="detectOS" default="showOS" >
<!--Create properties based on OS
conditions are like properties or variables that get set based on what is true
@nicholasdunbar
nicholasdunbar / parseColumns.php
Created August 23, 2014 06:44
Parse columns from pure text into structured data based on the precise spacing of the header and the columns.
<?php
//To parse an example like the following categorized columns:
/*
col1 col2 col3
==== ==== ====
1 a b c d e 103 14 as d9
2 a 103 14 as d9
3 a 103 14 as d9
*/
@nicholasdunbar
nicholasdunbar / parseApproxColumns.php
Last active August 29, 2015 14:05
For parsing columns from plain text with raged or unevenly spaced edges.
<?php
//To parse the following unevenly categorized columns:
/*
* col1 col2 col3
* ==== ==== ====
* 1 a b c d e 103 14 as d9
* 2 a 103 14 as d9
* 3 a 103 14 as d9
*
* Into structured data like this:
@nicholasdunbar
nicholasdunbar / detectIE8orLess.html
Last active November 5, 2019 18:53
Detect IE8 or a lesser version of IE in JavaScript.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Detect IE8</title>
<head>
<script type="text/javascript" id="init-ie-var">
var isIE8OrLess = false;
</script>
<!--[if lte IE 8]>