Skip to content

Instantly share code, notes, and snippets.

View liberom's full-sized avatar
:octocat:
Coding!

Vinicius Libero liberom

:octocat:
Coding!
View GitHub Profile
@liberom
liberom / regenerate_credentials.md
Created September 27, 2023 20:38 — forked from db0sch/regenerate_credentials.md
How to regenerate the master key for Rails 5.2 credentials

If your master.key has been compromised, you might want to regenerate it.

No key regeneration feature at the moment. We have to do it manually.

  1. Copy content of original credentials rails credentials:show somewhere temporarily.
  2. Remove config/master.key and config/credentials.yml.enc
  3. Run EDITOR=vim rails credentials:edit in the terminal: This command will create a new master.key and credentials.yml.enc if they do not exist.
  4. Paste the original credentials you copied (step 1) in the new credentials file (and save + quit vim)
  5. Add and Commit the file config/credentials.yml.enc
@liberom
liberom / rails-jsonb-queries
Created August 22, 2023 21:34 — forked from mankind/rails-jsonb-queries
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")
@liberom
liberom / vimrc_for_ruby.md
Last active December 20, 2022 20:41
Vim Configuration File .vimrc

‎‎​

@liberom
liberom / vim_cheatsheet.md
Created December 20, 2022 19:58
Vim Cheat Sheet

Vim Cheat Sheet

Navigation

  • End of the file: shift + g
  • Next line: j
  • Go down a defined number of lines: number + j
  • Skip to next word: w
  • Skip back a word: b
  • Skip to next section: W
@liberom
liberom / alias_matchers.md
Created September 6, 2021 23:23 — forked from JunichiIto/alias_matchers.md
List of alias matchers in RSpec 3

This list is based on aliases_spec.rb.

You can see also Module: RSpec::Matchers API.

matcher aliased to description
a_truthy_value be_truthy a truthy value
a_falsey_value be_falsey a falsey value
be_falsy be_falsey be falsy
a_falsy_value be_falsey a falsy value
require 'rails_helper'
RSpec.describe TodosController, :type => :controller do
describe "GET #index" do
#describe "POST #create" do
#describe "GET #show" do
#describe "PATCH #update" do (or PUT #update)
#describe "DELETE #destroy" do
#describe "GET #new" do
@liberom
liberom / new_linux_install.md
Last active February 16, 2024 09:05
Setting up a new linux install for development

New Linux Install

Create GitHub Account

Adding Repositories in Other Distros (Debian)

sudo apt-get install software-properties-common

Keybase proof

I hereby claim:

  • I am liberom on github.
  • I am liberom (https://keybase.io/liberom) on keybase.
  • I have a public key ASDzQtq80eRjtUNm-1PAfX9DmYNZGnBa7gEtkxwBMzkqcgo

To claim this, I am signing this object:

@liberom
liberom / gist:ab64e2dff69439c1987928585a4df983
Created January 6, 2021 23:42 — forked from wrburgess/gist:5528649
Backup Heroku Postgres database and restore to local database

Grab new backup of database

Command: heroku pgbackups:capture --remote production

Response: >>> HEROKU_POSTGRESQL_COLOR_URL (DATABASE_URL) ----backup---> a712

Get url of backup download

Command: heroku pgbackups:url [db_key] --remote production

@liberom
liberom / psql-error-fix.md
Created January 6, 2021 23:37 — forked from AtulKsol/psql-error-fix.md
Solution of psql: FATAL: Peer authentication failed for user “postgres” (or any user)

psql: FATAL: Peer authentication failed for user “postgres” (or any user)

The connection failed because by default psql connects over UNIX sockets using peer authentication, that requires the current UNIX user to have the same user name as psql. So you will have to create the UNIX user postgres and then login as postgres or use sudo -u postgres psql database-name for accessing the database (and psql should not ask for a password).

If you cannot or do not want to create the UNIX user, like if you just want to connect to your database for ad hoc queries, forcing a socket connection using psql --host=localhost --dbname=database-name --username=postgres (as pointed out by @meyerson answer) will solve your immediate problem.

But if you intend to force password authentication over Unix sockets instead of the peer method, try changing the following pg_hba.conf* line:

from