Skip to content

Instantly share code, notes, and snippets.

View edgarv09's full-sized avatar

Edgar Villamarin edgarv09

View GitHub Profile
@stevenharman
stevenharman / 00_Heroku-Release-Phase-Review-Apps-Rails_README.md
Last active June 4, 2025 20:13
Heroku Release Phase script for managing Rails DB migrations, and playing nice with Review Apps and postdeploy scripts

Heroku Release Phase + Review Apps + Rails

This is a simplified, but fairly thorough, set of scripts and configuration to enable Heroku Release Phase for Rails apps. Further, this particular set up plays nicely with Heroku Review Apps in that the release phase script will:

  1. Fail, loudly, if the DB does not yet exist.
  2. Load the DB schema if the current schema version (as determined by bin/rails db:version) is 0.
  3. Run DB migrations otherwise.

For a "normal" app that usually means it will run the DB migrations.

@slavikdev
slavikdev / cheatsheet.md
Last active January 1, 2025 15:03
Rails request path cheatsheet

Rails request path cheatsheet

Full path with query string

>>  request.url
=> "http://localhost:3000/ask-help.amp?ptn=pnh"

Virtual path without query string

>>  request.path
=> "/ask-help.amp"
@mankind
mankind / rails-jsonb-queries
Last active October 8, 2025 23:13
Ruby on Rails-5 postgresql-9.6 jsonb queries
http://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query
http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails
#payload: [{"kind"=>"person"}]
Segment.where("payload @> ?", [{kind: "person"}].to_json)
#data: {"interest"=>["music", "movies", "programming"]}
Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json)
Segment.where("data #>> '{interest, 1}' = 'movies' ")
Segment.where("jsonb_array_length(data->'interest') > 1")
@robertpainsi
robertpainsi / README.md
Last active October 1, 2025 00:10
How to reopen a pull-request after a force-push?

How to reopen a pull-request after a force-push?

Precodinitions

  • You need the rights to reopen pull requests on the repository.
  • The pull request hasn't been merged, just closed.

Instructions

  1. Write down the current commit hash of your PR-branch git log --oneline -1 <PR-BRANCH>
  2. Write down the latest commit hash on github before the PR has been closed.
  3. git push -f origin :
@ennukee
ennukee / shared_examples.md
Last active October 10, 2025 14:49
An article on the usage of RSpec Shared Examples by Dylan Bowers

Disclaimers and information

Written on April 25th, 2016. Last updated on April 25th, 2016.

Disclaimer: Keep in mind the code in this article may become outdated as time progresses. Please use at your own discretion and make sure you are updated on any major syntactical changes before utilizing the code structures used below.

This article assumes you have intermediate knowledge of Ruby and RSpec. A large portion of this article also uses concepts in Ruby on Rails. Most of the article will be given in code, so make sure you are comfortable in reading others' code as well.

The "hidden" power of shared examples

By Dylan Bowers
@RobinDaugherty
RobinDaugherty / create_gadgets.rb
Last active October 19, 2022 14:22
ActiveRecord attribute serializer Hashie::Mash stored as JSON in Postgres
class CreateGadgets < ActiveRecord::Migration
def change
create_table "gadgets" do |t|
t.json "info"
end
end
end
@lmarkus
lmarkus / README.MD
Last active October 3, 2025 03:29
Extracting / Exporting custom emoji from Slack

Extracting Emoji From Slack!

Slack doesn't provide an easy way to extract custom emoji from a team. (Especially teams with thousands of custom emoji) This Gist walks you through a relatively simple approach to get your emoji out.

If you're an admin of your own team, you can get the list of emoji directly using this API: https://api.slack.com/methods/emoji.list. Once you have it, skip to Step 3

HOWEVER! This gist is intended for people who don't have admin access, nor access tokens for using that list.

Follow along...

@pkfrom
pkfrom / Sublime Text License Key.md
Last active January 3, 2024 03:25
Sublime Text 2 License Key, Sublime Text 3 License Key, Sublime Text Full Version.
@maxivak
maxivak / 00.md
Last active September 15, 2025 13:09
Sending emails with ActionMailer and Sidekiq

Sending emails with ActionMailer and Sidekiq

Send email asynchroniously using Sidekiq.

ActionMailer

Create your mailer us usual:

@luiskhernandez
luiskhernandez / Api controller
Last active September 24, 2019 15:39
Devise authenticate_user_from_token
class ApplicationController < ActionController::API
before_action :authenticate_user_from_token!
def authenticate_user_from_token!
auth_token = request.headers['Authorization']
auth_token ? authenticate_with_token!(auth_token) : authentication_error
end
def authenticate_with_token!(token)
unless token.include?(':')