Skip to content

Instantly share code, notes, and snippets.

@ssaid
ssaid / dump_schema_data_from_postgres.sh
Created March 10, 2023 17:54
Dump data and schema from PostgreSQL DB
#!/bin/bash
DBNAME="dbname"
tables=$(psql -d $DBNAME -t -c "SELECT table_name FROM information_schema.tables WHERE table_schema='public' and table_type='BASE TABLE'"|cut -d' ' -f2)
while IFS= read -r table; do
pg_dump --schema-only -t $table $DBNAME > $table.schema
pg_dump --data-only -t $table $DBNAME > $table.data
done <<< "$tables"
@ssaid
ssaid / check_two_repos.sh
Last active March 8, 2023 16:39
After using BFG, check if the source code has not been modified
#!/bin/bash
# PURPOSE: Compare if two directories have the same source code in all branches
# WHY?: Ensure that bgf has not altered the code after running
# HOW?: Easy! dir1 is the original untouched repo, dir2 is what have been altered by BFG.
# 1. From untouched directory, grab all the branches and iterate over them
# 2. Magic happens in compare_branch_and_sha: checkout to that branch and get an md5sum of all files for each directory.
# 3. The output is self-explanatory!
# Thanks to https://rtyley.github.io/bfg-repo-cleaner/ for that awesome and magic project :)
dir1=$1
@ssaid
ssaid / .vimrc
Last active November 5, 2015 14:13
VIMRC (Installs vundle too..)
" no vi-compatible
set nocompatible
" Setting up Vundle - the vim plugin bundler
let iCanHazVundle=1
let vundle_readme=expand('~/.vim/bundle/vundle/README.md')
if !filereadable(vundle_readme)
echo "Installing Vundle.."
echo ""
silent !mkdir -p ~/.vim/bundle
silent !git clone https://github.com/gmarik/vundle ~/.vim/bundle/vundle
hola
Retenciones automaticas que no tienen tax_app_id
================================================
test_arg=> SELECT rtl.name, r.type, round(((round(rtl.amount,2)/round(rtl.base,2))*100),2) as percentage
FROM retention_tax_line rtl
JOIN retention_retention r
ON rtl.retention_id=r.id
JOIN account_tax at
ON r.tax_id=at.id
WHERE rtl.manual=false /* Solo automaticas */
@ssaid
ssaid / gist:fc76b99b1352c05de69d
Created August 21, 2015 15:08
Query to export to CSV
```
COPY(SELECT rp.name AS Partner, rpa.name as Contact_Name, rpa.street, rpa.street2, rpa.city, rpa.zip, rcs.name as state, rc.name as country FROM res_partner_address rpa
JOIN res_partner rp ON rpa.partner_id=rp.id
JOIN res_country rc ON rpa.country_id=rc.id
JOIN res_country_state rcs ON rpa.state_id=rcs.id
WHERE rpa.type IS NULL AND rpa.active IS True
ORDER BY rp.name)
TO '/tmp/res_partner_address_type_null.csv' DELIMITER ',' CSV HEADER;
```