Skip to content

Instantly share code, notes, and snippets.

View midwire's full-sized avatar
🏠
Working from home

Chris Blackburn midwire

🏠
Working from home
View GitHub Profile
#!/bin/bash
libs=( "/usr/local/lib/libmacfuse_i32.2.dylib" \
"/usr/local/lib/libosxfuse_i32.2.dylib" \
"/usr/local/lib/libosxfuse_i64.2.dylib" \
"/usr/local/lib/libmacfuse_i64.2.dylib" \
"/usr/local/lib/libosxfuse_i32.la" \
"/usr/local/lib/libosxfuse_i64.la" \
"/usr/local/lib/pkgconfig/osxfuse.pc" )
@midwire
midwire / VPN Watchdog.scpt
Last active August 29, 2015 14:00
Stay connected to your VPN...
# Change service (VPN) name to the name of your configured VPN service
on idle
tell application "System Events"
tell current location of network preferences
set myConnection to the service "RentPath"
if myConnection is not null then
if current configuration of myConnection is not connected then
connect myConnection
end if
end if
@midwire
midwire / ruby_patterns.md
Last active August 29, 2015 14:02
14 Defined Ruby Patterns from Russ Olsen's Book

Ruby Patterns

  • Template Method
  • Strategy
  • Observer
  • Composite
  • Iterator
  • Command
  • Adapter
  • Proxy
@midwire
midwire / commit_message.rb
Last active August 29, 2015 14:03
Create a commit message, with link to a Pivotal story, based on the branch name and put it all on the clipboard.
#!/usr/bin/env ruby
require 'pry-nav'
def pbcopy(input)
str = input.to_s
IO.popen('pbcopy', 'w') { |f| f << str }
str
end
branch_name = `git rev-parse --abbrev-ref HEAD`.chomp
@midwire
midwire / gateway.sh
Created July 10, 2014 13:56
Determine the default gateway on OSX.
#!/usr/bin/env bash
# determine the local gateway
netstat -nr|grep '^default'
@midwire
midwire / notify.rb
Created July 10, 2014 13:58
Notify after a long-running shell command
#!/usr/bin/env ruby
require "rubygems"
require "thor"
require 'terminal-notifier'
class NotifyAfter < Thor
desc "after ARGS",
"ARGS is the after and list of arguments to run, after which you will be notified."
@midwire
midwire / postgres.server.sh
Created July 10, 2014 13:58
Postgres control script.
#!/bin/bash
cmd=$1
function init_postgres() {
initdb /usr/local/var/postgres
}
function start_postgres() {
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
@midwire
midwire / recursive_unlock.sh
Created July 10, 2014 13:59
Simple file unlocking utility for Mac OSX.
#! /bin/bash
#
# Simple file unlocking utility for Mac OS X
#
ARGS=1
E_BADARGS=65
SETFILE=/Applications/Xcode.app/Contents/Developer/usr/bin/SetFile
function recursiveUnlock() {
pushd $1
@midwire
midwire / redis.server.sh
Created July 10, 2014 13:59
Redis server control script.
#!/usr/bin/env bash
cmd=$1
function start_redis() {
nohup redis-server /usr/local/etc/redis.conf > /dev/null 2>&1 &
}
function stop_redis() {
redis-cli shutdown
@midwire
midwire / restest.sh
Created July 10, 2014 14:00
Use curl for REST testing APIs
#!/usr/bin/env bash
# Use curl for REST testing apis
#
# curl params:
# i – show response headers
# H – pass request headers to the resource
# X – pass a HTTP method name
# d – pass in parameters enclosed in quotes; multiple parameters are separated by ‘&’
# curl -i -H "Accept: application/json" -X POST -d "firstName=james" http://192.168.0.165/persons/person