Skip to content

Instantly share code, notes, and snippets.

View quickshiftin's full-sized avatar

Nathan Nobbe quickshiftin

View GitHub Profile
@quickshiftin
quickshiftin / lastd.sh
Created February 10, 2014 19:35
BASH alias to get the last downloaded file on OSX
alias lastd='echo ~/Downloads/$(ls -t ~/Downloads/ | head -n 1)'
@quickshiftin
quickshiftin / git-find-replace.sh
Last active August 29, 2015 13:56
Simple git find-&-replace utility (for use w/ GNU sed)
#--------------------------------------------------------
# Simple search and replace utility for git repositories.
# @note Use w/ GNU sed.
# (c) Nathan Nobbe 2014
# quickshiftin@gmail.com
# http://quickshiftin.com
# $1 - Search
# $2 - Replace
# $3 - Subdirectory (optional, defaults to cwd)
#--------------------------------------------------------
@quickshiftin
quickshiftin / mysqldbs.sh
Last active August 29, 2015 13:56
mysqldbs - Show all mysql databases for a given host (defaults to localhost) a given user can view with a simple Bash alias.
alias mysqldbs='_() { local h=""; if [ ! -z "$2" ]; then h="-h$2"; fi; echo "show databases;" | mysql -u "$1" "$h" -p; }; _'
@quickshiftin
quickshiftin / phplint.sh
Last active August 29, 2015 13:56
The lint utility you wish `php -l` was out of the box. Lint check multiple PHP files with a single command.
function php_lint
{
for arg in $(seq $#)
do
# Use find to iterate over directories recursively
if [ -d "${!arg}" ]; then
find "${!arg}" -name '*.php' -exec php -l "{}" ";"
# Just run normal files and symlinks through php -l individually
elif [ -f "${!arg}" -o -h "${!arg}" ]; then
php -l "${!arg}"
@quickshiftin
quickshiftin / jetty-hash-pass.sh
Last active August 29, 2015 13:56
A thin wrapper around a jetty utility to hash passwords for xml files.
#!/bin/bash
# -----------------------------------------------------------------------------------
# jetty-hash-pass.sh
# (c) Nathan Nobbe 2014
# quickshiftin@gmail.com
# http://quickshiftin.com
#
# See the Password Issues section of the below link
# http://docs.codehaus.org/display/JETTY/How+to+configure+SSL#HowtoconfigureSSL-step3
#
@quickshiftin
quickshiftin / pem2pkcs12.sh
Created February 12, 2014 05:03
Convert a set of Apache ssl certificates to a format suitable for Jetty
#!/bin/bash
# -----------------------------------------------------------------------------------
# pem2pkcs12.sh
# (c) Nathan Nobbe 2014
# quickshiftin@gmail.com
# http://quickshiftin.com
#
# Use this script to convert a set of apache ssl certificates to a format suitable
# for Jetty.
#
@quickshiftin
quickshiftin / osx-locate.sh
Created February 18, 2014 03:11
Simulate locate on OSX
# update locate database, linux style
alias updatedb='sudo /usr/libexec/locate.updatedb'
# mdfind is the locate equivalent on OSX,
# so this is probly more useful for you
alias locate='mdfind -name'
@quickshiftin
quickshiftin / lse.sh
Last active August 29, 2015 13:56
ls wrapper for emacs that omits files created by the editor
_lse_filter='~|#.*#'
alias lse='_() { ls -1 $1 | egrep -v $_lse_filter; }; _'
@quickshiftin
quickshiftin / reboot-or-shutdown.sh
Created September 30, 2015 20:48
Reboot or shutdown and exit from the box
#!/bin/bash
alias reboot='sudo reboot && exit'
alias shutdown='sudo shutdown -h now && exit'
@quickshiftin
quickshiftin / thisdir.sh
Created October 5, 2015 15:07
echo the name of the current director (without leading directories)
alias thisdir='basename "$(pwd)"'