Skip to content

Instantly share code, notes, and snippets.

View jktravis's full-sized avatar

Joshua Travis jktravis

View GitHub Profile
@jktravis
jktravis / rename_files.sh
Created December 8, 2012 00:35
Rename a group of files
#!/bin/bash
# Renames a group of files
counter=0
filename=$1
context=$2
ext=$3
if [ $# -ne 0 ]
then
if [ -z "${ext}" ]
@jktravis
jktravis / remove_spaces.sh
Last active October 13, 2015 20:48
Pipe in or supply a single filename to remove the spaces
#!/bin/bash
# Replace spaces with underscores
for file in "${1}";
do
echo Renaming "$file" to "${file// /_}"
mv "$file" "${file// /_}"
done
@jktravis
jktravis / LowecaseFile.sh
Last active December 14, 2015 07:19
LowecaseFile.sh
#Lowercase a group of files
for i in "${1}"; do mv "$i" "$(echo $i|tr A-Z a-z)"; done
@jktravis
jktravis / RefreshContextMenu.sh
Last active December 15, 2015 08:49
Clean Up Right-click Menu in OSX
#!/bin/bash
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local-domain system -domain user && killall Finder
@jktravis
jktravis / rename.py
Last active December 16, 2015 08:49
remove spaces and lowercase file names.
import os, argparse
parser = argparse.ArgumentParser(description="Remove spaces from file names and make them lowercase.")
parser.add_argument("file", nargs='+', help="The file to be renamed")
args = parser.parse_args()
for f in args.file:
print "Renaming {} to {}".format(f, f.replace(" ", "_").lower() )
os.rename(f, f.replace(" ", "_").lower())
@jktravis
jktravis / gist:5692564
Created June 2, 2013 03:43
Bash rename with regex and back references.
for i in *.txt;
do
x=$(sed 's/^Foo\(Bar..*\)/\1/' <<< $i);
echo "$i renames to: $x";
mv $i $x;
done
@jktravis
jktravis / sha1diff.sh
Created August 22, 2014 15:07
In terminal SHA1 diff
diff -s <(sha1sum fileToCheck | cut -d " " -f1) <(echo "SHA1Hash")
@jktravis
jktravis / gist:4e10b4d1aab6c8c39347
Created March 3, 2015 18:46
copy public key to remote
cat ~/.ssh/id_rsa.pub | ssh user@host "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"

Keybase proof

I hereby claim:

  • I am jktravis on github.
  • I am jktravis (https://keybase.io/jktravis) on keybase.
  • I have a public key ASBnSUSRq2VafF3mvh7BrVUC1waCoHWIzIGgkLR3V5VBfQo

To claim this, I am signing this object:

@jktravis
jktravis / createErrorHandler.js
Last active February 14, 2017 01:18
A simple error handler to be used with the auto-dispatched failTypes in redux-logic.
function handleError (type, error) {
console.error(error);
let payload;
if (typeof error === 'string') {
payload = error;
} else if (error.message) {
payload = error.message;
}
return {type, payload, error: true };
}