Skip to content

Instantly share code, notes, and snippets.


Brooks Swinnerton bswinnerton

View GitHub Profile
View set.rb
require 'pry'
class MySet
attr_accessor :objects
def initialize
@objects = []
def count
View reddit.rb
require 'rest-client'
require 'json'
require 'pry'
endpoint_url = ''
response = RestClient.get(endpoint_url)
parsed_response = JSON.parse(response)
posts = parsed_response["data"]["children"].each_with_object([]) do |post, array|
array << {
View babblings.nginx.conf
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:

View bottles_of_beer.rb
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
View reddit_api.rb
require 'json'
require 'rest-client'
url = ''
response = RestClient.get(url)
parsed_response = JSON.parse(response)
posts = parsed_response['data']['children'].map do |post|
View post.rb
class Post
attr_accessor :title, :body
@@all = []
def initialize(title, body)
@title = title
@body = body
@@all << self
View main.rb
require_relative 'lib/user'
require_relative 'lib/post'
#require 'pry'
brooks ='Brooks', '')'Cat takes over the world', 'asdfasdfas', brooks)'colbert', 'asdf', brooks)'asdf', 'qwer', brooks)
Post.all.each do |post|

Back End Web Development


Generating a new application

rails new catmosphere
cd catmosphere/

Starting the rails server