Skip to content

Instantly share code, notes, and snippets.

@tinogis
tinogis / redis_empty.py
Last active January 13, 2022 07:47
Delete finished jobs from redis. Better than a FLUSHBD
import redis
r = redis.StrictRedis(host='redis')
l = r.keys('rq:job:*')
deleted_jobs = 0
total_jobs = len(l)
for j in l:
if 'dependents' in j:
continue
print 'Job {}'.format(j)
@tinogis
tinogis / dup_cleaner.py
Last active June 4, 2024 06:59
FTP_MON: Monitorizes STG ftp server
# -*- coding: utf-8 -*-
from ftplib import FTP
import click
from datetime import datetime
try:
from urllib.parse import urlparse
except:
from urlparse import urlparse
import os
@tinogis
tinogis / report.py
Last active January 21, 2019 18:30
Get and view an erp5 pdf report from command line
from erppeek import Client
import sys
import base64
from subprocess import call
import time
#report = 'giscedata.facturacio.factura'
#ids = [1513047, 1513049, 1513057, 1513042]
#ids = [1513042]
@ecarreras
ecarreras / README.md
Last active August 7, 2023 07:39
PostgreSQL replication

Checklist

  • Create user replication in the master
sudo -u postgres psql -c "CREATE USER rep REPLICATION \
LOGIN ENCRYPTED PASSWORD 'thepassword';"
  • Modify postgresql.conf in the master
listen_address = # make sure we're listening as appropriate
wal_level = hot_standby
@ecarreras
ecarreras / README.md
Last active August 29, 2015 13:58
Sitecustomize

Sitecustomize

Fix for unicode can't decode ascii...

#!/bin/bash
d_repo=( $(git remote -v | grep '\(push\)' | cut -d':' -f 2 | \
cut -d' ' -f 1 | cut -d '.' -f 1) )
d_base="developer"
d_from=gisce:$(git branch --no-color 2> /dev/null | grep '^\*' | \
cut -d ' ' -f 2)
read -p "User:" user
read -sp "Password:" password
echo

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 / VARS.sh
Last active December 11, 2015 02:28
Scripts per actualització de versió de l'ERP
VERSION="2.35.0"
#!/usr/bin/env python
import xmlrpclib
import sys
def run_test(host, port, dbname, uid, pwd, tid):
sock = xmlrpclib.ServerProxy('https://%s:%d/xmlrpc/ws_transaction'
% (host, port))
sock.commit(dbname, uid, pwd, tid)
sock.close(dbname, uid, pwd, tid)
@andreyvit
andreyvit / tmux.md
Created June 13, 2012 03:41
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a