Skip to content

Instantly share code, notes, and snippets.

View 3manuek's full-sized avatar
😎
tr3s.ma

Emanuel Calvo 3manuek

😎
tr3s.ma
View GitHub Profile
@3manuek
3manuek / workers.sh
Last active June 1, 2024 10:57
Functional implementation of Bash workers
#!/bin/bash
set -e -o pipefail
setWaiter(){
export maxWorkers=${1}
}
waiter(){
while test $(jobs -p | wc -l) -ge $maxWorkers ; do wait -n ; done
@3manuek
3manuek / gdal.md
Created November 7, 2023 20:03
Postgis/GDAL
[postgres@buildkitsandbox postgis]$ gdal-config --dep-libs
-lcrypto -larmadillo -lpoppler -ljson-c -lfreexl -lgeos_c -lwebp -lodbc -lodbcinst -L/usr/lib -lkmlbase -lkmldom -lkmlengine -lkmlxsd -lkmlregionator -lexpat -lxerces-c -lpthread -lopenjp2 -ljasper -lnetcdf -lhdf5 -lmfhdf -ldf -logdi -lgif -lgeotiff -lgta -lpng -lcfitsio -lpq -llzma -lproj -lsqlite3 -ltiff -ljpeg -lz -lpthread -lm -lrt -ldl -lspatialite -lsqlite3 -ldapclient -ldapserver -ldap -lpcre2-8 -lcurl -lxml2 -lmariadb
[postgres@buildkitsandbox postgis]$ view config.log 
[postgres@buildkitsandbox postgis]$ grep undefined config.log 
/workdir/postgis/lex.yy.c:1179: undefined reference to `yywrap'
/workdir/postgis/lex.yy.c:870: undefined reference to `yywrap'
/workdir/postgis/conftest.l:17: undefined reference to `yywrap'
/workdir/postgis/lex.yy.c:1179: undefined reference to `yywrap'
/workdir/postgis/lex.yy.c:870: undefined reference to `yywrap'
@3manuek
3manuek / gist:028925d71f72d5ea7f65d6a53d8547e9
Created July 14, 2020 17:26
TheBank Akai postinstall fix
*** postinstall 2020-07-14 14:25:45.000000000 -0300
--- postinstall_ori 2020-07-14 14:24:48.000000000 -0300
***************
*** 50,56 ****
source="$DIRNAME"
find "$source" -type f \( -name '*.svx' -o -name '*.wav' \) -exec sh -c '
! dest="/Library/Application\ Support/Akai/MPC/TheBank"
source="{}"
destination="$dest${1%/*}"
Redshift (RS) / ClickHouse (CH)
---
Redshift 3 nodes (1 coordinator) / CH 2 nodes, same specs.
RS:
8m 36s / 1m40s
select trunc(created_at),* from request_stats_2015;
CH:
### Keybase proof
I hereby claim:
* I am 3manuek on github.
* I am 3manuek (https://keybase.io/3manuek) on keybase.
* I have a public key ASC78Cs2PngOIkc6HHRJcDLp2pK0CryDfSl4fLi-2oEK6go
To claim this, I am signing this object:
@3manuek
3manuek / gist:49cda5d4d2ec93ef91a279fc5a36e15b
Created October 1, 2018 19:00
get connections from a config file
#!/usr/bin/python
from configparser import ConfigParser
def config(filename='endpoints.ini', section='postgresql'):
# create a parser
parser = ConfigParser()
# read config file
parser.read(filename)
ubuntu@pgtest:~/odyssey/build/sources$ uname -a
Linux pgtest 4.4.0-134-generic #160-Ubuntu SMP Wed Aug 15 14:58:00 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
ubuntu@pgtest:~/odyssey/build/sources$ cat version.h
#ifndef ODYSSEY_VERSION_H
#define ODYSSEY_VERSION_H
/*
* Odyssey.
*
ubuntu@pgtest:~/odyssey/build/sources$ uname -a
Linux pgtest 4.4.0-134-generic #160-Ubuntu SMP Wed Aug 15 14:58:00 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
ubuntu@pgtest:~/odyssey/build/sources$ cat version.h
#ifndef ODYSSEY_VERSION_H
#define ODYSSEY_VERSION_H
/*
* Odyssey.
*
@3manuek
3manuek / alter_full_table_relfilenode_n_locks.md
Last active June 22, 2018 19:02
[pg 10] relfilenode change on full table write and the AccessExclusiveLock
  • Open 2 psql terminals
postgres=# create table test AS SELECT clock_timestamp(), i::bigint as num from generate_series(1,10000000) i(i);
SELECT 10000000
Time: 9305.262 ms (00:09.305)

postgres=# select relname, oid, relfilenode from pg_class where oid = 'test'::regclass::oid;
 relname |  oid  | relfilenode
---------+-------+-------------
@3manuek
3manuek / gist:53e67f9cc926b1535e926c3b547b448c
Created May 7, 2018 04:08
Calculate bytes per N seconds for estimating speed of restores
WITH timeset AS (
select pg_database_size(datname) num, pg_size_pretty(pg_database_size(datname)) size from pg_database where datname = 'db'
UNION ALL
select pg_database_size(datname) num, pg_size_pretty(pg_database_size(datname)) size from pg_database, pg_sleep(10) where datname = 'db'
)
SELECT num - lag(num,1) OVER (ORDER BY num) bytes_per_10_second, size FROM timeset
;