Skip to content

Instantly share code, notes, and snippets.

View tedi's full-sized avatar
🖤

Tedi Konda tedi

🖤
View GitHub Profile
# 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'
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.
# 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!"

###Deploying to Heroku (Heroku official instructions)

##Initial Heroku set-up

  • Sign up for Heroku
  • Download Heroku toolbelt
  • Log in to Heroku from terminal (execute command heroku login)

##Set up PostgreSQL

  • Replace the sqlite3 gem with pg in the gem file
  • Run bundle install

###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.

# 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

####Arrays

Creating Arrays

my_array = ["Apples", "Oranges", "Pears"]
@tedi
tedi / hideaddrbar.js
Created March 9, 2012 20:44 — forked from scottjehl/hideaddrbar.js
Normalized hide address bar for iOS & Android
/*
* 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 ){