Skip to content

Instantly share code, notes, and snippets.

View quickshiftin's full-sized avatar

Nathan Nobbe quickshiftin

View GitHub Profile
@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-clear-dns.sh
Created April 1, 2014 15:35
OSX Clear DNS
# clear dns cache
alias cleardns='sudo dscacheutil -flushcache'
@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 / 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 / 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)"'
#!/bin/bash
# Locate files relative to current working directory
# Potentially faster than find for deep directories
function rlocate
{
locate "$1" | grep "$(pwd)"
}
//--------------------------------------------------------------------
// http://solutionoptimist.com/2013/12/27/javascript-promise-chains-2/
//--------------------------------------------------------------------
//--------------------------------------------------------------------
// Pretend calls to a service
//--------------------------------------------------------------------
function getDeparture() {
return new Promise((resolve) => {
setTimeout(function() {
@quickshiftin
quickshiftin / letsencrypt-revoke-cert.sh
Last active October 21, 2017 21:50
Revoke Letsencrypt certificate
#/bin/bash
# http://disq.us/p/1k1ww01
cert_path=$1 # eg /etc/letsencrypt/live/example.com/cert.pem
key_path=$2 # eg /etc/letsencrypt/live/example.com/privkey.pem
certbot revoke --cert-path "$1" --key-path "$2"
@quickshiftin
quickshiftin / launch-php-xdebug-cli.sh
Created November 4, 2017 16:58
Launch xdebug on a CLI script on a server you are connected to via SSH
#!/bin/bash
php -d xdebug.remote_autostart=1 -d xdebug.remote_host=$(echo $SSH_CLIENT | sed 's/ .*//') path-to-php-script.php