Skip to content

Instantly share code, notes, and snippets.

@phinze
phinze / main.tf
Created December 16, 2015 20:43
take a string like "a b c" and turn that in to "a", "b", "c" in the template
variable "input" {
default = "a b c"
}
resource "template_file" "json" {
template = "{ \"somekey\": [${list}] }"
vars {
list = "${join(", ", formatlist("\\"%s\\"", split(" ", var.input)))}"
}
}
@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 / 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
provider "aws" {
access_key = "foo"
secret_key = "bar"
region = "us-east-1"
}
module "vpc" {
source = "./tf_aws_vpc"
name = "keyprovidertest"
@phinze
phinze / moving_vpcs.tf
Last active December 3, 2015 14:49
Example for terraform-tool mailing list of moving a subnet between VPCs
# See https://groups.google.com/d/msgid/terraform-tool/db2ee775-e8b8-4e6b-8b3a-35fb182a1571%40googlegroups.com
# Setting region so AMI always works, configure the rest via env vars
provider "aws" {
region = "us-west-2"
}
resource "aws_vpc" "from" {
cidr_block = "10.1.0.0/16"
}
@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