Skip to content

Instantly share code, notes, and snippets.

View jasmind's full-sized avatar

Jasmin Daguda jasmind

View GitHub Profile

Example:

array_of_hashes = [
  {:a=>1}, {:a=>2}, {:a=>3},
  {:b=>4}, {:b=>5}, {:b=>6}, {:b=>7}, {:b=>8}, {:b=>9},
  {:c=>10}
]

Solution 1:

@jasmind
jasmind / cheatsheet.rb
Created February 27, 2023 10:54 — forked from mabenson00/cheatsheet.rb
Rails ActiveRecord JSON cheatsheet
# Basic key operators to query the JSON objects :
# #> : Get the JSON object at that path (if you need to do something fancy)
# -> : Get the JSON object at that path (if you don't)
# ->> : Get the JSON object at that path as text
# {obj, n} : Get the nth item in that object
# https://www.postgresql.org/docs/9.4/functions-json.html#FUNCTIONS-JSONB-OP-TABLE
# Date
# date before today
@jasmind
jasmind / how-to-copy-aws-rds-to-local.md
Created May 9, 2018 09:25 — forked from syafiqfaiz/how-to-copy-aws-rds-to-local.md
How to copy production database on AWS RDS(postgresql) to local development database.
  1. Change your database RDS instance security group to allow your machine to access it.
    • Add your ip to the security group to acces the instance via Postgres.
  2. Make a copy of the database using pg_dump
    • $ pg_dump -h <public dns> -U <my username> -f <name of dump file .sql> <name of my database>
    • you will be asked for postgressql password.
    • a dump file(.sql) will be created
  3. Restore that dump file to your local database.
    • but you might need to drop the database and create it first
    • $ psql -U <postgresql username> -d <database name> -f <dump file that you want to restore>
  • the database is restored
@jasmind
jasmind / 00.md
Created November 9, 2016 10:47 — forked from maxivak/00.md
Sending emails with ActionMailer and Sidekiq

Sending emails with ActionMailer and Sidekiq

Send email asynchroniously using Sidekiq.

ActionMailer

Create your mailer us usual: