Skip to content

Instantly share code, notes, and snippets.

View bswinnerton's full-sized avatar

Brooks Swinnerton bswinnerton

View GitHub Profile
require 'pry'
class MySet
attr_accessor :objects
def initialize
@objects = []
end
def count
require 'rest-client'
require 'json'
require 'pry'
endpoint_url = 'http://www.reddit.com/r/all.json'
response = RestClient.get(endpoint_url)
parsed_response = JSON.parse(response)
posts = parsed_response["data"]["children"].each_with_object([]) do |post, array|
array << {
upstream app {
# Path to Unicorn SOCK file, as defined previously
server unix:/tmp/unicorn.babblings.sock fail_timeout=0;
}
server {
listen 80;
server_name ror-study-group-3;
# Application root, as defined previously

Submitting homework

So we use Git to track different versions of code (what the code is doesn't really matter; homework, your web application, whatever). One way to accomplish this goal would just to make backups of a folder every day - but that's a huge pain and it's really easy to forget to do. Enter Git: it's a command line utility that allows you to "commit" code to a timeline. This is useful for a few reasons:

  • You can easily see who contributed what code and when
  • If something gets really messed up, you can simply revert your code to a different point in time
  • It allows you to branch out into different features, all while never breaking the core functionality
  • It allows people to collaborate on code

We're doing the same thing with homework, and specifically for this first homework, our "code" is just a file called blog.txt. To actually upload the homework, you'll want to follow these steps:

99.downto(1) do |i|
puts "#{i} #{i.between?(2,99) ? "bottles" : "bottle"} of beer on the wall"
puts "#{i} #{i.between?(2,99) ? "bottles" : "bottle"} bottles of beer!"
puts "You take one down and pass it around,"
puts "#{i} #{i.between?(2,99) ? "bottles" : "bottle"} bottles of beer on the wall!"
puts 'No more bottles of beer on the wall :-(' if i == 1
puts
end
require 'json'
require 'rest-client'
url = 'http://reddit.com/.json'
response = RestClient.get(url)
parsed_response = JSON.parse(response)
posts = parsed_response['data']['children'].map do |post|
{
class Post
attr_accessor :title, :body
@@all = []
def initialize(title, body)
@title = title
@body = body
@@all << self
end
require_relative 'lib/user'
require_relative 'lib/post'
#require 'pry'
brooks = User.new('Brooks', 'brooks@ga.co')
Post.new('Cat takes over the world', 'asdfasdfas', brooks)
Post.new('colbert', 'asdf', brooks)
Post.new('asdf', 'qwer', brooks)
Post.all.each do |post|

Back End Web Development

Rails

Generating a new application

rails new catmosphere
cd catmosphere/

Starting the rails server