Skip to content

Instantly share code, notes, and snippets.

View randomcamel's full-sized avatar

Chris Doherty randomcamel

View GitHub Profile

"The reader finds themselves wondering, "does send_data handle an empty array correctly?", and squanders precious seconds scrolling down the page to look. Despite the relief at discovering that of course it does, those seconds--entire, complete, juicy seconds in which the reader might instead be sucking out all the marrow of life, as Mr. Thoreau would no doubt have said when faced with a similar situation--could, at the programmer's discretion, be saved by guarding this call with a kind, if strictly unnecessary, unless."

@randomcamel
randomcamel / hanging_env
Last active August 29, 2015 14:17
/usr/bin/env called from shebang hangs with an invocation that works from the command line.
root@server-12-ubuntu-1404:~# /usr/bin/env PATH=/opt/chef-server/embedded/bin ruby -e 'puts ENV["PATH"]'
/opt/chef-server/embedded/bin
root@server-12-ubuntu-1404:~# cat foo.rb
#!/usr/bin/env PATH=/opt/chef-server/embedded/bin ruby
puts ENV["PATH"]
root@server-12-ubuntu-1404:~# ./foo.rb
^C
root@server-12-ubuntu-1404:~#
@randomcamel
randomcamel / .vagrant.d-Vagrantfile
Created March 31, 2015 16:38
Configure Vagrant to use Polipo on the OS X host as an HTTP(S) caching proxy
# this saves us from both hard-coding an IP, and using a non-bridged IP for the VM.
iface = `ifconfig -l`.match(/(vbox|vmnet.*?) /)[1]
local_ip = `ifconfig #{iface}`.match(/inet (.*?) /)[1]
Vagrant.configure("2") do |config|
if Vagrant.has_plugin?("vagrant-proxyconf")
if `lsof -i |egrep -e '^polipo.*TCP \\*:8123.*LISTEN'`.to_s.empty?
$stderr.puts "lsof doesn't see polipo listening on *:8123; running without a proxy."
elsif local_ip
config.proxy.http = "http://#{local_ip}:8123/"
@randomcamel
randomcamel / gist:2230f591a4ffe1cef7bf
Created July 23, 2015 16:49
driver generator output
mkdir: /Users/cdoherty/repos/chef-dummy/chef-provisioning-fake-generated: File exists
Recipe: (chef-apply cookbook)::(chef-apply recipe)
* directory[lib/chef/provisioning/driver_init] action create (up to date)
* directory[lib/chef/provisioning/fake-generated_driver] action create (up to date)
* file[lib/chef/provisioning/fake-generated_driver.rb] action create (up to date)
* file[lib/chef/provisioning/fake-generated_driver/version.rb] action create (up to date)
* file[lib/chef/provisioning/fake-generated_driver/driver.rb] action create (up to date)
* execute[rspec --init && echo '-fd' >> .rspec] action run (skipped due to not_if)
* file[spec/fake-generated_spec.rb] action create (up to date)
@randomcamel
randomcamel / grargh.rb
Created October 26, 2016 19:26
does this work?
# this creates an instance of the ::Ipaddr Chef resource, named "192.168.1.1"
ipaddr "192.168.1.1"
heartbeat "yeargh" do
<stuff>
# I *think* the "heartbeat" resource will take this and try to find a resource with that name.
resource_groups ["192.168.1.1"]
end
# Install prereqs with Homebrew:
#
# uninstall moreutils if installed:
# `brew uninstall moreutils`
#
# brew install wget
# brew install poppler
# brew install parallel
# brew install moreutils --without-parallel
set -e

This is a bit of history and a bit of a quirk in timing...

The history first...

Vagrant has all manner of provisioners effectively supporting any CM tool as well as supporting plugins to add more. When I started on Packer, I basically copied this model (nit: provisioners aren't pluggable anymore cause no one ever used that functionality but the interfaces are very similar and Packer also supports all manner of CM tool).

@randomcamel
randomcamel / estimating.md
Last active March 1, 2022 23:26
Chris's Software Estimation
  1. know how much roadmap-project work people can do in a week. commonly it's 40-60% of their time. call that PR (for Project Ratio).

  2. make a spreadsheet: [Story, Description, People, Weeks, Person-Weeks].

  3. break the work down into comprehensible pieces, where you feel confident saying things like "this will take 2 people, working full-time, 3 weeks to implement." in particular, break down milestones that deliver value; where, if the business told you to do something else, that would be okay, and the work done wasn't wasted.

  4. fill in your spreadsheet columns appropriately (say 2 people, 3 weeks, 6 Person-Weeks).

  5. sum up the Person-Weeks. ("People" and "Weeks" are for later.)

#!/bin/sh
# uses rsync's hard-link feature to mimic the function and structure of Apple's Time Machine.
# my server's name is 'shiny', which I evidently used to mount on /backup.
TARGET=/backup/shiny
date=`date "+%Y-%m-%dT%H:%M:%S"`
rsync --exclude=.AppleDouble -aCPv --link-dest=$TARGET/current $HOME $TARGET/back-$date
cd $TARGET
@randomcamel
randomcamel / brew-alias.sh
Last active June 16, 2021 20:54
Homebrew went through an irritating phase where you had to use `brew search` instead of `brew cask search`, even though you still had to do `brew cask install`.
brew () {
if [[ "x$1" == "xcask" && "x$2" == "xsearch" ]]; then
echo '`brew cask search` is broken, translating for you...'
shift
/usr/local/bin/brew $*
else
/usr/local/bin/brew $*
fi
}