Skip to content

Instantly share code, notes, and snippets.

Avatar

Johan Ekenlycka quezacoatl

View GitHub Profile
@quezacoatl
quezacoatl / flatten.rb
Created Apr 3, 2018
Flatten array in Ruby
View flatten.rb
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 Sep 16, 2016
CloudFront format for request-log-analyzer
View cloud_front.rb
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
Ruby 2.2.X AWS SDK memory leak
View Gemfile
source 'https://rubygems.org'
gem 'nokogiri'
gem 'aws-sdk'
gem 'fake_sqs'
gem 'newrelic_rpm'
@quezacoatl
quezacoatl / Gemfile
Created Mar 5, 2015
AWS SDK 2.0.29 XML parsing issue
View Gemfile
source 'https://rubygems.org'
#gem 'nokogiri'
gem 'aws-sdk', '~> 2'
You can’t perform that action at this time.