Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/ruby
logfile='logfile.txt'
File.read(logfile).split("\n").each do |ln|
if ln =~ /(^\d\d\d\d-\d\d-\d\d)(.*)(\d\d\d\d-\d\d-\d\d)(.*)/
puts $1 + $2 + $4
else
puts ln
end
end
def initialize
require 'pp'
@word_count = 0
sentence = sentence_to_arr("I The greatest gift of life is friendship, and I have received it.")
puts speak_goat(sentence)
end
def speak_goat(sentence)
sentence.each_with_index do | word, i |
sentence[i] = transform_word(word)
stock = [1,8,3,0,1,54,29,1,3,10,49,10,39,28,41,1,3]
prices= Array.new
stock.each_with_index do |buy_price, buy_index|
stock.each_with_index do |sell_price, sell_index|
if buy_index < sell_index
value = sell_price - buy_price
hr = {sell_index: sell_index, buy_index: buy_index, value: value}
prices << hr
end
end
class OldAmi
require 'aws-sdk'
require 'pp'
require 'date'
def initialize(days_old)
@images = Hash.new
get_regions.each do |region|
@old_amis = list_old_ami(region, days_old)
@amis_to_save = get_amis_to_save(region)
@direction = Hash.new('Unknown')
(351..360).each {|n| @direction[n] = "North" }
(0..10).each {|n| @direction[n] = "North" }
(11..30).each {|n| @direction[n] = "North North East" }
(31..60).each {|n| @direction[n] = "North East" }
(61..80).each {|n| @direction[n] = "East North East" }
(81..100).each {|n| @direction[n] = "East" }
(101..120).each {|n| @direction[n] = "East South East" }
(121..150).each {|n| @direction[n] = "South East" }
(151..170).each {|n| @direction[n] = "South South East " }
@martin2110
martin2110 / wind.rb
Last active September 24, 2015 17:49
DIRECTION = {
north: (351..360).to_a + (0..10).to_a,
north_north_east: (11..30).to_a,
north_east: (31..60).to_a,
east_north_east: (61..80).to_a,
east: (81..100).to_a,
east_south_east: (101..120).to_a,
south_east: (121..150).to_a,
south_south_east: (151..170).to_a,
south: (171..190).to_a,
arr = [1,2,3,4,5,5,6,7,7,7]
track = Hash.new
arr.each_with_index do | num, index |
unless track[num]
track[num] = Array.new
end
track[num].push(index)
end
track.each { |key, value|
if value.count == 1
==> nagios01: ================================================================================
==> nagios01: Recipe Compile Error in /var/chef/cache/cookbooks/mysql/libraries/provider_mysql_service_rhel.rb
==> nagios01: ================================================================================
==> nagios01:
==> nagios01:
==> nagios01: NoMethodError
==> nagios01: -------------
==> nagios01: undefined method `require_relative' for main:Object
==> nagios01:
==> nagios01:
NoMethodError: undefined method `require_relative' for main:Object
/var/chef/cache/cookbooks/mysql/libraries/provider_mysql_service_rhel.rb:3
/usr/lib/ruby/gems/1.8/gems/chef-11.4.0/bin/../lib/chef/run_context/cookbook_compiler.rb:179:in `load'
/usr/lib/ruby/gems/1.8/gems/chef-11.4.0/bin/../lib/chef/run_context/cookbook_compiler.rb:179:in `load_libraries_from_cookbook'
/usr/lib/ruby/gems/1.8/gems/chef-11.4.0/bin/../lib/chef/run_context/cookbook_compiler.rb:176:in `each'
/usr/lib/ruby/gems/1.8/gems/chef-11.4.0/bin/../lib/chef/run_context/cookbook_compiler.rb:176:in `load_libraries_from_cookbook'
/usr/lib/ruby/gems/1.8/gems/chef-11.4.0/bin/../lib/chef/run_context/cookbook_compiler.rb:98:in `compile_libraries'
/usr/lib/ruby/gems/1.8/gems/chef-11.4.0/bin/../lib/chef/run_context/cookbook_compiler.rb:97:in `each'
/usr/lib/ruby/gems/1.8/gems/chef-11.4.0/bin/../lib/chef/run_context/cookbook_compiler.rb:97:in `compile_libraries'
/usr/lib/ruby/gems/1.8/gems/chef-11.4.0/bin/../lib/chef/run_context/cookbook_compiler.rb:7
2014-02-19 20:34:53,696 [1392842093] Warning : Printing stored debug messages prior to our daemonization
2014-02-19 20:35:06,231 [1392842106] Warning : Importing module logstore_mongodb: No module named pymongo
2014-02-19 20:36:57,645 [1392842217] Critical : I got an unrecoverable error. I have to exit
2014-02-19 20:36:57,645 [1392842217] Critical : You can log a bug ticket at https://github.com/naparuba/shinken/issues/new to get help
2014-02-19 20:36:57,646 [1392842217] Critical : Back trace of it: Traceback (most recent call last):
File "/usr/local/shinken/shinken/satellite.py", line 969, in main
self.do_mainloop()
File "/usr/local/shinken/shinken/daemon.py", line 244, in do_mainloop
self.do_loop_turn()
File "/usr/local/shinken/shinken/satellite.py", line 712, in do_loop_turn