Skip to content

Instantly share code, notes, and snippets.

@mkocher
mkocher / go.mod
Last active June 12, 2023 22:58
nats.go example
module example.com/example
go 1.20
require github.com/nats-io/nats.go v1.27.0
require (
github.com/golang/protobuf v1.5.3 // indirect
github.com/klauspost/compress v1.16.5 // indirect
github.com/nats-io/nats-server/v2 v2.9.17 // indirect
@mkocher
mkocher / pivotal_logos.rb
Created October 9, 2014 01:51
Recipe for a pivotal labs desktop
node.default["background_host"] = "http://cheffiles.pivotallabs.com"
node.default["backgrounds"]["primary"] = %w{blue}.map do |color|
"pivID_#{color}-1004x400.png"
end
node.default["backgrounds"]["secondary"] = ["BackToTheEdward.png"]
node.default['login_icon'] = "tracker_dot"
node['backgrounds'].each do |level, filenames|
directory "#{node['sprout']['home']}/Pictures/Backgrounds#{level.capitalize}" do
mode "0755"
Vagrant.configure('2') do |config|
config.vm.hostname='bosh-lite'
config.vm.box = 'misheska_precise_64'
# vagrant plugin install vagrant-omnibus
config.omnibus.chef_version = "10.28.0"
config.vm.provider :virtualbox do |v, override|
# Boxes are coming from https://github.com/misheska/basebox-packer
|ruby-1.9.3-p194| steuart in ~/workspace/hello
○ → vmc push -t
Failed to load tunnel-dummy-vmc-plugin:
Unable to activate tunnel-dummy-vmc-plugin-0.0.2, because cfoundry-0.5.0 conflicts with cfoundry (~> 0.4.0)
You may need to update or remove this plugin.
Name> foo
>>>
@mkocher
mkocher / gist:4057929
Created November 12, 2012 07:15
gem_package and rvm do not like one another
[2012-11-11T23:11:03-08:00] INFO: Processing gem_package[plist] action install (pivotal_workstation::default_editor line 7)
[2012-11-11T23:11:11-08:00] INFO: Processing ruby_block[Set the default editor] action create (pivotal_workstation::default_editor line 10)
================================================================================
Error executing action `create` on resource 'ruby_block[Set the default editor]'
================================================================================
LoadError
---------
cannot load such file -- plist
@mkocher
mkocher / gist:3651970
Created September 6, 2012 06:12
Using a gem for shared project code
Sharing common code using a gem is a great idea, but it's painful to rapidly iterate in both codebases.
What we settled on something like:
if ENV['LOCAL_GEMS']
gem 'shared_stuff', :path => '~/workspace/shared_stuff'
else
gem 'shared_stuff, :github => 'mkocher/shared_stuff'
end
@mkocher
mkocher / fake.rb
Created September 5, 2012 04:30
Fakes in Ruby
class FileTransferJob
def initialize(ftp_service = FtpService.new)
@ftp_service = ftp_service
end
def do_the_needful
@ftp_service.put("/tmp/the_file_to_send", "/tmp/the_destination")
end
end
module JasmineFixtures
# Saves the markup to a fixture file using the given name
def save_fixture(markup, name)
fixture_path = File.join(Rails.root, '/tmp/js_dom_fixtures')
Dir.mkdir(fixture_path) unless File.exists?(fixture_path)
fixture_file = File.join(fixture_path, "#{name}.fixture.html.erb")
File.open(fixture_file, 'w') do |file|
file.puts(markup)
end
Species = DS.Model.extend({
name: DS.attr('string')
});
Person = DS.Model.extend({
name: DS.attr('string'),
species: DS.belongsTo(Species, { embedded: true })
tags: DS.hasMany(Tag, { embedded: true })
});
execute "check file cache path" do
command "ls #{Chef::Config[:file_cache_path]}"
end