This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'open3' | |
class Sqs | |
def self.process_messages | |
sqs = Aws::SQS::Client.new(region: ENV.fetch("AWS_REGION"), | |
access_key_id: ENV.fetch("AWS_ACCESS_KEY_ID"), | |
secret_access_key: ENV.fetch("AWS_SECRET_ACCESS_KEY")) | |
queue_url = sqs.get_queue_url(queue_name: ENV.fetch("AWS_SQS_QUEUE_NAME")).queue_url | |
poller = Aws::SQS::QueuePoller.new(queue_url, { client: sqs }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Version": "2012-10-17", | |
"Id": "Policy154...", | |
"Statement": [ | |
{ | |
"Sid": "Stmt15420...", | |
"Effect": "Allow", | |
"Principal": { | |
"AWS": "arn:aws:iam::744...556:user/s3-user" | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Version": "2012-10-17", | |
"Id": "Policy154...", | |
"Statement": [ | |
{ | |
"Sid": "Stmt1542...", | |
"Effect": "Allow", | |
"Principal": { | |
"AWS": "arn:aws:iam::744...556:user/s3-user" | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TEST_CASES = [ | |
[ | |
"For step-by-step directions email someone@gmail.com", | |
"For Step-by-Step Directions Email someone@gmail.com"], | |
[ | |
"2lmc Spool: 'Gruber on OmniFocus and Vapo(u)rware'", | |
"2lmc Spool: 'Gruber on OmniFocus and Vapo(u)rware'"], | |
[ | |
"Have you read “The Lottery”?", | |
"Have You Read “The Lottery”?"], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
array = File.readlines('dutch.bin') # 10k lines | |
Benchmark.bmbm do |x| | |
x.report { | |
x.report("tr") { array.each { |line| line.tr('e', 'z') } } | |
} | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
array = File.readlines('dutch.bin') # 10k lines | |
hash = Hash[*array] # 5k keys => 5k values | |
Benchmark.bmbm do |x| | |
x.report { | |
x.report("Array count") { 10_000.times { array.count } } | |
x.report("Array size") { 10_000.times { array.size } } | |
x.report("Hash count") { 10_000.times { hash.count } } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
require 'set' | |
array = File.readlines('dutch.bin') # 10k lines | |
hash = Hash[*array] # 5k keys => 5k values | |
set = array.to_set # 10k entries | |
line = array[-1] # Last line | |
Benchmark.bmbm do |x| | |
x.report("Array.include?") { 10_000.times { array.include?(line)} } |
OlderNewer