Skip to content

Instantly share code, notes, and snippets.

View rosdyana's full-sized avatar
💭
I may be slow to respond.

Rosdyana Kusuma rosdyana

💭
I may be slow to respond.
View GitHub Profile
@rosdyana
rosdyana / postgres-cheatsheet.md
Created April 1, 2020 08:59 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@rosdyana
rosdyana / remove_duplicates.py
Last active January 15, 2020 07:01 — forked from victorono/remove_duplicates.py
Django - remove duplicate objects where there is more than one field to compare
from django.db.models import Count, Max, Q
from django.db.models.functions import Length
from ma_audience.models import Audience
unique_fields = ['email']
duplicates = (
Audience.objects.filter(Q(organization_id=81), ~Q(email=''), Q(email__isnull=False)).values(*unique_fields)
.order_by()
.annotate(max_id=Max('id'), count_id=Count('id'))
@rosdyana
rosdyana / Update-branch.md
Created January 9, 2019 08:20 — forked from santisbon/Update-branch.md
Bring your feature branch up to date with master. Deploying from Git branches adds flexibility. Bring your branch up to date with master and deploy it to make sure everything works. If everything looks good the branch can be merged. Otherwise, you can deploy your master branch to return production to its stable state.

Updating a feature branch

First we'll update your local master branch. Go to your local project and check out the branch you want to merge into (your local master branch)

$ git checkout master

Fetch the remote, bringing the branches and their commits from the remote repository. You can use the -p, --prune option to delete any remote-tracking references that no longer exist in the remote. Commits to master will be stored in a local branch, remotes/origin/master