Skip to content

Instantly share code, notes, and snippets.

View ecarreras's full-sized avatar
💡
IT for utilities

Eduard Carreras ecarreras

💡
IT for utilities
View GitHub Profile
@chanks
chanks / gist:7585810
Last active January 10, 2025 03:03
Turning PostgreSQL into a queue serving 10,000 jobs per second

Turning PostgreSQL into a queue serving 10,000 jobs per second

RDBMS-based job queues have been criticized recently for being unable to handle heavy loads. And they deserve it, to some extent, because the queries used to safely lock a job have been pretty hairy. SELECT FOR UPDATE followed by an UPDATE works fine at first, but then you add more workers, and each is trying to SELECT FOR UPDATE the same row (and maybe throwing NOWAIT in there, then catching the errors and retrying), and things slow down.

On top of that, they have to actually update the row to mark it as locked, so the rest of your workers are sitting there waiting while one of them propagates its lock to disk (and the disks of however many servers you're replicating to). QueueClassic got some mileage out of the novel idea of randomly picking a row near the front of the queue to lock, but I can't still seem to get more than an an extra few hundred jobs per second out of it under heavy load.

So, many developers have started going straight t

@ecarreras
ecarreras / README.md
Last active February 16, 2017 10:34
Vivència com inquilí a un pis gestionat per Progrup

Tot acaba, o potser més aviat comença amb el retard de 6 mesos per part de Progrup en retornar una fiança de 750 euros.

Els antecedents del meu pas per un pis gestionat per Progrup, des de que vaig entrar uns 3 anys 31 de desembre del 2009 i fins que he marxat a 27 de novembre del 2012. Aproximadament uns 6 mesos i encara no se m'ha tornat la fiança.

En el moment de signar el contracte se'm va dir que era imprescindible, que el dia de la signatura del contracte, portar un xec per valor de 750 euros. Ho vaig trobar normal, ja que en tots els lloguers hi ha una fiança amb el valor del lloguer mensual.

Els primers mesos se'm va tallar fins a dos cops el suministrament d'aigua, degut a que abans d'entrar jo no es van regularitzar les factures de l'aigua i hi havia uns deutes pendents. Feina que havia de fer Progrup, però maldecaps de quedar-se sense aigua corrent dues vegades, anar en hores de feina a l'atenció al client del distribuïdor d’aigua, avançar els diners d'un deute que jo ni m'hauria d'haver assaben

@algal
algal / nginx-cors.conf
Created April 29, 2013 10:52
nginx configuration for CORS (Cross-Origin Resource Sharing), with an origin whitelist, and HTTP Basic Access authentication allowed
#
# A CORS (Cross-Origin Resouce Sharing) config for nginx
#
# == Purpose
#
# This nginx configuration enables CORS requests in the following way:
# - enables CORS just for origins on a whitelist specified by a regular expression
# - CORS preflight request (OPTIONS) are responded immediately
# - Access-Control-Allow-Credentials=true for GET and POST requests

Paralize your scripts with Redis

  1. Setup your redis server
  2. Install python-rq
  3. Clone this gist
  4. Start n workers
  5. Run tas_rq.py
  6. Wait workers do the job :)
@ecarreras
ecarreras / REAME.md
Last active December 13, 2015 17:58
Switcht to previous workspace

Switch to previous workspace

  1. Start the server.
 $ python lw.py server
  1. Bind a shortcut to python lw.py client.
anonymous
anonymous / gist:4747864
Created February 10, 2013 01:14
TPB AFK Subtítulos en español
10:01:47:24 10:01:51:10 
Tres suecos fueron detenidos el día de hoy,
sospechosos de administrar-
10:01:51:14 10:01:57:10
-uno de los sitios web de descargas
ilegales más grandes del mundo... -
10:01:57:14 10:02:02:01
Buenas noches. EE.UU. amenazó
@ecarreras
ecarreras / README.md
Last active December 11, 2015 17:09
Install/Upgrade packages without (re)starting services in Debian/Ubuntu
@mikeyk
mikeyk / watch_wal-e.py
Created January 16, 2013 20:24
Watch_wal-e script
#! /usr/bin/env python
from boto.ses.connection import SESConnection
import os
import sys
import subprocess
import socket
TMPFILE = '/var/run/postgresql/last-wal-archive-error-file.tmp'
if __name__ == '__main__':
@ecarreras
ecarreras / VARS.sh
Last active December 11, 2015 02:28
Scripts per actualització de versió de l'ERP
VERSION="2.35.0"
@dcramer
dcramer / gist:3898601
Created October 16, 2012 10:40
pmp Concept