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
@midwire
midwire / sftp.thor.rb
Created February 2, 2012 21:50 — forked from mattmccray/sftp.thor.rb
Thor task for sftp syncing
# module: sftp
# A generic Thor module for sftp syncing.
#
# 1. Call `thor sftp:setup` to create config file.
# 2. Edit the config file
# 3. Call `tor sftp:sync` start the sync
#
# Ze end.
require 'vcr'
require 'support/integration_support'
VCR.config do |c|
c.cassette_library_dir = File.expand_path('fixtures/cassette_library')
c.stub_with :fakeweb
c.ignore_localhost = false
c.ignore_hosts EXCHANGE_CASE_SERVICE_INTEGRATION_HOST
c.default_cassette_options = { :record => :none }
end
@midwire
midwire / knife.rb
Created July 31, 2013 19:46
Standard knife.rb file
chef_server = "provision-dev.infra.rds"
log_level :info
log_location STDOUT
node_name "vagrant"
client_key "#{ENV['HOME']}/.chef/#{chef_server}/vagrant.pem"
validation_client_name "chef-validator"
validation_key "#{ENV['HOME']}/.chef/#{chef_server}/chef-validator.pem"
chef_server_url "https://#{chef_server}"
syntax_check_cache_path "#{ENV['HOME']}/.chef/#{chef_server}/syntax_check_cache"
@midwire
midwire / Guardfile
Last active December 31, 2015 07:09
DRY Guardfile with defined groups for running in focused mode or default mode. Switch at the Guard prompt using scope focus, or scope default.
# Run Guard normally. This Guardfile defines 2 groups:
# 1) default: This is the default group and will run all appropriate specs when anything changes.
# 2) focus: This is the group you want when you are focusing on a specific spec or context of specs. When in this
# scope Guard will only run specs tagged with :focus.
#
# Example:
# context "GET on :index, /", focus: true do
# ...
# end
#
@midwire
midwire / string.rb
Created January 20, 2014 16:16
String extension class
class String
class << self
def random(count = 6, ranges = [('a'..'z'),('A'..'Z'),('0'..'9')])
o = ranges.map{|i| i.to_a}.flatten;
string = (0..(count-1)).map{ o[rand(o.length)] }.join;
end
end
def left(count)
#!/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 / expand_history.rb
Last active November 30, 2017 14:09
Print a sorted list of your command history. Helpful for determining commands that need to be aliased.
#!/usr/bin/env ruby
class String
ENCODING_OPTS = { invalid: :replace, undef: :replace, replace: '', universal_newline: true }.freeze
def remove_non_ascii
encode(Encoding.find('ASCII'), ENCODING_OPTS)
end
end
# @zsh_history = %x(cat ~/.zsh_history |sed 's/\xc2\x91\|\xc2\x92\|\xc2\xa0\|\xe2\x80\x8e//' 2> /dev/null).split("\n")