Skip to content

Instantly share code, notes, and snippets.

# Use vi keybindings in copy and choice modes
setw -g mode-keys vi
# Vim-style copy/paste
unbind [
bind ` copy-mode
unbind p
bind p paste-buffer
bind -t vi-copy H start-of-line
bind -t vi-copy L end-of-line
@acrmp
acrmp / 00_README.md
Created November 10, 2012 00:05
Mocking out a library in Chef

Example of mocking out a library in Chef so you can test the provider in isolation.

If you want to test the library itself you can do more normal Ruby things.

@acrmp
acrmp / reboot_spec.rb
Created October 31, 2012 02:42
retr0h
require "chefspec"
require 'mixlib/shellout'
require "ostruct"
require ::File.join ::File.dirname(__FILE__), "..", "files", "default", "reboot"
describe Reboot do
::Chef::ShellOut.class_eval do
def run_command
true
end
@acrmp
acrmp / default.rb
Created October 16, 2012 17:25
FC019 Dot Notation support
Chef::Log.info node[:kernel][:machine]
Chef::Log.info node[:kernel][:machine]
Chef::Log.info node.kernel.machine
@acrmp
acrmp / example-tmux-guard.yml
Created July 13, 2012 00:06
tmuxinator config
project_name: example-tmux-guard
project_root: .
rvm: 1.9.3@example-project
tabs:
- 'minitest-chef-example':
layout: 3937,104x35,0,0[104x27,0,0{52x27,0,0,51x27,53,0},104x7,0,28]
panes:
- vim example-project/cookbooks/example/files/default/tests/minitest/default_test.rb
- vim example-project/cookbooks/example/recipes/default.rb
- 'cd example-project && bundle exec guard'
@acrmp
acrmp / mysql_test.rb
Created March 19, 2012 23:34
minitest-chef-handler
require 'minitest/spec'
module MiniTest::Chef::Resources
include Chef::Mixin::ConvertToClassName
def self.register_resource(resource)
define_method(resource) do |name|
clazz = Chef::Resource.const_get(convert_to_class_name(resource.to_s))
res = clazz.new(name, run_context)
@acrmp
acrmp / custom-functions.rb
Created March 14, 2012 23:43
Nokogiri custom xpath function segfault
require 'nokogiri'
xml = %q{
<foo>
<foo/>
</foo>
}
doc = Nokogiri::XML.parse(xml)
puts doc.xpath('//foo[bool_function(bar/baz)]', Class.new {