Skip to content

Instantly share code, notes, and snippets.

View gdalmau's full-sized avatar

Gerard Dalmau gdalmau

View GitHub Profile
@gdalmau
gdalmau / generate_random_cups.py
Created August 10, 2017 08:36 — forked from mroig/generate_random_cups.py
Generate Random CUPS
# coding: utf-8
import random
cups_checksum_table = 'TRWAGMYFPDXBNJZSQVHLCKE'
cups_name_length = 12
def gen_checksum(cupsname):
"""Calcula el checksum d'un CUPS."""
@gdalmau
gdalmau / report.py
Created September 26, 2017 15:46 — forked from tinogis/report.py
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]
report = 'account.general.ledger.cumulative'
@gdalmau
gdalmau / tmux-cheatsheet.markdown
Created November 27, 2017 10:26 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@gdalmau
gdalmau / git-squash.sh
Created January 4, 2018 16:20 — forked from favila/git-squash.sh
git-squash: script to create a squashed patch from a branch.
#! /bin/sh
# Produce a squash-commit patch from a branch of changes
MASTER=$1
PATCHBRANCH=$2
SQUASHBRANCH="$PATCHBRANCH-squash"
MESSAGE=$3
git checkout -b $SQUASHBRANCH $MASTER &&
git merge --squash $PATCHBRANCH &&
git commit -a -m "$MESSAGE" &&
@gdalmau
gdalmau / psql-with-gzip-cheatsheet.sh
Created February 17, 2018 10:57 — forked from brock/psql-with-gzip-cheatsheet.sh
Exporting and Importing Postgres Databases using gzip
# This is just a cheat sheet:
# On production
sudo -u postgres pg_dump database | gzip -9 > database.sql.gz
# On local
scp -C production:~/database.sql.gz
dropdb database && createdb database
gunzip < database.sql.gz | psql database
@gdalmau
gdalmau / install-postgres-10-ubuntu.md
Last active March 25, 2018 09:57 — forked from alistairewj/install-postgres-10-ubuntu.md
Install PostgreSQL 10 on Ubuntu

Install PostgreSQL 10 on Ubuntu

This is a quick guide to install PostgreSQL 10 - tested on Ubuntu 16.04 but likely can be used for Ubuntu 14.04 and 17.04 as well, with one minor modification detailed below.

(Optional) Uninstall other versions of postgres

To make life simple, remove all other versions of Postgres. Obviously not required, but again, makes life simple.

dpkg -l | grep postgres
@gdalmau
gdalmau / pivotpandas.py
Last active May 2, 2018 13:01 — forked from ecarreras/pivotpandas.py
Pandas pivot table
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
# Create DataFrame from Excel
df = pd.read_excel('/home/ecarreras/Desktop/l.xls')
# Create pivot table from DataFrame
@gdalmau
gdalmau / print_report.py
Created November 15, 2018 11:54
Imprimir report desde erppeek
import base64
import sys
import time
from subprocess import Popen
from erppeek import Client
c = Client(...
report = 'giscedata.facturacio.factura'
params = {'context': {}}
@gdalmau
gdalmau / .bash_prompt.sh
Last active April 15, 2021 08:00 — forked from miki725/.bash_prompt.sh
Custom bash prompt which displays: (virtualenv) user:/path (git-branch)
#!/bin/bash
#
# DESCRIPTION:
#
# Set the bash prompt according to:
# * the active virtualenv
# * the branch of the current git repository
# * the return value of the previous command
# * the fact you just came from Windows and are used to having newlines in
# your prompts.