Skip to content

Instantly share code, notes, and snippets.

@kattak
kattak / service_objects.md
Last active November 24, 2020 11:24
Service Objects in Rails

##What are Service Objects?


 Service objects contain business logic with an interface that is easy to test.
 View > Controller > Model, but sometimes need other data, i.e. from an API

Where are service objects located?

├── app

#Checkbox Field

<div class="field">
<%= f.label "Mechanics in Game:" %><br />
<%= f.collection_check_boxes :mechanic_ids, @mechanics.all, :id, :name do |m| %>
  <div class="collection-check-box">
    <%= m.check_box %>
    <%= m.label %>
  </div>
@kattak
kattak / bookmarklets.md
Last active January 9, 2017 00:22
Hello World Bookmarklet - What is a bookmarklet? Why would I want to use one? Make a "Hello World" bookmarklet in <10 minutes.

##Bookmarklets

#####What is it?

  • An anonymous JS function
  • Saved in the url of a bookmark in your browser
  • Can also reference an external file

#####What can it be used for?:

  • Hide the subscription blocker on NYT
  • Fill in forms for you
```bash
'rails new APPNAME --database=postgresql’
*heroku doesn’t use sqlite3, which is default in new rails apps
***SQLite just stores the database to a file in your db/ folder, which is why it's incompatible with Heroku.***
**Redo blog app using postgresql DB
**Then try deploying to heroku
How to deploy app to heroku
@kattak
kattak / Current trends: EC6, V8, Angular & React, Node
Created January 9, 2017 15:55
(in progress) Types of languages; Javascript, V8, EC6; Angular and React compared to Rails; Node
@kattak
kattak / Generators in Rails.md
Last active June 30, 2017 01:11
(in progress)

Make a Rails blog in 10 minutes

New Rails App with postgres

rails new APPNAME --database=postgresql

Why can't we use the default (sqlite) database?

  • Heroku is a popular free hosting service.
  • Heroku doesn’t use SQLite3, which is the default database in new Rails apps.
@kattak
kattak / d3js.md
Last active January 10, 2017 06:18

#About d3.js

#First Step ✮ Either use a gem - this one is most popular iblue/d3-rails

-You might get a json v1.8.1 error

-Delete the Gemfile.lock

###Big Questions for search optimization

How many queries? Can get (and parse) full lyrics? Can store/serialize lyrics? How to store once acquired? Restricted list Possible queries and benchmarks from existing APIs

Crawler Search and ranking already done when you do a search. To make search so fast, the search layer just returns the next 10 results from a list starting at position 1.

@kattak
kattak / Caching in Rails.md
Created January 16, 2017 07:06
In progress...