Skip to content

Instantly share code, notes, and snippets.

View willmorgan's full-sized avatar

Will Morgan willmorgan

View GitHub Profile
@willmorgan
willmorgan / git-branch-delete-gone.sh
Last active October 16, 2018 11:47
Delete Git branches that are gone
git branch -v | grep "\[gone\]" | grep -Eo "^ ([A-z0-9_./-]+)" | sed -E 's/^ //g' | xargs git branch -D
@willmorgan
willmorgan / .htaccess
Created February 18, 2016 15:34
SilverStripe mod_pagespeed install
<IfModule pagespeed_module>
ModPagespeed on
ModPagespeedDisallow "*/admin/*"
AddOutputFilterByType MOD_PAGESPEED_OUTPUT_FILTER text/html
ModPagespeedLowercaseHtmlNames on
ModPagespeedEnableFilters prioritize_critical_css,defer_javascript
ModPagespeedEnableFilters convert_jpeg_to_webp,inline_preview_images
ModPagespeedEnableFilters collapse_whitespace,remove_comments
</IfModule>
@willmorgan
willmorgan / .gitconfig
Last active July 2, 2018 13:26
.gitconfig aliases
[alias]
co = checkout
chep = cherry-pick
chepc = cherry-pick --continue
br = branch
ci = commit
st = status
rbi = rebase -i
rbc = rebase --continue
plu = pull --rebase upstream
@willmorgan
willmorgan / function.json
Created February 19, 2018 15:13
Azure Function Runtime ISO8601 datetime mangling
{
"disabled": false,
"tracing": {
"consoleLevel": "verbose"
},
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
@willmorgan
willmorgan / fail-ci-if-only-found.sh
Created January 8, 2018 15:13
Checks for accidental .only blocks inside tests
set +e
# Check for accidental `.only` blocks inside tests, and fail the tests if any are found:
ACCIDENTAL_ONLY=$(grep -R -m 1 --include="*.js" --exclude-dir=node_modules --exclude-dir=.git "\.only" . 2>&1)
HAS_ACCIDENTAL_ONLY=$?
set -e
if [ $HAS_ACCIDENTAL_ONLY == 0 ];
then
echo "Found a \`.only\` block inside the tests; failing CI build. Details below:"
echo ${ACCIDENTAL_ONLY}
@willmorgan
willmorgan / function.js
Last active June 22, 2017 08:41
Azure Function crasher
const sshpk = require('sshpk');
function printClientCert(cert) {
return sshpk.parseCertificate(cert, 'x509');
}
module.exports = function (context, req) {
context.log(
printClientCert(Buffer.from(req.headers['x-arr-clientcert'], 'base64'))
);
@willmorgan
willmorgan / update-authorized-keys.sh
Created April 19, 2017 12:55 — forked from dhensby/update-authorized-keys.sh
Script to update SSH keys for a user
#!/usr/bin/env bash
USER=''
HOME_DIR=''
DEBUG=false
KEY_FILE=''
function setuser {
if [ -z "$1" ]; then
echo "RUNTIME EXCEPTION: No user supplied"
#!/bin/sh
# Pre-commit file needs to be executable so first
# chmod +x .git/hooks/pre-commit
# Fix your grunt path
PATH="/usr/local/bin:$PATH"
# Runs grunt default
echo "Running Grunt..."
@willmorgan
willmorgan / transitionmasher.js
Created November 6, 2013 13:38
transitionmasher.js
if(this.transitions) {
body.addClass('bhv-transition-now').css('height', fullHeight);
body.height();
body.removeClass('bhv-transition-now').addClass('state-transitioning');
body.height();
body.css('height', 0);
body.on('transitionend.close', function(event) {
body.off('transitionend.close');
body.addClass('state-hidden');
body.height();
@willmorgan
willmorgan / TableOptionsetField.php
Last active December 18, 2015 11:19
3,1 DataObjectManager style field that allows arbitrary options to be rendered on the frontend with maximum flexibility and ease.
<?php
/**
* TableOptionsetField
* DataObjectManager style field that allows arbitrary options to be rendered on
* the frontend with maximum flexibility and ease.
* @author Will Morgan <will@betterbrief.co.uk>
*/
class TableOptionsetField extends FormField {