Skip to content

Instantly share code, notes, and snippets.

View tmikeschu's full-sized avatar

Mike Schutte tmikeschu

View GitHub Profile

SourceTrack

  • Wish-I-Hads

  • High

  • Low

  • Looking forward to

SourceTrack

  • Wish-I-Hads

  • High

  • Low

  • Looking forward to

Sourcery

Wish-I-Hads
High
Low
Looking forward to
Would like to change
Completed
Working On
What I need / What I'm stuck with

def turing_transform(person)
4.times do
person.destroy_confidence
person.teach_some_stuff
person.take_lots_of_money
person.reduce_melanin
person.throw_a_little_morsel_of_confidence
person.make_some_great_friends
end
person
def top_3_words(text)
sterilized_words(text).reduce({}, &count_words)
.sort_by(&by_count).map(&first).reverse.take(3)
end
def count_words
lambda do |result, word|
result[word] = (result[word] || 0) + 1 ;
result
end

Procs and Lambdas in Ruby

Procs

adder = Proc.new { |arg1, arg2| arg1 + arg2 }

Procs in Ruby are like anonymous functions. In other words, little packages of code (defined in blocks of {} or do..end) that can be passed around as an object. Proc is actually short for procedure, so when you pass a Proc as an argument to a method, you can think of it as giving the method a list of instructions, as opposed to a particular data structure or value.

Re-FactoryGirl

  1. Head to this repo and follow the directions in the readme.

  2. Work through this playlist of tutorials.

  • Try increasing the speed of the videos once you get the hang of FactoryGirl (start with the gear button on the YouTube video frame).
  1. Head to the FactoryGirl Docs and try to implement the following:
  • Aliases
  • Inheritance
// Source: https://github.com/tmikeschu/the-spoken-tour
// ContactForm.jsx
import React, { Component } from "react"
import APIService from "../../APIService/APIService"
const apiService = new APIService("https://spoken-api.herokuapp.com")
export default class ContactForm extends Component {
constructor(props) {
// src/App/About/About.jsx
import React, { Component } from 'react'
export default class About extends Component {
render() {
return (
<article className="about">
<section className="who">
<h2>Who</h2>
// src/App/About/About.jsx
import React from 'react'
const About = () => (
<article className="about">
<section className="who">
<h2>Who</h2>
<p>We are a pair of lunatics who...</p>
</section>