Skip to content

Instantly share code, notes, and snippets.

View flaviut's full-sized avatar

Flaviu Tamas flaviut

View GitHub Profile
@flaviut
flaviut / Setting up Emporia Vue 2 with ESPHome.md
Last active March 12, 2024 00:27
Setting up Emporia Vue 2 with ESPHome
@flaviut
flaviut / box-drawing.md
Last active November 6, 2023 15:35
Box Drawing characters with examples

Box drawing fun

A few boxes drawn with Unicode box drawing characters:

╔═╦═╗
╠═╬═╣
║ ║ ║
╚═╩═╝
@flaviut
flaviut / ntp.py
Created November 2, 2023 01:56
A simple, experimental NTP client written in Python.
import socket
import struct
import time
from dataclasses import dataclass
from enum import IntEnum
from typing import Optional
NTP_SERVER = "pool.ntp.org"
NTP_PORT = 123
TIME1970 = 2208988800 # 1970-01-01 in NTP epoch

Get all user tables & size

SELECT database, table, storage_policy, round(total_bytes / 1024 / 1024) as MiB
FROM system.tables 
WHERE storage_policy IS NOT NULL AND lower(database) NOT IN ('system', 'information_schema')
ORDER BY MiB DESC;

Get all user tables with TTLs

@flaviut
flaviut / parse-strace.py
Created October 5, 2023 15:45
Parses an strace output file to determine how long each file spends open, and makes a treemap. This may (depending on your program) be equvilant to how long it takes to read each file.
#!/usr/bin/env python
# use with `strace --absolute-timestamps=format:unix,precision:us -o strace.log yourprogram`.
import re
import csv
import os
from collections import defaultdict
import plotly.express as px
@flaviut
flaviut / sensors3.conf
Created August 11, 2023 21:39
sensors configuration for my computer
chip "nvme-pci-*"
label temp2 "flash"
label temp3 "cpu"
# ASRock B350 Fatal1ty Gaming ITX/ac
# 2019, contributed by Erdem U. Altinyurt
# Modified by Flaviu Tamas
#
# dmi: board_name: B350 Fatal1ty Gaming ITX/ac
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""Script to draw bounding boxes and text from a Tesseract box file.
The script takes an image TIFF_FILE, draws the text and bounding boxes
of the corresponding BOX_FILE and saves the resulting OUT_FILE.
Tesseract box file columns:
<symbol> <left> <bottom> <right> <top> <page>
import macros
proc procToLambda(input: PNimrodNode): PNimrodNode {.compiletime.} =
# Ident !"foo"
# Empty
# Empty
# FormalParams
# Ident retType
# IdentDefs
# ...
CREATE USER iam_admin;
GRANT rds_iam TO iam_admin;
grant rds_superuser to iam_admin;
CREATE USER iam_readonly;
GRANT rds_iam TO iam_readonly;
GRANT pg_read_all_data to iam_readonly;
REVOKE CREATE ON SCHEMA public FROM iam_readonly;
import parseutils, pegs, myutils, strutils, re
type
Url* = object
scheme*, hostname*: String
port*: Option[Int]
username*, password*: Option[String]
path*: String
parameters*, fragments*: Option[String]