Skip to content

Instantly share code, notes, and snippets.

View shaselton's full-sized avatar

Scott Haselton shaselton

  • Southern California, Washington DC
View GitHub Profile
@shaselton
shaselton / vpc.tf
Last active August 8, 2021 04:26
VPC template
# Rough Implementation of the pattern found here: https://medium.com/aws-activate-startup-blog/practical-vpc-design-8412e1a18dcc
provider "aws" {
region = "us-east-1"
}
# create a vpc
resource "aws_vpc" "shaselton" {
cidr_block = "10.0.0.0/16"
enable_dns_hostnames = true
### Keybase proof
I hereby claim:
* I am shaselton on github.
* I am shaselton (https://keybase.io/shaselton) on keybase.
* I have a public key ASAeh-Uh7Pbawb8aS8FoTBkIR9-0KY8fX8m8GzXyBenAcwo
To claim this, I am signing this object:
# Bob is preparing to pass IQ test. The most frequent task in this test is
# to find out which one of the given numbers differs from the others. Bob
# observed that one number usually differs from the others in evenness.
# Help Bob — to check his answers, he needs a program that among the given
# numbers finds one that is different in evenness, and return a position of this number.
# ! Keep in mind that your task is to help Bob solve a real IQ test, which
# means indexes of the elements start from 1 (not 0)
# Examples :
# iq_test("2 4 7 8 10") => 3 // Third number is odd, while the rest of the numbers are even
# Create a simple calculator that given a string of operators (+ - * and /)
# and numbers separated by spaces returns the value of that expression
# Example:
# Calculator.new.evaluate("2 / 2 + 3 * 4 - 6") # => 7
# Remember about the order of operations! Multiplications and divisions have
# a higher priority and should be performed left-to-right. Additions and
# subtractions have a lower priority and should also be performed left-to-right.
# Description:
# Implement a function called makeAcronym that returns the first letters of each word in a passed in string.
# Make sure the letters returned are uppercase.
# If the value passed in is not a string return 'Not a string'
# If the value passed in is a string which contains only characters other than spaces and alphabet letters, return 'Not letters'
# EXAMPLES:
# 'Hello codewarrior' -> 'HC'
# '42' -> 'Not letters'
def validBraces(string)
opening_character = ['(', '[', '{']
closing_character = [')', ']', '}']
string.split('').each_with_object([]) do |character, stack|
if opening_character.include?(character)
stack << character
else
return false if closing_character.index(character) != opening_character.index(stack.pop)
end
@shaselton
shaselton / hash_tag.rb
Last active April 2, 2016 18:28
You start working for a fancy new startup hoping to revolutionize social networking! GASP! They had this great idea that users should be able to specify relevant keywords to their posts using an ingenious idea by prefixing those keywords with the pound sign (#). Your job is to extract those keywords so that they can be used later on for whatever…
def parse_hash_tags(str)
str.split(' ').select{ |word| /^#+([a-zA-Z])/.match(word) }.map{ |hash_tag| hash_tag.gsub(/^#+/, '') }
end
@shaselton
shaselton / gist:10d45a3aa328227ff137
Created March 26, 2016 22:25
Weekly Challenges 3-26-16
def leftpad(str, len, ch = '')
return str if str.size >= len
(Array.new(len - str.size, ch) + str.split('')).join('')
end
puts leftpad('hello', 10, 'w')