Skip to content

Instantly share code, notes, and snippets.

@philsof
philsof / useful-ruby-collection-methods.md
Last active January 29, 2018 02:17
Useful Ruby Collection Methods

Useful Enumerable methods (can be called on Hash objects and Array objects):

  • all?
  • any?
  • count
  • each_slice
  • each_with_index
  • each_with_object
  • find
  • find_all
  • find_index
@philsof
philsof / naming-conventions-for-a-many-to-many-table-and-model-in-rails.md
Last active May 12, 2022 14:37
Naming conventions for a many-to-many join table and model in rails

Migration table naming convention: groups_users

Migration file naming convention (the part of the file name that is not automatically generated): create_groups_users

Model class naming convention: GroupsUser

@philsof
philsof / unique-constrait-on-active-record-migration.md
Last active February 11, 2016 20:53
How to implement a unique constrait in an Active Record migration

Here are the docs and here is a highly rated StackOverflow answer. (The docs are pretty long, you will probably want to search the web page for "unique" to find the relevant info.)

Bottom line: You need to create an index and make the index unique:

add_index :table_name, :column_name, :unique => true

Hope this helps. Any questions let me know.

@philsof
philsof / code-review-for-branch-pair-silvestrijonathan-data-drill-stack-and-queue-challenge.md
Last active February 12, 2016 01:37
Code review for branch pair-silvestrijonathan on data-drill-stack-and-queue-challenge 2/11/16

Good stuff, here are my notes on your code:

  • You are getting this, good work! 👍

  • This test does the job. Be aware though: Rspec comes with built-in expect change test capabilities, which can test if an object changes. (For example, if the length of an array increased by 1.) This will come in handy in the very near future.

  • Note: You caught this error while I was writing this! Nice work! Here is what I wrote anyway:

This is a really tricky one to catch and is a good teaching moment: take a look at this test, which currently passes when it

@philsof
philsof / code-review-mirascarvalone-build-a-rails-blog.md
Last active February 10, 2016 21:47
Code review for branch mirascarvalone on challenge build-a-rails-blog 2/10/2016

This is good stuff, here are my notes on your code:

@philsof
philsof / code-review-pair-edwardgemson,kerryimai-build-a-rails-blog.md
Last active February 10, 2016 20:55
Code review for branch pair-edwardgemson,kerryimai challenge build-a-rails-blog 2_10_16

Good work, here are my notes on your code:

@philsof
philsof / code-review-pair-kb-diangelo,kerryimai-behavior-drill-style-editor-challenge-02-01-2016.md
Last active February 2, 2016 01:33
Code review pair-kb-diangelo,kerryimai behavior-drill-style-editor-challenge 02-01-2016

Good work! Your code does the job. Here are my notes on your code:

  • You are utilizing jQuery's on method for a click event on your form's submit button, which works. But there is a better way. Because we are dealing with a form's submit action, you could utilize jQuery's on method for a submit event, which would look like this:

    $('#style_editor').on('submit', function(event) {  //#style-editor is the id of the form

    Notice the submit event only requires you to locate the form (it automatically knows you are referring to the form's submit action). When binding event handlers to form submit actions, you are going to want to utilize this.

Note: You could also utilize jQuery's submit method directly.

@philsof
philsof / code-review-world-s-simplest-browser-challenge-pair-dmandelb,plonsker.md
Last active February 2, 2016 00:49
Code review world-s-simplest-browser-challenge pair-dmandelb,plonsker 02-01-2016.md

Good work! Per your desire to sharpen your MVC skills, here are some detailed notes on your code:

  • You have a puts call in your Display class's initialize method. Instead, you are going to want your Controller to utilize your Display.look_at_this method to print this initial welcome text to the console:

    @viewer.look_at_this("Welcome to the World's Simplest Browser")

Or, you could write a specific Display method for this:

@philsof
philsof / code-review-pair-dthelouie,plonsker-parsing-data-1-csv-in-csv-out-challenge.md
Last active January 29, 2016 17:40
Code review pair-dthelouie,plonsker parsing-data-1-csv-in-csv-out-challenge

This does the job. Good work. Here are my notes on your code:

  • It looks like you unnecessarily separated the parsing work into two methods, your get_list method and your parse_people_objects_from_file method. All of this logic could be contained within parse_people_objects_from_file; there is no need to separate some of the logic into a get_list method. This is how you could combine both methods:

    def parse_people_objects_from_file
      csv_row_objects = []
      CSV.foreach('people.csv', headers: true) do |line|
        csv_row_objects.push(line)
      end
@philsof
philsof / code-review-pair-andy4626,lnagle93-design-drill-argument-order-dependency-challenge.md
Last active January 28, 2016 17:37
Code review pair-andy4626,lnagle93 design-drill-argument-order-dependency-challenge

Good work! Here are my notes on your code: