Skip to content

Instantly share code, notes, and snippets.

@quezacoatl
quezacoatl / flatten.rb
Created April 3, 2018 06:51
Flatten array in Ruby
def flatten(arr, flat=[])
arr.each_with_object(flat) do |item, result|
if item.is_a?(Array)
flatten(item, flat)
else
result << item
end
end
end
@quezacoatl
quezacoatl / cloud_front.rb
Created September 16, 2016 06:07
CloudFront format for request-log-analyzer
class CloudFront < RequestLogAnalyzer::FileFormat::Base
extend RequestLogAnalyzer::FileFormat::CommonRegularExpressions
line_definition :access do |line|
line.header = true
line.footer = true
line.regexp = /^(#{timestamp('%Y-%m-%d %H:%M:%S')})\s(\w+)\s(\d+)\s(#{ip_address})\s(\w+)\s(\S+)\s(\S+)\s(\d+)\s(\S+)\s(\S+)\s(\S+)\s(\S+)\s(\w+)\s(\S+)\s(\S+)\s(\w+)\s(\d+)\s(\S+)\s(#{ip_address}|-)\s+(\S+)\s(\S+)\s(\w+)\s(\S+)/
line.capture(:timestamp).as(:timestamp)
@quezacoatl
quezacoatl / Gemfile
Last active May 10, 2016 02:11
Ruby 2.2.X AWS SDK memory leak
source 'https://rubygems.org'
gem 'nokogiri'
gem 'aws-sdk'
gem 'fake_sqs'
gem 'newrelic_rpm'
@quezacoatl
quezacoatl / Gemfile
Created March 5, 2015 07:32
AWS SDK 2.0.29 XML parsing issue
source 'https://rubygems.org'
#gem 'nokogiri'
gem 'aws-sdk', '~> 2'