Skip to content

Instantly share code, notes, and snippets.

@dmerrick
dmerrick / cleanup-ecr.rb
Last active August 23, 2020 14:04
Delete old ECR images
#!/usr/bin/env ruby
# this script will delete ECR images that are older than N days
require 'date'
require 'json'
# customize this script
repo = 'snapdocs'
delete_if_older_than = 60 # days
#!/usr/bin/env ruby
# this script takes a list of encoded words,
# and returns the decoded message. for example:
#
# gravity-falls-decoder.rb 4-16-19 11-23-10
#
#
# we'll start by setting up some important variables
#!/usr/bin/env ruby
input = {
foo: [ 1, 2],
bar: [ 3, 4]
}
num_args = input.values.first.size
output = []
[28,14,64]
[46,80,44]
[56,19,44]
[38,65,44]
[28,37,64]
[48,25,44]
[76,44,44]
[42,58,44]
[64,62,44]
[34,31,64]
#!/bin/bash
# wrapper script to include required ENV variables
# set these if the variable is not already set
# c.p. http://stackoverflow.com/a/11686779
export EXAMPLE_INT="${EXAMPLE_INT:=5}"
export EXAMPLE_STRING="${EXAMPLE_STRING:=potatoes}"
# actually run the binary
./bin/binary-name $*

Keybase proof

I hereby claim:

  • I am dmerrick on github.
  • I am dmerrick (https://keybase.io/dmerrick) on keybase.
  • I have a public key ASBfbOy8KJdeAf-NASIA0BQEMCwL2zXV1P-E-_czTSiQWAo

To claim this, I am signing this object:

#!/usr/bin/env ruby
puts "Why is the FBI after you?"
# optional, but you can chain the downcase here
text = gets.chomp.downcase
# the default parameter for String#split is ' ', so you can omit it
words = text.split
# note that since text was only used here, you could have just said:
#words = gets.chomp.downcase.split
# I don't know if the guide goes on to address these points,
# but I thought it might be kinda fun to help you on your path.
if 4 > 5
# ruby programmers tend to use 2 spaces instead of 4 for indentation
# also, even though it's confusing, you'll generally use "puts" instead of "print"
puts "I'm soooo wrong it's painful"
# I like to avoid using parentheses to group things, so I'd rewrite what you had as:
#elsif 4 > 5 != true
#!/usr/bin/env ruby
# this script takes a URL and verifies that
# every css file included loads correctly
require 'open-uri'
require 'nokogiri'
require 'pry' if $DEBUG
url = ARGV.shift || 'https://ifttt.com'
doc = Nokogiri::HTML(open(url).read)
@dmerrick
dmerrick / dmv_alerter.rb
Created October 7, 2014 23:34
Let me know when the DMV line is short!
#!/usr/bin/env ruby
# this script will scrape the CA DMV website for wait times,
# and if the wait is less than a certain threshold, it will
# alert you with an audible message (at least on OS X).
require 'open-uri'
require 'date'
# found from http://apps.dmv.ca.gov/web/fieldoffice.html?number=503
@branch_id = 503