Skip to content

Instantly share code, notes, and snippets.

@Graham42
Graham42 / depsNgInclude.js
Last active August 29, 2015 14:07
Angular directive when you need ngInclude to wait on dependencies
'use strict';
/*
* ngInclude functionality but waits until a list of dependencies have resolved.
*
* = Directive args =
* deps-ng-include = <path/to/template.html>
* deps = <comma separated list of dependencies>
*
* == Example ==
@Graham42
Graham42 / ls_escape_hack.sh
Created November 29, 2014 19:28
list all files escaped
ls -1 | sed 's/\([^\n]*\)/"\1"/g'
@Graham42
Graham42 / git-svn-clone-from-existing-clone.sh
Last active August 29, 2015 14:15
Get a git-svn clone faster if someone else has already cloned
#!/bin/bash
# @arg 1 - the git repository on someone elses machine or a server
# ie. [email protected]:/home/gmcgregor/MODULE_NAME
# @arg 2 - the svn url to point to
# ie. https://svn.my-company.com/MODULE_NAME
# check if required programs are installed
type svn >/dev/null 2>&1 || { echo >&2 "svn needs to be installed for this script to run."; exit 1; }
type git >/dev/null 2>&1 || { echo >&2 "git needs to be installed for this script to run."; exit 1; }
git svn --help >/dev/null 2>&1 || { echo >&2 "git-svn needs to be installed for this script to run."; exit 1; }
@Graham42
Graham42 / affirmation
Created February 20, 2015 00:31
MuleSoft Contributor Agreement Acceptance by Graham McGregor
I, Graham McGregor, have read and do accept the MuleSoft Contributor Agreement
at http://www.mulesoft.org/legal/contributor-agreement.html
Accepted on Thu Feb 19 2015 19:31:36 GMT-0500 (EST)
#!/bin/bash
function usage {
echo "USAGE: git merge-svn <from> [<to>]"
echo ""
echo " from The branch name to be merged FROM"
echo " to Optional branch name to be merged onto. Default: HEAD"
echo ""
}

Keybase proof

I hereby claim:

  • I am Graham42 on github.
  • I am graham42 (https://keybase.io/graham42) on keybase.
  • I have a public key whose fingerprint is 6312 6E73 DA79 A2D9 DB23 92BC 324C F799 431B D7B5

To claim this, I am signing this object:

@Graham42
Graham42 / start-with-this.css
Last active November 17, 2015 17:42
Simple minimalist css to start with when building a web page
body {
margin: 40px auto;
padding: 0 20px;
max-width: 650px;
color: #444444;
background-color: #f2f2f2;
line-height: 1.6;
font-size: 16px;
font-family: sans-serif;
}
@Graham42
Graham42 / run-in-dirs.sh
Created October 22, 2016 20:39
Bash functions to run commands in all sub directories
# do something in each subfolder, excludes hidden folders
function foreach_dir(){
for arg in $(ls --color=none); do
if [ -d "$arg" ] ; then
cd $arg
eval $@
cd ..
fi
done
}
@Graham42
Graham42 / stat-directory.sh
Created April 11, 2017 12:58
One-liner to list files in a directory with actual byte size
DIR=path/to/wherever/; stat -c%n $DIR/* | xargs -I'{}' bash -c "printf \"%-40s\" {}; stat -c%s {} | xargs printf \"%'10.f\n\""
@Graham42
Graham42 / nope-to-IE.html
Last active December 16, 2017 22:35
refuse to serve IE - this is conditionally useful
<body>
<noscript>
<p>You need to enable JavaScript to run this app.</p>
</noscript>
<!-- Check for IE 9 and below -->
<!--[if IE]>
<p>Sorry! Your browser is not supported. We recommend using
<a href="https://www.google.com/chrome/browser/">Chrome</a> or
<a href="https://www.mozilla.org/en-US/firefox/new/">Firefox</a>.
</p>