Skip to content

Instantly share code, notes, and snippets.

View KAllan357's full-sized avatar

Kyle Allan KAllan357

  • Singularity 6
  • Philadelphia, PA
View GitHub Profile
@KAllan357
KAllan357 / FindMissingNumber.groovy
Created April 28, 2011 22:02
Accepts an array of integers from 1-N in which one number is missing. N is equal to the length of the array minus 1.
#!/usr/local/bin/groovy
def findMissingNumber(def a) {
lowerSum = a.inject(0, {
sum, it -> sum += it
})
upperSum = (1..(a.size + 1)).inject(0, {
sum, it -> sum += it
})
@KAllan357
KAllan357 / nexus_cookbook_snippet.rb
Created August 2, 2012 00:27
logic for finding a Nexus install's optional-plugins and making a symlink for it
available_plugins = Dir.entries("#{node[:nexus][:home]}/nexus/WEB-INF/optional-plugins")
node[:nexus][:plugins].each do |plugin|
matched_plugin = available_plugins.find{|plugin_dir| plugin_dir.match(plugin)}
link "#{node[:nexus][:home]}/nexus/WEB-INF/plugin-repository/#{matched_plugin}" do
to "#{node[:nexus][:home]}/nexus/WEB-INF/optional-plugins/#{matched_plugin}"
end
end
diff --git a/lib/chef/provider/link.rb b/lib/chef/provider/link.rb
index b8017c4..9f4723e 100644
--- a/lib/chef/provider/link.rb
+++ b/lib/chef/provider/link.rb
@@ -93,7 +93,7 @@ class Chef
@current_resource.link_type != @new_resource.link_type
if @current_resource.to # nil if target_file does not exist
converge_by("unlink existing file at #{@new_resource.target_file}") do
- ::File.unlink(@new_resource.target_file)
+ file_class.unlink(@new_resource.target_file)
link("C:\test\current") do
provider Chef::Provider::Link
action [:delete, :create]
retries 0
retry_delay 2
to "C:/test/releases/50.4"
link_type :symbolic
target_file "C:\\test\\current"
cookbook_name :my_test
owner "Administrator"
#7:/Users/kallan/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/winrm-1.1.2/lib/winrm.rb:29::-: require 'winrm/soap_provider'
#7:/Users/kallan/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/winrm-1.1.2/lib/winrm/soap_provider.rb:19::-: require 'httpclient'
...
#7:/Users/kallan/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/httpclient-2.2.0.2/lib/httpclient/auth.rb:30::-: require 'gssapi'
#7:/Users/kallan/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/gssapi-1.0.3/lib/gssapi.rb:6::-: require 'ffi'
...
#7:/Users/kallan/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/ffi-1.6.0/lib/ffi/library.rb:101:FFI::Library:-: begin
#7:/Users/kallan/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/ffi-1.6.0/lib/ffi/library.rb:102:FFI::Library:-: lib = FFI::DynamicLibrary.open(libname, lib_flags)
Trace/BPT trap: 5
[default] -- /vagrant
[default] -- C:/mounted-packages
An error occurred executing a remote WinRM command.
Shell: powershell
Command: function which {
$command = [Array](Get-Command $args[0] -errorAction continue)
write-host $command[0].Definition
}
diff --git a/lib/ridley/host_connector/winrm/command_uploader.rb b/lib/ridley/host_connector/winrm/command_uploader.rb
index 728f7ed..f32b285 100644
--- a/lib/ridley/host_connector/winrm/command_uploader.rb
+++ b/lib/ridley/host_connector/winrm/command_uploader.rb
@@ -20,23 +20,27 @@ module Ridley
CHUNK_LIMIT = 1024
- # @return [String]
- attr_reader :command_string
current_path = "C:/foo"
execute ::File.join(current_path, "start_my_thing.bat") do
only_if {
node[:my_thing][:running]
}
end
# [2013-05-01T17:30:12-07:00] INFO: execute[C:/foo/start_my_thing.bat] ran successfully
# MyThing.exe in Task Manager
[internal-services|root@nexus01 (16:30:52):timeline]# ls index/
_cctp.fdt _cctp.fdx _cctp.fnm _cctp.frq _cctp.nrm _cctp.prx _cctp.tii _cctp.tis _cctq.cfs _cctr.cfs _ccts.cfs _cctt.cfs _cctu.cfs _cctv.cfs _cctw.cfs segments_azcc segments.gen write.lock
chef:recipe > remote_file "maven.tar.gz" do
chef:recipe > source "http://apache.osuosl.org/maven/maven-3/3.0.5/binaries/apache-maven-3.0.5-bin.tar.gz"
chef:recipe ?> checksum "adsjflasdjfljladfj"
chef:recipe ?> action :create
chef:recipe ?> end
=> <remote_file[maven.tar.gz] @name: "maven.tar.gz" @noop: nil @before: nil @params: {} @provider: Chef::Provider::RemoteFile @allowed_actions: [:nothing, :create, :delete, :touch, :create_if_missing] @action: [:create] @updated: false @updated_by_last_action: false @supports: {} @ignore_failure: false @retries: 0 @retry_delay: 2 @source_line: "(irb#1):1:in `irb_binding'" @elapsed_time: 0 @resource_name: :remote_file @path: "maven.tar.gz" @backup: 5 @diff: nil @source: "http://apache.osuosl.org/maven/maven-3/3.0.5/binaries/apache-maven-3.0.5-bin.tar.gz" @cookbook: nil @cookbook_name: nil @recipe_name: nil @checksum: "adsjflasdjfljladfj">
chef:recipe > run_chef
[2013-05-24T22:16:20+00:00] INFO: Processing remote_file[maven.tar.gz] action create ((irb#1) line 1)
[