Skip to content

Instantly share code, notes, and snippets.

View malderete's full-sized avatar

Martin Alderete malderete

  • booking.com
  • Netherlands
View GitHub Profile
@malderete
malderete / pyconAr2014.py
Last active June 27, 2019 09:07
PyConAr 2014
"""
Presentacion de la problematica
envio bloqueante de emails en Django
"""
def register_user(request):
if request.method == 'POST':
form = RegisterUserForm(request.POST)
if form.is_valid():
user = form.save()
# send the email!!!
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#define BUF_SIZE 5
// the buffer works like a stack for
// the sake of simplicity, if needed
// we may implement a queue
@malderete
malderete / .git_completion
Created April 27, 2015 14:30
Git completion bash/Zsh
# bash/zsh git prompt support
#
# Copyright (C) 2006,2007 Shawn O. Pearce <[email protected]>
# Distributed under the GNU General Public License, version 2.0.
#
# This script allows you to see repository status in your prompt.
#
# To enable:
#
# 1) Copy this file to somewhere (e.g. ~/.git-prompt.sh).
@malderete
malderete / redis_lock_manager.py
Last active October 30, 2015 18:39
Redis Lock using python-redis library
import socket
import redis
class RedisLock(object):
"""Redis Lock implementation over redis.StrictRedis.lock.
:param strict_client: A StrictRedis client.
:type strict_client: redis.StrictRedis.
@malderete
malderete / cache.py
Created July 5, 2016 15:02
Time based cache decorator
import functools
import logging
import time
logger = logging.getLogger(__name__)
MAX_ENTRIES = 100 # Max items per cache!
def memoize(expire_seconds):
@malderete
malderete / update-system
Created March 21, 2017 02:12
Bash script to full upgrade a Debian system
#!/bin/bash
sudo apt-get -f install &&
sudo apt-get update &&
sudo apt-get check &&
sudo apt-get upgrade -f -y &&
sudo apt-get dist-upgrade -f -y -q &&
sudo dpkg --configure -a &&
sudo apt-get autoclean &&
sudo apt-get autoremove -f &&
#sudo aptitude purge '~c' &&
@malderete
malderete / drf_django_auditlog_mixin.py
Last active January 3, 2020 21:30
Mixin to use django-auditlog with DRF
from django.db.models.signals import pre_save
from django.utils.functional import curry
from auditlog.middleware import threadlocal, AuditlogMiddleware
from auditlog.models import LogEntry
class SetUserForAuditMixin:
def should_active_signal(self, request):
return request.user.is_authenticated

Keybase proof

I hereby claim:

  • I am malderete on github.
  • I am malderete (https://keybase.io/malderete) on keybase.
  • I have a public key ASDHCJeJYIGsbShVpV69_W08PY8srZj2sbDgBnaUCuFJVAo

To claim this, I am signing this object: