Skip to content

Instantly share code, notes, and snippets.

@lesandie
lesandie / upgrade.xml
Created June 25, 2024 08:32
Upgrade snippet for ClickHouse to allow Downgrades
<!-- Upgrade from 21/22 to 23.8 and after to 24 -->
<clickhouse>
<index_mark_cache_size>5368709120</index_mark_cache_size>
<merge_tree>
<ratio_of_defaults_for_sparse_serialization>1</ratio_of_defaults_for_sparse_serialization>
<compress_marks>0</compress_marks>
<compress_primary_key>0</compress_primary_key>
</merge_tree>
</clickhouse>
@lesandie
lesandie / file_buffering.py
Created November 28, 2021 10:05
File buffering example
# Simple line buffering example
# When using the context maganet with,
# simply use a 1 to open the file in buffering mode
filename = "input_file.txt"
with open(filename, 'r', 1) as filehandle:
filecontent = filehandle.buffer
for line in filecontent:
line = line.decode()
line = line.strip()
print(line)
@lesandie
lesandie / txt2csv.py
Created November 26, 2021 20:02
Simple python txt to csv conversion
from csv import Reader, Writer
txt_file = "infile.txt"
csv_file = "output.txt"
delimiter = "|"
with open(txt_file, 'r') as txt_fh, \
open(csv_file, 'w'i, newline="", encoding="utf-8") as csv_fh:
writer(csv_fh).writerows(reader(txt_fh, delimiter=delimiter))
@lesandie
lesandie / pg_admin.md
Last active November 26, 2021 20:00
Curso_postgres acctaplic DB

ADMIN queries

-------------------
-- Check max conn
-------------------
SELECT  * FROM
(SELECT COUNT(*) used FROM pg_stat_activity) q1,
(SELECT setting::int res_for_super FROM pg_settings WHERE name=$$superuser_reserved_connections$$) q2,
(SELECT setting::int max_conn FROM pg_settings WHERE name=$$max_connections$$) q3;

Keybase proof

I hereby claim:

  • I am lesandie on github.
  • I am dnieto (https://keybase.io/dnieto) on keybase.
  • I have a public key ASAXr56B-V6EOKUoZoqOhWIXfF2GNhdYHELNNEd58QF8IAo

To claim this, I am signing this object: