Skip to content

Instantly share code, notes, and snippets.

View artefactop's full-sized avatar

Pepe Navarro artefactop

View GitHub Profile
package main
import (
"net/http"
"database/sql"
"fmt"
"log"
"os"
)
@Kartones
Kartones / postgres-cheatsheet.md
Last active May 12, 2025 01:59
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)
@stuart11n
stuart11n / gist:9628955
Created March 18, 2014 20:34
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@artefactop
artefactop / calendar_iso8601.erl
Created May 21, 2013 18:04
erlang dates to integer iso8601
date_to_integer_iso8601({date,{Y,M,D}}) ->
datetime_to_integer_iso8601({datetime,{{Y,M,D},{0,0,0}}}).
datetime_to_integer_iso8601({datetime,{{Y,M,D},{H,Min,S}}}) ->
Y * 10000000000 + M * 100000000 + D * 1000000 + H * 10000 + Min * 100 + S.
@renatoalbano
renatoalbano / encode_uri_rfc3986.erl
Created September 27, 2012 21:06
erlang percent encoding that works with utf-8
-module(encode_uri_rfc3986).
-author('Renato Albano <[email protected]>').
-export([encode/1]).
%% Taken from <http://erlangexamples.com/>,
%% from <http://github.com/CapnKernul/httparadise>
%% and <http://www.erlang.org/doc/man/edoc_lib.html>
encode([C | Cs]) when C >= $a, C =< $z ->
@jespada
jespada / git-log
Created June 19, 2012 12:29
nice git log
#See a nice git log:
git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --
#configure that git log by default
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --"
#next time just
git lg