Skip to content

Instantly share code, notes, and snippets.

View DamianRivas's full-sized avatar
🚀

Damian Rivas DamianRivas

🚀
View GitHub Profile
@DamianRivas
DamianRivas / Seralizers.md
Last active March 20, 2018 04:43 — forked from SnoopSqueak/Seralizers.md
JSON serializing with Ruby on Rails

Serializers

Why Serialize?

API's either receive data-modifying requests (post, put, delete) or data-accessing requests (get), and in either case, their response can involve retreiving data, serializing that data into JSON, and returning it.

In Rails, this serialization could be done manually, by, say, creating a serializer method:

# User.rb
def serialize
 hash = {}
@DamianRivas
DamianRivas / heroku_pg_db_reset.md
Last active February 22, 2018 22:12 — forked from zulhfreelancer/heroku_pg_db_reset.md
How to reset PG Database on Heroku?

How to reset PG Database on Heroku?

  • Step 1: heroku restart
  • Step 2: heroku pg:reset DATABASE (no need to change the DATABASE)
  • Step 3: heroku run rake db:migrate
  • Step 4: heroku run rake db:seed (if you have seed)

One liner

heroku restart && heroku pg:reset DATABASE --confirm APP-NAME && heroku run rake db:migrate

@DamianRivas
DamianRivas / player-js-analysis.md
Last active December 7, 2017 21:10 — forked from R-V-S/player-js-analysis.md
player.js analysis
  1. This file declares a class, Player, instantiates it, and assigns it to a global player variable.
  2. The Player class contains four methods:
    • constructor()
    • playPause()
    • skipTo()
    • setVolume()
  3. The constructor() method sets initial values for the currentlyPlaying, playState, volume, and soundObject properties.
    • currentlyPlaying is set to the first item in album.songs.
    • The initial playState is "stopped".
  • The volume is set to the number 80.