Skip to content

Instantly share code, notes, and snippets.

View andrewwheal's full-sized avatar

Andrew Wheal andrewwheal

  • CloudCall Ltd
  • Rugby, Warwickshire
  • 06:41 (UTC +01:00)
View GitHub Profile
@andrewwheal
andrewwheal / options.sh
Created November 11, 2015 17:04
Bash Option Parsing
#!/bin/bash
# Include this file in the top of your script to have options
# parsed into an OPTIONS variable.
#
# If you set an OPTSTRING variable, getopts will be used with that string
#
# If you set an OPTION_DEBUG variable, then the parsed options will be output
declare -A OPTIONS
$arr = [...];
uasort(
$arr,
function($a, $b) {
return strnatcmp($a['foo'], $b['foo']);
}
);
@andrewwheal
andrewwheal / abstract.php
Created April 21, 2015 10:14
Abstract Selenium Test Case - checking for Internal Server Error pages
<?php
class AbstractTestCase extends PHPUnit_Extensions_Selenium2TestCase
{
/**
* Check for internal server errors and reload the page upto 3 times
*/
protected function checkInternalServerError()
{
$url = $this->url();
@andrewwheal
andrewwheal / abstract.php
Created April 21, 2015 09:59
Abstract Selenium Test Case - allows Browserstack and browser configuration from environment variables
<?php
class AbstractTestCase extends PHPUnit_Extensions_Selenium2TestCase
{
/**
* Array of browsers and platforms to run tests in
*
* @var array
*/
public static $browsers = array(
@andrewwheal
andrewwheal / git-tidy-branches
Created December 17, 2014 11:02
git tidy-branches
#!/bin/bash
KEEP=$@
branches=$(git branch | grep -v "*" | grep -v "detached" | grep -v "no branch")
if [ "$KEEP" != "" ]; then
for notthis in $KEEP; do
branches=$(echo "$branches" | grep -vE "$notthis")
done
@andrewwheal
andrewwheal / cdup.func.sh
Created September 16, 2014 15:29
cdup bash function
cdup() {
p=${1}
if [[ $p = -* ]]; then
c="cd "
while [[ $p -lt 0 ]]; do
c=$c"../"
let p=p+1
done
$c
else
@andrewwheal
andrewwheal / JavaScript.xml
Created September 2, 2014 11:50
PhpStorm Live Tempates
<?xml version="1.0" encoding="UTF-8"?>
<templateSet group="JavaScript">
<template name="ready" value="$(function() {&#10;&#9;$END$&#10;})" description="HOJS says do this" toReformat="true" toShortenFQNames="true">
<context>
<option name="HTML_TEXT" value="false" />
<option name="HTML" value="false" />
<option name="XSL_TEXT" value="false" />
<option name="XML" value="false" />
<option name="CSS_PROPERTY_VALUE" value="false" />
<option name="CSS_DECLARATION_BLOCK" value="false" />
@andrewwheal
andrewwheal / Fuel CRUD Controller.php
Created September 2, 2014 11:48
PhpStorm File Templates
<?php
#if (${NAMESPACE})
namespace ${NAMESPACE};
#end
class Controller_${NAME} extends \Controller_Template {
public function action_index() {
@andrewwheal
andrewwheal / git-commands.md
Last active October 17, 2018 02:13
git-commands

moving branches

  • git branch -f <branch> [<destination>]
  • git hoist <branch> [<destination>]
  • git ff [<destination>]
  • git catchup [<branch>] [<remote>]

updating submodules

  • git subup

diff all the things

* {
-webkit-filter: grayscale(100%);
-moz-filter: grayscale(100%);
-ms-filter: grayscale(100%);
-o-filter: grayscale(100%);
filter: grayscale(100%);
filter: url(grayscale.svg); /* Firefox 4+ */
filter: gray; /* IE 6-9 */
}