Skip to content

Instantly share code, notes, and snippets.

Postgres Cheatsheet

This is a collection of the most common commands I run while administering Postgres databases. The variables shown between the open and closed tags, "<" and ">", should be replaced with a name you choose. Postgres has multiple shortcut functions, starting with a forward slash, "". Any SQL command that is not a shortcut, must end with a semicolon, ";". You can use the keyboard UP and DOWN keys to scroll the history of previous commands you've run.

Setup

installation, Ubuntu

http://www.postgresql.org/download/linux/ubuntu/ https://help.ubuntu.com/community/PostgreSQL

@bolerap
bolerap / PG cheat sheet
Created March 19, 2019 09:36 — forked from borisrorsvort/PG cheat sheet
PG cheat sheet
cheat sheets.
$ command line ruby cheat sheets
PostgreSQL
----------
Create the filesystem
----
$ export PGROOT="/var/lib/postgres"
$ mkdir -p $PGROOT/data && chown postgres.postgres $PGROOT/data
-- Simple.hs
-- calculates the summary of a sequence number with a pattern
-- eg: [1, 2, 3, 4] or [1, 3, 5, 7] or [1, 3, 6, 9]
-- general form [a..b] => sum = ((a + b) * length [a..b]) / 2
seqSum :: Fractional a => [a] -> a
seqSum list = ((first + last) * len) / 2
where
len = length list
first = head list
@bolerap
bolerap / multiple_ssh_setting.md
Created November 5, 2018 03:39 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@bolerap
bolerap / postgres_error.md
Created September 25, 2018 10:15
The specified database user/password combination is rejected: [28000] FATAL: no pg_hba.conf entry for host MacOS postgres installed via homebrew

add host all all 0.0.0.0/0 trust to /usr/local/var/postgres/pg_hba.conf

@bolerap
bolerap / settings.py
Created August 30, 2018 04:39 — forked from ipmb/settings.py
Django logging example
import logging.config
import os
from django.utils.log import DEFAULT_LOGGING
# Disable Django's logging setup
LOGGING_CONFIG = None
LOGLEVEL = os.environ.get('LOGLEVEL', 'info').upper()
logging.config.dictConfig({
  1. PUT: update entire resource. Using this verb may lead to lost data when you are not entered fully fields of the resource.
  2. PATCH: partial update, update a part (one or serveral fields) of the resource.
@bolerap
bolerap / OSX-Convert-MOV-GIF.md
Created July 21, 2018 08:52 — forked from tskaggs/OSX-Convert-MOV-GIF.md
Creating GIFs from .MOV files in OSX using FFmpeg and ImageMagick

Convert MOV to GIF using FFmpeg and ImageMagick

I tried a few different techniques to make a GIF via command-line and the following gives me the best control of quality and size. Once you're all setup, you'll be pumping out GIFs in no time!

Preparation

Install FFmpeg

  • $ brew install ffmpeg [all your options]
    • Example: $ brew install ffmpeg --with-fdk-aac --with-ffplay --with-freetype --with-frei0r --with-libass --with-libvo-aacenc --with-libvorbis --with-libvpx --with-opencore-amr --with-openjpeg --with-opus --with-rtmpdump --with-schroedinger --with-speex --with-theora --with-tools

Install ImageMagick

@bolerap
bolerap / javascript_data_type.js
Created July 13, 2018 06:46
Javascript data types, while null == undefined is true
// 0. Primitive data types (6): Boolean, Null, Undefined, String, Number, Symbol
//
// 1. Truely and Falsy value in javascript
// - Falsy (6 falsy value): false, 0, '' (empty string), null, undefined, NaN
// - Truely: All other values that differ 6 falsy value above.
//
// 2. Type Coerce
// - When checking equality (==) javascript will coerce operands to the same data type before compare.
// - With operator === javascript only compare operands when they are the same data type. Immediately return false when differ.
//