Skip to content

Instantly share code, notes, and snippets.

Peter Williamson Willshaw

Block or report user

Report or block Willshaw

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Willshaw
Willshaw / shellTrim.sh
Last active Aug 29, 2015
Shell script to create trimmed versions of a CSV. Trims the file to the number of lines supplied in the second input.
View shellTrim.sh
#!/bin/bash
#
#AUTHOR: Pete Williamson
#DATE: 2014-10-21
#
#USAGE:
# Creates smaller versions of supplied CSV file,
# based on the line number values as the second parameter
#
# The resulting CSVs are zipped up (for windows compatibility)
View teaboi-web-firebase
<!--
Bootstrap themed, Firebase & jQuery powered drinks run monitor
Add your own Firebase project URL where specified:
https://www.firebase.com/
Peter Williamson : 02/02/2015
Licence - do what you like with it, credit would be nice
-->
View Coldfusion Unique Array, Java Vs Ben
<cfscript>
lst = '';
cnt = 10000;
for( i = 1; i <= cnt; i++ ) {
val = randRange( 1, 5 );
lst = listAppend( lst, val );
}
@Willshaw
Willshaw / bash-grep-repos
Last active Aug 29, 2015
Bash Script to Git Grep a directory of repos
View bash-grep-repos
#!/bin/bash
#
# Supply 2 params from cmd, path to search and the term.
# The script will cd to $path, then check any directories
# it finds for the presence of a .git directory.
#
# If it finds a .git directory, a repo is assumed and
# a case insensitive grep is performed on term
#
# example:
@Willshaw
Willshaw / clickShield.js
Created Jun 9, 2015
Angular JS Click Shield Directive
View clickShield.js
/**
* AngularJS directive to shield an element from clicks
*
* The directive should be placed after the content to shield,
* and will create an elemenent absolutely positioned across
* the full area of the target element.
* Can be used with ng-if to create context specific shield
*
* USAGE:
*
@Willshaw
Willshaw / copyHooks.sh
Last active Nov 11, 2015
Copy hook into multiple repos
View copyHooks.sh
ls -la | awk '{print $9}' | grep -v comcar | egrep '^[a-z]' | while read -r line; do sed -e "s/myrepo/$line/" myrepo/hooks/post-receive > $line/hooks/post-receive; done
#
# Break down of the above command is below - don't try to run the bits
# on their own, you need to pipe the outputs between, like the example above
#
# List contentsfiles in current directory - full list view, row per file/folder
ls -la
# Only print the 9th column (folder name)
@Willshaw
Willshaw / fibonacci.php
Last active Dec 17, 2015
PHP Fibonacci number
View fibonacci.php
<?
// array to store sequence - initialised with first 2 numbers
$nums = array(0,1);
// loop 20 times creating more numbers in the sequence
for($i = 1; $i <=20; $i++) {
$next = $nums[$i]+$nums[$i-1];
array_push($nums,$next);
}
@Willshaw
Willshaw / angular-module-controllers
Last active Dec 23, 2015
Get list of controllers attached to an AngularJS module
View angular-module-controllers
var arrCtrl = myApp.controller()._invokeQueue;
for( var c in arrCtrl ) {
var ctrl = arrCtrl[c];
var name = ctrl[2][0] || 'undefined';
// I've suffixed all my controllers with Ctrl (TutorialCtrl, LoginCtrl), change the regex to suit you
if( name.match(/Ctrl$/) ) {
console.log(name);
@Willshaw
Willshaw / image-transparency-check.html
Last active Jan 14, 2016
Check the look of a transparent image on a coloured background - tested only in Chrome
View image-transparency-check.html
<DOCTYPE !html>
<html>
<head>
<title>Quick image check</title>
<style>
* {
font-family: sans-serif;
}
#dropzone,
@Willshaw
Willshaw / download-files-push-to-s3
Last active Apr 12, 2016
Download a load of files from the web and push to an s3 bucket
View download-files-push-to-s3
#!/bin/bash
#
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# Version 2, December 2004
# Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
# Everyone is permitted to copy and distribute verbatim or modified
# copies of this license document, and changing it is allowed as long
# as the name is changed.
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
You can’t perform that action at this time.