Skip to content

Instantly share code, notes, and snippets.

Craig Rowe cargowire

Block or report user

Report or block cargowire

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

Keybase proof

I hereby claim:

  • I am cargowire on github.
  • I am cargowire ( on keybase.
  • I have a public key ASAtuFVcugGTK_Xzq_FHZJbsosuh-R7mRRgNnr6RxdLVWAo

To claim this, I am signing this object:

cargowire /
Created Aug 17, 2012
Rename files by adding a suffix after a fixed number of characters from the original string (assumes no '.' in filenames)
for i in *.$1;
IFS="." read -ra parts <<< "$i"
mv $i ${parts[0]:0:$3}$2.${parts[1]};
unset IFS
cargowire /
Created Apr 13, 2012
Export all php files as static html files
# Uses php cli to run all php files in the current directory and write their output to file
# Argument 1 is the extension of the output files e.g. ".html" or ".htm"
# Argument 2 is a prefix for the filenames
for file in *.php; do
php $file | cat > $2${file%.php}$1;
cargowire /
Created Jan 20, 2011
List files within the arg1 folder that are not referenced in any content from files in arg2
# Simple find unreferenced filename script
# Argument 1 is a folder that contains files you are interested in. e.g. an images folder
# Argument 2 is a folder that contains the files to search within. e.g. a css folder
for pattern in `ls $1`; do
if ! grep -rq $pattern $2; then
echo $pattern;
cargowire / namespacedAutoOnLoad.js
Created Dec 17, 2010
Implements a simple json traverse as the only call in jQuery onReady to find all '_load' methods on classes and call them within their own scope. Allows easy adding of new 'classes' within that known namespace that control their own load and private vars
View namespacedAutoOnLoad.js
// Single jquery onload action covers all namespaced items
$(function () { traverse(myNamespace); });
// Identify all _load methods in the namespace and call them within their own object scope
var traverse = function(jsonObj, parentObj, name) {
if (typeof (jsonObj) == "object") {
parentObj = jsonObj;
$.each(jsonObj, function(k,v) {
traverse(v, parentObj, k);
You can’t perform that action at this time.