This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This file should contain all the record creation needed to seed the database with its default values. | |
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). | |
# | |
# Examples: | |
# | |
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) | |
# Mayor.create(name: 'Emanuel', city: cities.first) | |
# | |
puts "Adding a Whole bunch of movies" | |
Movie.create [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
git init && git add . && git commit -m 'Initial Commit' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Subteddit | |
def self.add_story(story) | |
@story ||= [] | |
@story << story | |
end | |
def add_story(story) | |
@story ||= [] | |
@story << story | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create simple array | |
array = [1,2,3,4,5] | |
# Iterate through each value | |
array.each {|num| puts num * 20 } | |
puts num | |
# You're gonna have a bad time | |
# plays nice with variable outside | |
x = 2 | |
array.each {|num| puts num * 20 + x } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rebecca Black Friday is the debut single by new Internet sensation Rebecca Black. The music video for "Friday" received over 1 million plays on Youtube in its premiere day. | |
(Yeah, Ah-Ah-Ah-Ah-Ah-Ark) | |
Oo-ooh-ooh, hoo yeah, yeah | |
Yeah, yeah | |
Yeah-ah-ah | |
Yeah-ah-ah | |
Yeah-ah-ah | |
Yeah-ah-ah | |
Yeah, yeah, yeah |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rest-client' | |
require 'json' | |
class Rubeque | |
def initialize | |
@questions = categorize | |
end | |
def categories |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Tab Completion: Press Tab to finish commands/paths | |
Moving around | |
Control + a: Go to the beginning of the line | |
Control + e: Go the the end of the line | |
Option + b: Move back one word | |
Option + f: Move forward one word | |
Deleting | |
Control + k: Delete from current cursor position |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When we last left our application it there were list and task models. They were associated with a list having many tasks and a task belonging to a list. | |
We wanted to build a nested form so we had to let the list model know it has some additional responsibilities. | |
In the List model we had to add this: | |
accepts_nested_attributes_for :tasks | |
This line creates an attribute on the list objects available at :task_attributes. | |
Since rails has mass assignment protection, and we WANT our form to use mass assignment to create tasks through a list we need to white list our new attribute on the attr_accessible line | |
attr_accessible :name, :tasks_attributes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'google_drive' | |
class Transaction | |
def initialize(date, merchant, amount) | |
@date = date | |
@merchant = merchant | |
@amount = amount | |
end | |
def self.all | |
ws.rows.map{|row| Transaction.new row[0], row[1], row[2]} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# We covered a lot in class and I wanted to go over some of the things we discussed in class in more details | |
# First things first! This file is an .rb file. You can run it in your terminal. Try it! | |
##---------------------------------------------------------------------------------------------------- | |
puts "I can haz codingz?" | |
##---------------------------------------------------------------------------------------------------- | |
# Great now comment out that line. We'll have a bunch of code examples you will have to uncomment to get them to run. | |
# Your editor has a short cut for commenting and uncommenting code so don't do this manually. | |
# Ok. Something specific to classes | |
# We mentioned some specific stuff about property 'visibility'. | |
# All that means is what can you ask your object for that won't piss it off. |