Skip to content

Instantly share code, notes, and snippets.

@ryllada
ryllada / postgres-cheatsheet.md
Created February 10, 2022 10:24 — 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)
import string
class BlankFormatter(string.Formatter):
""" With the use of this class, we avoid the KeyError in dictionary based
str.format when the key is missing.
"""
def __init__(self, default=''):
self.default = default
#!/usr/bin/env python
# encoding: utf-8
from sklearn.grid_search import GridSearchCV
from sklearn.naive_bayes import GaussianNB
from sklearn.linear_model import LogisticRegression
from sklearn.linear_model import Perceptron
from sklearn.ensemble import RandomForestClassifier
from sklearn.ensemble import ExtraTreesClassifier
from sklearn.ensemble import GradientBoostingClassifier
#!/usr/bin/env python
# encoding: utf-8
import re
__author__ = 'Rodolfo Yllada (ryllada@gmail.com)'
def preprocess(data, predictors_base):
predictors = predictors_base[:]
# -*- coding: UTF-8 -*-
from reportlab.graphics.barcode import createBarcodeDrawing
from reportlab.lib.pagesizes import cm
class CuentaCobroCuaderno60(models.Model):
""" Cuentas asociadas al Cuaderno 60, en las que el tercero hace los
ingresos para el pago de actividades, reserva de recintos, etc.
"""
# -*- encoding: utf-8 -*-
from django.template.loader import get_template
from django.template import Context
from django.conf import settings
import cStringIO as StringIO
import ho.pisa as pisa
import datetime
import os
import subprocess
# -*- encoding: utf-8 -*-
import subprocess
import os
__author__ = 'Rodolfo Yllada (ryllada@gmail.com)'
# This little routine aims to transmit the changes commited in the master
# branch, to the rest of branches, that not are included in
# -*- coding: utf-8 -*-
import requests
import bs4
class ScrapingClassBase(object):
DOMAIN = None
STARTING_URL = None
ELEMENTS_CONTAINER = None
ELEMENTS_TO_COLLECT = ()