###Cheat Sheet
####Arrays
Creating Arrays
my_array = ["Apples", "Oranges", "Pears"]| /* | |
| * Normalized hide address bar for iOS & Android | |
| * (c) Scott Jehl, scottjehl.com | |
| * MIT License | |
| */ | |
| (function( win ){ | |
| var doc = win.document; | |
| // If there's a hash, or addEventListener is undefined, stop here | |
| if( !location.hash && win.addEventListener ){ |
###Cheat Sheet
####Arrays
Creating Arrays
my_array = ["Apples", "Oranges", "Pears"]| # Teddit Contionals - Solution Code. | |
| # Let's add a new Teddit feature. Upvotes! | |
| def get_input | |
| gets.strip | |
| end | |
| def calculate_upvotes(story, category) | |
| upvotes = 1 |
###Cheat Sheet
####What is a Framework?
...a software framework is an abstraction in which software providing generic functionality can be selectively changed by additional user written code.
‐ via Wikipedia You use libraries, frameworks use you.
###Deploying to Heroku (Heroku official instructions)
##Initial Heroku set-up
##Set up PostgreSQL
| # BEWD2 optimized solution for 99 bottles | |
| def pluralize(word, count) | |
| "#{count} #{word}#{'s' unless count == 1}" | |
| end | |
| def sing_bottles(count) | |
| pluralized_count = pluralize("bottle", count) | |
| puts "#{pluralized_count} of beer on the wall" | |
| puts "#{pluralized_count} of beer" | |
| puts "#{pluralize("bottle", count - 1)} of beer on the wall!" |
| In class we integrated the Mashable and Digg APIs into the Teddit exercise. | |
| For Homework integrate the Reddit API as one of the news sources: http://www.reddit.com/.json | |
| Homework due on Tuesday, August 19. |
| # We're going to add a remote data source to pull in stories, Digg and Mashable. | |
| # http://mashable.com/stories.json | |
| # http://digg.com/api/news/popular.json | |
| # These stories will also be upvoted based on our rules. No more user input! | |
| # Pull the json, parse it and then make a new story hash out of each story(Title, Category, Upvotes) | |
| # Add each story to an array and display your "Front page" | |
| require 'json' | |
| require 'rest-client' |