Skip to content

Instantly share code, notes, and snippets.

Phil Cohen phlipper

Block or report user

Report or block phlipper

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@phlipper
phlipper / s3api.sh
Created Jan 21, 2016
AWS CLI S3 Update ACLs
View s3api.sh
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 Apr 9, 2015
TECH603 Day 5 example code - Working with Classes, Containers, and Cups
View cup.rb
# 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 Apr 9, 2015
TECH603 Day 5 Warmup
View warmup.rb
# 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 Apr 4, 2015
TECH603 Day 4 - Working with Cups
View cup.rb
# 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 Apr 4, 2015
TECH603 Day 4 Warmup
View warmup.rb
# 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 Apr 2, 2015
TECH603 Day 3 - Working with functions
View functions.rb
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 Aug 29, 2015
TECH603 Day 3 Warmup
View warmup.rb
# 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 Apr 2, 2015
TECH603 Day 2 - Working with JSON data from a file
View countries.json
[
{
"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 Aug 29, 2015
TECH603 Day 2 - Working with country data and Hashes
View country_hashes.rb
# 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 Apr 2, 2015
TECH603 Day 2 Warmup
View warmup.rb
# 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
You can’t perform that action at this time.