Skip to content

Instantly share code, notes, and snippets.

View randomcamel's full-sized avatar

Chris Doherty randomcamel

View GitHub Profile
@randomcamel
randomcamel / bunny_test.rb
Created January 4, 2012 04:47
Script to load a queue and then cause the error 'Error subscribing to queue qtest.broadcast (Bunny::ProtocolError)'
#!/usr/bin/env ruby
require 'rubygems'
require 'bunny'
# Chris Doherty, confused by Bunny::Queue#subscribe semantics.
# run with `ruby bunny_test.rb load` followed by `ruby bunny_test.rb consume`.
class BunnyTest
@randomcamel
randomcamel / separate_worker.rb
Last active December 11, 2015 14:48
Trying to separate out the process that submits jobs from the process that executes them. Under 1.8.7, the Worker doesn't pick up the job submitted by the 'run' case: the join() command just waits.
require 'rubygems'
require 'ruote' # 2.3.0.2
require 'ruote/storage/fs_storage'
def get_storage
Ruote::FsStorage.new("ruote_issue_work")
end
class MyParticipant < Ruote::Participant
@randomcamel
randomcamel / gist:5522598
Created May 5, 2013 23:42
Chef context of carbon-cache failing to start in the graphite-chef recipe.
[2013-05-05T23:37:03+00:00] INFO: Processing service[carbon-cache] action enable (graphite::carbon line 68)
[2013-05-05T23:37:03+00:00] INFO: Processing service[carbon-cache] action start (graphite::carbon line 68)
================================================================================
Error executing action `start` on resource 'service[carbon-cache]'
================================================================================
@randomcamel
randomcamel / hanging-celluloid-inspect.rb
Created July 26, 2013 00:51
If I try to call #inspect on an actor with an active Notifications subscription, it hangs. If you comment out either the `#inspect` call or the subscription, the program runs and exits quickly.
# Chris Doherty, code@randomcamel.net
require "celluloid"
require "celluloid/autostart"
class Cell
include Celluloid
include Celluloid::Notifications
attr_reader :count
@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).

#!/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
}

Keybase proof

I hereby claim:

  • I am randomcamel on github.
  • I am cdoherty (https://keybase.io/cdoherty) on keybase.
  • I have a public key ASAFza9EFloxNSHqh-7qr53alNEQhr8gDAdEakMs6ELSDwo

To claim this, I am signing this object: