Skip to content

Instantly share code, notes, and snippets.

@phinze
phinze / remove_casks_linked_as_formula.sh
Created August 6, 2013 23:44
Clean Casks from homebrew-casks that were improperly linked as homebrew formula during a brew update. This happened for a spell due to a bug in homebrew that is now fixed, but some people have extra links lying around from when the bug was in the wild. This has been tested and cleans up any symlinks that shouldn't be there.
find $(brew --prefix)/Library/Formula -type l | for symlink in $(cat -); do readlink $symlink | grep phinze-cask | grep -v brew-cask > /dev/null && rm -v $symlink; done
@phinze
phinze / brew-casklist.rb
Last active December 16, 2015 03:49
example of a homebrew external command with a start to categorized cask listing built for conversation in https://github.com/phinze/homebrew-cask/issues/198
BREW_CASK_PREFIX = `brew --prefix brew-cask`.chomp
$LOAD_PATH << File.join(BREW_CASK_PREFIX, 'rubylib')
require 'cask'
module CaskCategories
CATEGORIES = {
'adium' => 'chat',
'rdio' => 'music',
'firefox' => 'browser',
@phinze
phinze / gist:5323078
Created April 5, 2013 22:12
delete all files in a folder with applescript ouch my eyezzzzzzzz
tell application "Finder"
set the appfiles to files in folder (POSIX file "/tmp/somefolder" as text)
repeat with appfile in appfiles
delete appfile
end repeat
end tell
@phinze
phinze / deploy.rb
Created March 29, 2013 15:00
no access to git from your production app box? still want to use git to deploy so you are dealing in SHAs/clones and not timestamps/tars? access your repo using a reverse ssh tunnel!
# config/deploy.rb
$: << File.expand_path('../../lib', __FILE__)
require 'capistrano_hacks/reverse_tunnel'
set :scm, :git
set :local_repository, '.'
set :reverse_tunnel_port, 52222
set :repository, Capistrano::Hacks.tunneled_repository_url(self)
set :ssh_options, { :forward_agent => true }
@phinze
phinze / aws-shell.rb
Last active December 13, 2015 21:58
quick 'n' dirty aws-shell
#!/usr/bin/env ruby
require 'rubygems'
require 'highline'
def ask(question)
HighLine.new.ask(question) { |q| q.echo = '*' }
end
if ENV['AWS_SHELL']
@phinze
phinze / gist:4670690
Created January 30, 2013 04:41
global timecop
config.after_initialize do
# Set Time.now to September 1, 2008 10:05:00 AM (at this instant), but allow it to move forward
t = Time.local(2008, 9, 1, 10, 5, 0)
Timecop.travel(t)
end
@phinze
phinze / osx-postgres-mem.sh
Created January 29, 2013 19:38
In memory postgres database. First cut. Adapted from https://github.com/okfn/ckan/blob/master/bin/osx-postgres-mem.sh
#!/bin/sh
## set up postgres (in this case 9.0 from macports
export PGCTL=/usr/local/bin/pg_ctl
export PGDATA=/Volumes/pgtmp/postgres
case $1 in
start)
## Make a RAM filesystem
diskutil erasevolume HFS+ "pgtmp" `hdiutil attach -nomount ram://1048576`
@phinze
phinze / gist:4559271
Created January 17, 2013 20:10
example of several uses of "end" in ruby
class FooDog
def bark(loud=false)
if loud
puts "BARK"
else
puts "bark"
end
end
end
@phinze
phinze / gist:3196057
Created July 29, 2012 04:27
contents of open source sparrow iphone.zip
.
├── Entitlements.plist
├── PLCrashReporter.h
├── Sparrow-main.a
├── app
│   └── Sparrow.app
│   ├── 1sur3.png
│   ├── 1sur3@2x.png
│   ├── 1sur4.png
│   ├── 1sur4@2x.png