Skip to content

Instantly share code, notes, and snippets.

class User
# justin rarely mutates initially set instance variables
attr_reader :first_name, :last_name, :birth_date
def initialize(first_name, last_name, birth_date=nil)
@first_name = first_name
@last_name = last_name
@birth_date = birth_date
end
# the code
def method_i_want_to_trace
method_a
method_b
end
def method_a
method_a1
method_a2

Backbone Fundamentals

In our case, an AppView will handle the creation of new todos and rendering of the initial todo list. Instances of TodoView will be associated with each individual Todo record. Todo instances can handle editing, updating, and destroying their associated todo.

What is the role of the Backbone Router?

Why is MDB using that as the main point of entry for his app?

See http://addyosmani.github.io/backbone-fundamentals/#routers for a discussion of the router routes: { ':year/:termOne/:termTwo': 'renderGraph' } syntax. It's just a way to add params dynamically. Note that :year and :termOne and :termTwo, when matched, are passed to the renderGraph function like so renderGraph: function (year, termOne, termTwo) { ... }

From Backbone Fundamentals:

In Backbone, routers provide a way for you to connect URLs (either hash fragments, or real) to parts of your application. Any piece of your application that you want to be bookmarkable, shareable, and back-button-able, needs a URL.

An application will usually have at least one route mapping a URL route to a function that determines what happens when a user reaches that route. This relationship is defined as follows: 'route' : 'mappedFunction'

Questions

VCR with AJAX

Suitor app, text_spec.rb.

feature 'Reddit Text Message Alerts' do
  let(:heading) { "PrompText" }
  let(:subreddit) { "romance" }

Constructor functions begin w capital letter and should be preceded by 'new'. Use some_var = new SomeFunction(); to create objects inheriting from SomeFunction.

An object in JS is a dynamic collection of properties.The three basic operations on an object are 'get' (object.name), 'set' (object.name = some_value;), and 'delete' (delete object.name).

JS has prototypes, not classes. Make an object and then create objects that inherit from that object with 'object.create'.

Everything in js except null and undefined is an object.

Objects are passed by reference in js.

ELOQUENT JS -- CONTENTS

new

Just like the notation with braces and colons we have already seen, new is a way to create object values. Instead of specifying all the property names and values, a function is used to build up the object. This makes it possible to define a kind of standard procedure for creating objects. Functions like this are called constructors, and in chapter 8 we will see how to write them.

new

The new keyword provides a convenient way of creating new objects. When a function is called with the word new in front of it, its this variable will point at a new object, which it will automatically return (unless it explicitly returns something else). Functions used to create new objects like this are called constructors. Here is a constructor for rabbits:

JS THE GOOD PARTS -- SCREENCAST

GET THE BOOK "THINKING FAST AND SLOW"

JSLint.com code quality. tells me when i'm using the bad parts of JS

always put curly braces on the right:

return {
 ok: true
~/Desktop/coding_resources/programs/md_notes
16:14:27 davemox@Daves-MacBook-Pro $ bundle exec rspec
................................................................................................*......*...
An error occurred in an after hook
  ActiveRecord::StatementInvalid: PG::ConnectionBad: PQsocket() can't get socket descriptor:             SELECT tablename
            FROM pg_tables
            WHERE schemaname = ANY (current_schemas(false))

  occurred at /Users/davemox/.rvm/gems/ruby-2.0.0-p353@md_notes/gems/activerecord-4.0.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:120:in `async_exec'
.small-12.medium-9.large-9.columns
  = simple_form_for [@collection, @note] do |f|
    = f.input :title, label: false
    .content-form-size= f.input :content, label: false
    #tags
      - @tag_list.each do |tag|
        %a{:style => "display:inline-block", :data => "#{tag.name}", :class => 'button tiny'}= tag.name
    #new_tags
    = text_field_tag 'new_tags', nil, placeholder: "Add additional comma separated tags here"