Skip to content

Instantly share code, notes, and snippets.

:shipit:

Will Morgan willmorgan

:shipit:
View GitHub Profile
@willmorgan
willmorgan / .gitconfig
Last active Jul 2, 2018
.gitconfig aliases
View .gitconfig
[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 / git-branch-delete-gone.sh
Last active Oct 16, 2018
Delete Git branches that are gone
View git-branch-delete-gone.sh
git branch -v | grep "\[gone\]" | grep -Eo "^ ([A-z0-9_./-]+)" | sed -E 's/^ //g' | xargs git branch -D
@willmorgan
willmorgan / function.json
Created Feb 19, 2018
Azure Function Runtime ISO8601 datetime mangling
View function.json
{
"disabled": false,
"tracing": {
"consoleLevel": "verbose"
},
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
@willmorgan
willmorgan / fail-ci-if-only-found.sh
Created Jan 8, 2018
Checks for accidental .only blocks inside tests
View fail-ci-if-only-found.sh
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 Jun 22, 2017
Azure Function crasher
View function.js
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 Apr 19, 2017 — forked from dhensby/update-authorized-keys.sh
Script to update SSH keys for a user
View update-authorized-keys.sh
#!/usr/bin/env bash
USER=''
HOME_DIR=''
DEBUG=false
KEY_FILE=''
function setuser {
if [ -z "$1" ]; then
echo "RUNTIME EXCEPTION: No user supplied"
@willmorgan
willmorgan / .htaccess
Created Feb 18, 2016
SilverStripe mod_pagespeed install
View .htaccess
<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 / anchor-coordinates.js
Created Jun 23, 2015
"Anchor" an element around another element.
View anchor-coordinates.js
function getAnchorCoordinates(anchor, container, me) {
me = me || this.el;
container = container || document.body;
// Margins - use half a margin for normal positioning, the full margin for compensating
// against the container box
var offsetMarginX = 30;
var offsetMarginY = 30;
// The coordinates we're anchoring around
View example.php
<!-- Step 0: Ensure your server configuration is correct (see sample-apache.conf) -->
<!-- Step 1: Include the hash script (see git-hash.php) -->
<?php $hash = require_once 'git-hash.php'; ?>
<html>
<!-- Step 2: Prepend the hash to any combined assets -->
<link rel="stylesheet" href="assets/_combined-<?=$hash?>.css" />
<script src="assets/_combined-<?=$hash?>.js" />
View gist:8474916
#!/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..."
You can’t perform that action at this time.