Monday, December 23, 2013

Xmas Pet App with Hannah Howard

Hannah and I met up today at Silverlake Coffee to work on an app for her partner Ben for Christmas. We should have gotten together sooner because we ended up spending a lot of time yak shaving but didn't actually get much done. Here is some of the stuff we were dealing with to work together on this project...

Hannah is working on the newest versions of Ruby and Rails which means I have finally reached a point where I need to start using RVM a Ruby version manager.

https://rvm.io/rvm/install 
$ jen@sandinista ~/Desktop/poochpapa $ gvim .ruby-version
$ jen@sandinista ~/Desktop/poochpapa $ gvim .ruby-gemset 
* To start using RVM you need to run `source /home/jen/.rvm/scripts/rvm` in all your open shell windows, in rare cases you need to reopen all shell windows.
http://rvm.io/rvm/basics

Hannah made me a collaborator at https://github.com/hannahhoward/poochpapa.git

Ben's website for his pet sitting service: http://www.poochpapa.com/
Ben's favorite color: brown earth tones orange ocre reese pieces

Hannah is also using Postgres as her database so I downloaded it but couldn't install it. I think I need more permissions and Lars' help.

Saturday, December 21, 2013

Refactoring w/ Cynthia, Frances & REve

Grep-ing is incredibly useful when looking for something in a file you are unfamiliar with
  $ grep -rn "whatever you are looking for" . 
-r means recursively which means your computer will look in a file if it is not there then it will keep looking until there is m=nothing else to look for
n is line number
. the dot at the end means look through everything

git branch -av
   a is all
   v is verbose

git remote add upstream_user https://github.com/user/repo.git

simplecov - ruby gem that reports how much of your code is covered by tests

Add to your Gemfile

group :test, :development do  
  gem 'hpricot'  
  gem 'simplecov', :require => false #code coverage thingy
end

Add to top of tests  test.rb

  # -*- coding: utf-8 -*-
  # Tests designed to run with autotest.
 require 'simplecov'
 SimpleCov.start
  require 'test/unit'
  require 'fileutils' # for saving downloaded XML
  $LOAD_PATH << './lib'
  require 'reve'

cattr_reader so you can read the class level variable in the instance of the class

    module Class #:nodoc:
      def cattr_reader(*syms) #:nodoc:
        syms.flatten.each do |sym|
          next if sym.is_a?(Hash)
          class_eval(<<-EOS, __FILE__, __LINE__)
            unless defined? @@#{sym}
              @@#{sym} = nil
            end

            def self.#{sym}
              @@#{sym}
            end

            def #{sym}
              @@#{sym}
            end
          EOS
        end
      end

      def cattr_writer(*syms) #:nodoc:
        options = syms.last.is_a?(Hash) ? syms.pop : {}
        syms.flatten.each do |sym|
          class_eval(<<-EOS, __FILE__, __LINE__)
            unless defined? @@#{sym}
              @@#{sym} = nil
            end

            def self.#{sym}=(obj)
              @@#{sym} = obj
            end
            #{"
            def #{sym}=(obj)
              @@#{sym} = obj
            end
            " unless options[:instance_writer] == false }
          EOS
        end
      end
      def cattr_accessor(*syms) #:nodoc:
        cattr_reader(*syms)
        cattr_writer(*syms)
      end
    end


Tuesday, December 17, 2013

Rails Tutorial 3.3

Rspec  Should vs. Expect

https://www.relishapp.com/rspec/rspec-expectations/v/2-0/docs/matchers/expect-change
http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
http://betterspecs.org/

In Rspec have_title is a method which checks for an HTML title within the given content

I always forget what .erb stands for. It is embedded Ruby.

Rails method
provide
<% provide(:title, 'Home') %>
<%= yield(:title) %>
The distinction between the two types of embedded Ruby is that <% ... %> executes the code inside, while <%= ... %> executes it and inserts the result into the template.

Thursday, November 7, 2013

Notes - Rails Tutorial Chapter 3.2 - Integration Tests vs. Unit Tests

Integration Tests vs. Unit Tests

Unit Tests

A unit test is a test written by the programmer to verify that a relatively small piece of code is doing what it is intended to do. They are narrow in scope, they should be easy to write and execute, and their effectiveness depends on what the programmer considers to be useful. The tests are intended for the use of the programmer, they are not directly useful to anybody else, though, if they do their job, testers and users downstream should benefit from seeing less bugs.   ~ Nathan Hughes

Integration Tests

An integration test is done to demonstrate that different pieces of the system work together. Integration tests cover whole applications, and they require much more effort to put together. They usually require resources like database instances and hardware to be allocated for them. The integration tests do a more convincing job of demonstrating the system works (especially to non-programmers) than a set of unit tests can, at least to the extent the integration test environment resembles production.
Actually "integration test" gets used for a wide variety of things, from full-on system tests against an environment made to resemble production to any test that uses a resource (like a database or queue) that isn't mocked out.

Wednesday, November 6, 2013

Cal Tech & POODR Ch 1 & 2

Yesterday I started re-reading Practical Object-Oriented Design with Ruby by Sandi Metz. I got through half of Chapter 2. I didn't re-read Chapter 1 because I remember the main ideas from it.

Chapter 2 starts out with a bicycle. A good way to start if you ask me. There is talk about gearing. I never really thought that much about this. I put my bike in a low gear for going up the hill and a large gear for going down the hill. But what does that really mean mechanically? Fixed gear people talk about their gear ratios but I always tuned those conversations out because I am too clumsy for a fixie. I do have a single gear bike but I have no idea what the ratio is. It just goes. And the people who have 2 different sized wheels are just taking it to another level that I have previously been uninterested in.

Sandi Metz has made me think about all of this stuff. The most I can say is at least I knew it existed so that is something. 

We are trying to figure out the gear ratio of a bike.

Friday, October 25, 2013

My Bundler Feature was Merged

My PR to Bundler  was merged!
This fixes the issue: Warn if the same gem (same version) is added twice. bundler/bundler-features#22

Try it out: Open a Gemfile in on of your projects and duplicate one of your gems.
do a bundle install
You should get a warning telling you that you have a duplicated gem and what it is.
This is the warning you'll see:

"Your Gemfile lists the gem #{current.name} (#{current.requirement}) more than once. You should probably keep only one of them. While it's not a problem now, it could cause errors if you change the version of just one of them later."
Yay!!

Wednesday, October 23, 2013

New Relic Rocks

So I am here in San Francisco for the Future Stack Conference because New Relic gave Rails Girls a scholarship. Someone else was supposed to come but she couldn't make it and I was next on the list. So New Relic paid for me to fly here, sent a car for me; a fancy, shiny, black car which dropped me off for a 3 night stay at the Grand Hyatt Hotel in Union Sq. My room is amazing. Then I got an amazing goody bag with a cool Future Stack tote, t-shirt, stickers, other swag and a generous food stipend. Wow. I won the scholarship lottery.

I walked around Union Sq. for hours today shopping for the perfect scarf. The first one I found is the one I ended up buying many hours later. I got a nice lunch and dinner. Now am in my pajamas relaxing and getting ready for the long day and night tomorrow.