Skip to content

Instantly share code, notes, and snippets.

[inodes_alert:log11] 2017/02/28 20:39:40 I! {"Name":"disk","Database":"","RetentionPolicy":"","Group":"host=aws-nv-u-csadb02,path=/net/zfs1/export/analyticsbinning","Dimensions":{"ByName":false,"TagNames":["host","path"]},"Tags":{"host":"aws-nv-u-csadb02","path":"/net/zfs1/export/analyticsbinning"},"Fields":{"inodes_used_percent":0},"Time":"2017-02-28T20:39:40Z"}
[inodes_alert:log11] 2017/02/28 20:39:40 I! {"Name":"disk","Database":"","RetentionPolicy":"","Group":"host=aws-nv-u-csadb02,path=/net/zfs1/export/analyticsdigital","Dimensions":{"ByName":false,"TagNames":["host","path"]},"Tags":{"host":"aws-nv-u-csadb02","path":"/net/zfs1/export/analyticsdigital"},"Fields":{"inodes_used_percent":0},"Time":"2017-02-28T20:39:40Z"}
[inodes_alert:log11] 2017/02/28 20:39:40 I! {"Name":"disk","Database":"","RetentionPolicy":"","Group":"host=aws-nv-u-csadb02,path=/net/zfs1/export/analyticsprojects","Dimensions":{"ByName":false,"TagNames":["host","path"]},"Tags":{"host":"aws-nv-u-csadb02","path":"/net/zfs1/export/analyti
@bayendor
bayendor / inodes_alert.tick
Created February 28, 2017 17:54
Kapacitor alert to warn on inodes percent used
// inodes_alert example
// DEFINE: kapacitor define inodes_alert -type stream -tick inodes_alert.tick -dbrp telegraf.ninety_days
// ENABLE: kapacitor enable inodes_alert
// Parameters
var period = 5m
var every = 30s
var warn = 90
var crit = 95
@bayendor
bayendor / keybase.md
Created April 22, 2016 15:44
keybase.md

Keybase proof

I hereby claim:

  • I am bayendor on github.
  • I am dbayendor (https://keybase.io/dbayendor) on keybase.
  • I have a public key ASB1V69Is1m_YenJTKqCUfMSmusHP5quka8emz0F5BjJNQo

To claim this, I am signing this object:

@bayendor
bayendor / puppet.vim
Created April 4, 2016 14:05
VIM Config settings for working with Puppet
" Set up puppet manifest and spec options
au BufRead,BufNewfile *.pp
\ set filetype=puppet
au BufRead,BufNewfile *_spec.rb
\ nmap <F8 :!rspec --color %<CR>
" Enable indentation matching for =>'s
filetype plugin indent on
" turn off auto adding comments on next line
@bayendor
bayendor / docker
Last active October 6, 2015 15:56 — forked from chernjie/logrotate.d-docker
Logrotate docker logs, copy this file to /etc/logrotate.d/docker
/data/docker/containers/*/*-json.log {
daily
rotate 7
size 100M
compress
delaycompress
missingok
}
@bayendor
bayendor / flatten_clone.rb
Last active August 29, 2015 14:19
Flatten an array in ruby without using `flatten`
def flatten_clone(array, level = -1, result = [])
array.each do |element|
if element.is_a?(Array) && level != 0
flatten_clone element, level - 1, result
else
result << element
end
end
result
end
@bayendor
bayendor / Archaeology.md
Last active August 29, 2015 14:18
Software Archaeology Code Screen Exercise

The cryptic Ruby function takes an array as an argument and returns an array of the items that occur more than once in the original array.

It does this using the inject method specifying an empty Hash as the accumulator. It iterates over each item in the array by referencing the item index position, and passes the resulting item into the accumulator. This builds up a hash of key/value pairs with the key being the item from the initial collection and the value representing the number of times the item appears in the array. It then uses the reject method on the resulting hash and iterates over the hash returning a new array containing the items in self for which the given block is false.

Using idiomatic Ruby a cleaner way to write this function would be:

def show_duplicates(collection)
  collection.select { |element| collection.count(element) > 1 }.uniq
end
@bayendor
bayendor / arctive_record_queries.rb
Last active August 29, 2015 14:15
ActiveRecord Homework for Module 4 of Turing
# Find all the items that have the word "elegant" in it.
items = Item.where("name LIKE ?", "%elegant%")
# Add three orders to a user.
3.times do |i|
user = User.first
order = Order.create!(user_id: user.id)
order.items << Item.find(i + 1)
end
namespace :deploy do
desc "Deploys app to Github & production."
task all: :environment do
if system("rake test:all") == false
puts "The tests fail."
break
end
puts "The tests passed."
require 'rspec'
def sum(numbers)
numbers.inject(0) { |sum, number| sum + number }
end
def product(numbers)
numbers.inject(1) { |sum, number| sum * number }
end