Skip to content

Instantly share code, notes, and snippets.

gonzaloamadio / gist:d42acb8cce05061e674a7f698f03972c
Created October 25, 2021 20:49
OtherFieldValidator Django
View gist:d42acb8cce05061e674a7f698f03972c
class OtherFieldValidatorInSerializer:
A validator to be inherited from, that will give use the
possibility of validate two fields.
More exaplanation on comments along the code.
TODO: Easily extensible to a list of fields
(For a model that has to fields, date_start and date_end)
gonzaloamadio /
Created May 27, 2021 18:40 — forked from raprasad/
Ignoring migrations during Django testing (unmanaged databases, legacy databases, etc)


  • Django 1.9 application with two databases:
    • Legacy database with readonly access via unmanaged models. Both Django models ( and related migrations have "managed" set to False
      • 'managed': False
    • Default database holding django specific tables (e.g. auth_user, django_content_type, etc)

Testing Woes

import uuid
from django.db import models
class UUIDField(
def __init__(self, *args, **kwargs):
self.version = kwargs.pop('version', 1)
#!/usr/bin/env bash
log() { echo -e "\e[0;33m${1}\e[0m"; }
# Ask for the administrator password upfront.
sudo -v
log 'Empty the Trash on all mounted volumes and the main HDD...'
sudo rm -rfv /Volumes/*/.Trashes
sudo rm -rfv ~/.Trash
gonzaloamadio /
Last active November 5, 2019 21:45 — forked from chadgh/
python decorators for; debugging, threading
def timeit(function):
'''Decorator used for debugging. Prints the call and how long it took.'''
def timed(*args, **kwargs):
ts = time.time()
result = function(*args, **kwargs)
te = time.time()
print("{0} ({1}, {2}) {3:.2} sec"
.format(function.__name__, args, kwargs, te - ts))
class CreateJob(UseCaseInterface):
def __init__(
repository: JobRepositoryInterface,
self._title = title
gonzaloamadio / linux admin basic commands
Last active July 18, 2018 09:39
Various linux commands for administrators, and for everyone
View linux admin basic commands
--- Connect to windows via rdesktop ---
> rdesktop -u administrador -g1500x800
--- Connect to linux via ssh ---
> ssh {user}@{ip or dns-name}
> ssh
gonzaloamadio / .vimrc
Last active July 6, 2020 14:50
My ~/.vimrc configuration. Mostly oriented for python
View .vimrc
" # Fisa-vim-config
" #
" # version: 8.2
" # Other ref:
set encoding=utf-8
let using_neovim = has('nvim')
let using_vim = !using_neovim
View gist:764bb66febcab4a2c0f48f1791a62b13
########## LOGGIN
# Put this inside (if you have separated settings, put it on base setting)
# If DEBUG=True, all logs (including django logs) will be
# written to console and to debug_file.
# If DEBUG=False, logs with level INFO or higher will be
# saved to production_file.