Skip to content

Instantly share code, notes, and snippets.

@phlipper
phlipper / s3api.sh
Created January 21, 2016 04:48
AWS CLI S3 Update ACLs
aws s3api list-objects --bucket=mys3bucket \
--region=us-west-2 \
--output=text \
--prefix=myprefix \
--query='Contents[].[Key]' | \
xargs -P4 -I % aws s3api put-object-acl \
--acl=public-read \
--region=us-west-2 \
--bucket=mys3bucket \
--key='%'
@phlipper
phlipper / cup.rb
Created April 9, 2015 22:29
TECH603 Day 5 example code - Working with Classes, Containers, and Cups
# shared `label_name` functionality
module Label
def label_name
"[#{self.class.to_s.upcase}] - Has a Label Name"
end
end
# Car - includes `Label`
class Car
include Label
@phlipper
phlipper / warmup.rb
Created April 9, 2015 22:06
TECH603 Day 5 Warmup
# 1. Create a class named Country
class Country
end
# 2. Add the ability to read and write an attribute named "name". This should
# be done using two methods.
# HINT: the writer method has the `=` at the end
# HINT HINT: use an ivar to store the name in the scope of the class
class Country
def name
@phlipper
phlipper / cup.rb
Created April 4, 2015 21:54
TECH603 Day 4 - Working with Cups
# define a class
class Cup
# class definition
def initialize
puts "I am initializing ... I should be a new cup"
@contents = "coffee"
end
def contents
@contents
@phlipper
phlipper / warmup.rb
Created April 4, 2015 21:49
TECH603 Day 4 Warmup
# example used in warmup quiz
def function(a, b = 1)
a = a.to_i
if a == 1
a + 5 / 2
elsif a == 2
a + 5 + 3
elsif a > 2 && a <= 1000
a
@phlipper
phlipper / functions.rb
Created April 2, 2015 15:02
TECH603 Day 3 - Working with functions
a, b = "a", "b"
c = "c"
d = "d"
e = "e"
f = "f"
# define it - ugly style
def function0(arg0, arg1, arg2, arg3, arg4, arg5)
puts "you passed in #{arg0}, #{arg1}, #{arg2}, #{arg3}, #{arg4}, and #{arg5}"
end
@phlipper
phlipper / warmup.rb
Last active August 29, 2015 14:18
TECH603 Day 3 Warmup
# 1. Create a `day_3` directory under the course directory.
# 2. Save this file under the new folder as `warmup.rb`.
# 3. Assign any string value to a variable.
string = "i hope i do well in class today"
# 4. Assign any whole number to a variable.
b = 42
@phlipper
phlipper / countries.json
Created April 2, 2015 14:52
TECH603 Day 2 - Working with JSON data from a file
[
{
"id": "AGO",
"name": "Angola",
"population": 21471618,
"capital": "Luanda",
"latitude": -8.81155,
"longitude": 13.242,
"income_level": "Upper Middle",
"high_income": false
@phlipper
phlipper / country_hashes.rb
Last active August 29, 2015 14:18
TECH603 Day 2 - Working with country data and Hashes
# Convert all of the following country data in to a Hash, like that of Angola
# Angola
angola = {
"id" => "AGO",
"name" => "Angola",
"population" => 21_471_618,
"capital" => "Luanda",
"latitude" => -8.81155,
"longitude" => 13.242,
@phlipper
phlipper / warmup.rb
Created April 2, 2015 14:45
TECH603 Day 2 Warmup
# 1. Create a `day_2` directory under the course directory.
# Check!
# 2. Save this file under the new folder as `warmup.rb`.
# Check!
# 3. Assign your favorite vacation location to a variable called `destination`.
destination = "Spain"
# 4. Assign the number of days you'd like to visit to a variable called