Skip to content

Instantly share code, notes, and snippets.

View joaomarceloods's full-sized avatar

João Marcelo Oliveira joaomarceloods

  • Fortaleza, CE, Brazil
View GitHub Profile
@joaomarceloods
joaomarceloods / ruby_links.md
Created January 5, 2017 19:56
Useful links to ruby related material
@joaomarceloods
joaomarceloods / remote_pg_dump
Created July 21, 2017 18:38
Postgres - Clone remote database
pg_dump -Fc \
-d REMOTE_DB_NAME \
-h REMOTE_DB_HOST \
-p 5432 \
-U REMOTE_DB_USER \
|\
pg_restore \
-d LOCAL_DB_NAME \
-h localhost \
-p 5432 \
# Pseudo-code to create pairs of people who didn't meet yet.
# In exceptional case, there may be three people in a group.
donuts = []
people = Person.pluck(:id, :already_met) # { id: 1, already_met: [2, 3, 4] }
for person in people:
# skip if person is already in a donut
next if donuts.flat_map.include(person.id)