Skip to content

Instantly share code, notes, and snippets.

View jota12x's full-sized avatar
⛩️
Premature optimization is the root of all evil

Juanjosé Tenorio jota12x

⛩️
Premature optimization is the root of all evil
View GitHub Profile
@Haolicopter
Haolicopter / n_diagonals.py
Created June 8, 2018 19:31
Solve n diagonals problem with backtracking
def can_be_extended_to_solution(perm, n, m):
# Too many non diagonal squares
if perm.count(2) > m*m - n:
return False
new = len(perm) - 1
# New square has no diagonal
if perm[new] == 2:
return True
from django import template
register = template.Library()
@register.filter
def cool_number(value, num_decimals=2):
"""
Django template filter to convert regular numbers to a
cool format (ie: 2K, 434.4K, 33M...)
@Kartones
Kartones / postgres-cheatsheet.md
Last active May 9, 2024 10:07
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)