Skip to content

Instantly share code, notes, and snippets.

View stnvh's full-sized avatar

Stan Hutcheon stnvh

  • Norwich, Norfolk
View GitHub Profile

Keybase proof

I hereby claim:

  • I am stnvh on github.
  • I am stnvh (https://keybase.io/stnvh) on keybase.
  • I have a public key ASAhUgiHvJZ4yPOL-ENxYFwmNmw8Xeca4eAmWvIUFlED1Ao

To claim this, I am signing this object:

@stnvh
stnvh / killafter
Last active February 25, 2016 12:17
A script to kill a process if it's execution time has elapsed a specified amount of seconds
#!/bin/bash
# checks if a process has ran for n seconds, and kills it if so
# - usage killafter <procname> <seconds>
func="$1"
timeout="$2"
green="\033[31m"
red="\033[31m"
@stnvh
stnvh / placeholder-ie-polyfill.js
Last active April 22, 2016 13:26
left hand assignment ftw
/* ie placeholders */
$('[placeholder]').on('focus blur', function() {
var h = this.getAttribute('placeholder'), v = this.value;
this.value = !v && h || ((v != h) && v || '');
}).trigger('blur');
@stnvh
stnvh / chatwipe
Last active August 5, 2020 00:58
Regularly wipe message history on OS X at configurable intervals — Uses applescript to completley remove conversations from app
#!/bin/bash
# removes various files related to stored iChat/Messages data on disk
# ran through launchd. relies on compiled applescript to fully remove all conversation traces
# will not run if the system is in use, unless the system has been idle for the amount of minutes below
TIMEOUT=15
## start ##
16:55:44.153146 IP (tos 0x0, ttl 64, id 36489, offset 0, flags [DF], proto TCP (6), length 499)
192.168.1.75.61121 > uklon5-vip-bx-005.aaplimg.com.http: Flags [P.], cksum 0xf2a1 (correct), seq 3793543519:3793543966, ack 397515557, win 4117, options [nop,nop,TS val 1971128429 ecr 138026923], length 447
N..l'........E.....@.@......K..#....P..._...%...........
u}.m.:..GET /apple-assets-us-std-000001/Purple3/v4/74/d2/82/74d28291-9db9-7ae2-305d-9b8b3f5fd463/ftk3252456602304584541.pkg HTTP/1.1
Host: osxapps.itunes.apple.com
Accept: */*
Connection: keep-alive
iCloud-DSID: XXXXXXXXXX
Range: bytes=2711126016-
Date: Thu, 01 Oct 2015 15:55:44 GMT
@stnvh
stnvh / LivereloadProvider.php
Created July 20, 2015 15:02
Livereload helper for SilverStripe
<?php
/**
* Put {$Livereload} just before the end of the closing body tag
*/
class LivereloadProvider implements TemplateGlobalProvider {
public static function get_template_global_variables() {
return array(
@stnvh
stnvh / textarea-dynamic-rows.js
Last active August 29, 2015 14:23
Adapts textarea rows to content length (opposed to a fixed height based approach) IE8+
(function() {
/* resize textarea based on text content (with IE8 support & no fixed heights or pseudo-divs!) */
// jquery
var textarea = $('textarea');
if(textarea.length) textarea.on('input propertychange', function() {
this.rows = ((this.value || '').match(/(\r?\n)/mg) || []).length + 1;
}).trigger('input');
@stnvh
stnvh / Facebook.ss
Created April 17, 2015 10:23
Simple social buttons wrapper for SilverStripe
<% require javascript('https://connect.facebook.net/en_GB/sdk.js#xfbml=1&version=v2.0') %>
<div class="{$ClassName}">
<div id="fb-root"></div>
<div class="fb-share-button" data-href="{$URL}" data-layout="<% if Type %>{$Type}<% else %>button<% end_if %>"></div>
</div>
@stnvh
stnvh / emailsearch.sh
Created November 3, 2014 12:37
Time machine mail search
#!/bin/bash
# Email search script
# by Stan Hutcheon
if [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then
echo 'usage: emailsearch [volume] [user] [backupname] [backupvolume] [query]'
exit
fi
@stnvh
stnvh / intel.sh
Created October 23, 2014 10:41
Downloads the latest Intel HD Graphics driver from OSX combo update
#!/bin/bash
URL="http://support.apple.com/downloads/DL1760/en_US/OSXUpdCombo10.9.5.dmg"
if [[ ! -f /tmp/OSXUpdCombo10.9.5.dmg ]]; then
echo 'Downloading 10.9.5 Combo...'
curl -Lo /tmp/OSXUpdCombo10.9.5.dmg $URL
fi
if [[ ! -d /tmp/ComboMount ]]; then