Skip to content

Instantly share code, notes, and snippets.

@talum
talum / csv_admissions.txt
Last active November 10, 2016 23:12
cpb_admissions_csv
file = "#{Rails.root}/tmp/#{Date.current}-cpb-admissions-list.csv"
CSV.open(file, 'w') do |csv|
csv << ["name", "hubspot_link", "enrollment program", "payment plan", "enrollment status", "salesforce contact link", "admission decision"]
CpbApplication.all.joins(:user).order(reviewed_at: :desc).each do |cpb_application|
cpb_presenter = CpbApplicationReviewPresenter.new(cpb_application)
csv << [cpb_presenter.name, cpb_presenter.hubspot_profile_link, cpb_presenter.enrollment_program, cpb_presenter.enrollment_payment_plan, cpb_presenter.enrollment_status, cpb_presenter.salesforce_contact_link, cpb_application.user.program_admissions.where(program_id: 'community_powered_bootcamp').first.try(:status)]
end
end
@talum
talum / programming_phoenix.md
Last active August 2, 2017 03:12
programming phoenix ch3/4 notes

Programming Phoenix Ch 3: Controllers & Views

connection the whole universe of things we need to know about the user's request (a struct, map with known set of fields)

connection
|> endpoint
|> router
|> browser_pipeline
|&gt; UsersController
@talum
talum / graphql query
Created August 11, 2017 02:46
fun graphql query
lol
@talum
talum / programming_phoenix_ch_6.md
Last active August 17, 2017 03:05
programming phoenix ch 6 generators and relationships

Programming Phoenix Chapter 6: Generators and Relationships

Generating Resources

  • phoenix.gen.html
  • phoenix.gen.json

"At the end of the day, it ends up adding complexity to the framework—and, indirectly, to your application—only to save a few keystrokes every once in a while. " (p.93)

ex) mix phoenix.gen.html Video videos user_id:references:users url:string title:string description:text

@talum
talum / ch_7.md
Created August 23, 2017 03:40
programming_phoenix ch 7

Programming Phoenix Ch. 7

  • database constraints, adding associations with references p. 109 - makes sure the category_id referenced in videos exists
  • i.e. make the database maintain integrity
  • uniqueness constraint on categories, to prevent dupes. esp. when running seed file twice

Ecto Queries

  • are composable, can define in chunks
  • This strategy works because Ecto defines something called the queryable protocol. from receives a queryable, and you can use any queryable as a base for a new query. (p. 112)
@talum
talum / programming_phoenix_ch_9.md
Created September 6, 2017 03:24
programming phoenix ch 9

Programming Phoenix: Chapter 9

Brunch

  • build tool
  • interface for player

Changeset Benefits

  • separate policy for each type of change
  • filter / cast incoming data
  • validate data (length or format)
@talum
talum / programming_phoenix_ch_10.md
Created September 13, 2017 02:47
programming phoenix ch 10

Programming Phoenix: Chapter 10 Channels

Channel

  • single client on page connects directly with a process on the server called a channel
  • cilents & servers talk directly to each other
  • channel sends, receives, message aand keeps state
  • messages are events
  • state is in a struct called socket
  • phoenix conversation is about a topic
  • each user's conversation on a topic has its own isolated, dedicated process
@talum
talum / programming_phoenix_ch_11.md
Created September 20, 2017 11:09
programming phoenix ch 11

Programming Phoenix Ch 11 : OTP

Managing State with Processes

  • Use concurrency and recursion to manage state
  • separate of client and server
  • used diff abstractions for asynchronous and synchronous communication with server

Building GenServers for OTP

  • don't need to worry about ref
  • GenServer in control of receive loop
@talum
talum / agile_notes_ch4.md
Last active February 13, 2018 03:54
agile

Chapter 4: Adopting XP

Prerequisites

  1. Management Support
    • workspace w/ pairing stations
    • team members solely allocated to project
    • on-site non engineers
    • "Acceptance of new ways of demonstrating progress and showing results"
    • patience while we learn

Chapter 5 Separating Responsibilities

Code: https://github.com/talum/99bottles/commit/3120ccc3aa7d7227bc6fb1513bc770e4652aeb5d

Summary: "This chapter explores what it means to model abstractions and rely on messages; it considers the consequences of mutation and the perils of premature performance optimization." Sandi Metz, Katrina Owen. 99 Bottles of OOP (Kindle Locations 5107-5108).

On refactoring and chapter 4 changes: "The truth about refactoring is that it sometimes makes things worse, in which case your efforts serve gallantly to disprove an idea." Sandi Metz, Katrina Owen. 99 Bottles of OOP (Kindle Locations 5096-5097).

5.1 Code Smell