Skip to content

Instantly share code, notes, and snippets.

View quickshiftin's full-sized avatar

Nathan Nobbe quickshiftin

View GitHub Profile
@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 / NNReflectionMethod.php
Last active December 8, 2015 18:38
Syntactic sugar to quickly create a closure for an instance method. Especially useful for creating 'callables' to private methods.
<?php
class NNReflectionMethod extends ReflectionMethod
{
static public function closure($object, $method)
{
if(!is_object($object)) {
throw new InvalidArgumentException('$object must be an object');
}
$oRm = new ReflectionMethod($object, $method);
@quickshiftin
quickshiftin / strlen.sh
Last active October 27, 2015 01:39
strlen from the command line...
function strlen
{
local string="$1"
local size=${#string}
echo $size
}
@quickshiftin
quickshiftin / osx-clear-dns.sh
Created April 1, 2014 15:35
OSX Clear DNS
# clear dns cache
alias cleardns='sudo dscacheutil -flushcache'
@quickshiftin
quickshiftin / remote-mac-volume.sh
Created February 23, 2014 20:56
Set the volume on a mac over the network with SSH
function remote_volume
{
local user="$1"
local host="$2"
local vol="$3"
ssh "$user"@"$host" 'osascript -e "set volume output volume '"$vol"'"'
}
@quickshiftin
quickshiftin / osx-brew-gnu-coreutils-man.sh
Created February 21, 2014 07:25
Running GNU coreutils via Homebrew on your Mac? Here's a one-liner to get the manpages working!
# Short of learning how to actually configure OSX, here's a hacky way to use
# GNU manpages for programs that are GNU ones, and fallback to OSX manpages otherwise
alias man='_() { echo $1; man -M $(brew --prefix)/opt/coreutils/libexec/gnuman $1 1>/dev/null 2>&1; if [ "$?" -eq 0 ]; then man -M $(brew --prefix)/opt/coreutils/libexec/gnuman $1; else man $1; fi }; _'
@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 / 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 / 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 / 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
#