Skip to content

Instantly share code, notes, and snippets.

View karolzlot's full-sized avatar
🏠
Working from home

Karol Zlot karolzlot

🏠
Working from home
View GitHub Profile
@karolzlot
karolzlot / tqdm_cpu_ram.py
Last active December 19, 2023 18:57
Monitoring real time cpu and ram usage with tqdm. If you like it please upvote this answer: https://stackoverflow.com/a/69511430/8896457
from tqdm import tqdm
from time import sleep
import psutil
with tqdm(total=100, desc='cpu%', position=1) as cpubar, tqdm(total=100, desc='ram%', position=0) as rambar:
while True:
rambar.n=psutil.virtual_memory().percent
cpubar.n=psutil.cpu_percent()
rambar.refresh()
cpubar.refresh()
@karolzlot
karolzlot / ovh_dns_settings_for_fastmail.txt
Last active March 6, 2023 11:56
OVH DNS settings for fastmail.com. They can be pasted "as text" in OVH panel to replace all current settings. You need to replace "example.fr" with your domain.
$TTL 3600
@ IN SOA dns200.anycast.me. tech.ovh.net. (2022082311 86400 3600 3600000 60)
IN NS ns200.anycast.me.
IN NS dns200.anycast.me.
IN A 66.111.4.53
IN A 66.111.4.54
IN MX 10 in1-smtp.messagingengine.com.
IN MX 20 in2-smtp.messagingengine.com.
IN TXT "v=spf1 include:spf.messagingengine.com ~all"
@karolzlot
karolzlot / normalization_comparison.py
Created December 1, 2022 01:10
Python normalization comparison
import unicodedata
from unidecode import unidecode
def normalize(text:str):
text = unicodedata.normalize('NFD', text)\
.encode('ascii', 'ignore')\
.decode("utf-8")
return text
text ='zażółć gęślą jaźń, kožušček 北亰 François aaßaa aßb'
@karolzlot
karolzlot / stack question.md
Last active July 14, 2022 12:57
Get differences between two lists of dictonaries (result as two differences lists) in Python - this is a draft for a question which finally landed here: https://stackoverflow.com/questions/68091970/get-differences-between-two-lists-of-dictionaries-result-as-two-differences-lis

I have two lists of dictonaries. They contain gmail labels and filters. I need to get differences between them in form of two differences lists. I want order of the elements to be preserved.

Example:

a=[
	{'name': 'label_a'},
	{'color': {'background': '#42d692', 'text': '#094228'}, 'name': 'label_b'},
@karolzlot
karolzlot / logitech_k740_fn_remap.ahk
Last active April 11, 2022 05:43
How to remap Logitech k740 function keys with autohotkey
; This file is autohotkey v2 script.
#SingleInstance Force
#Warn ; Enable warnings to assist with detecting common errors.
SendMode "Input" ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir A_ScriptDir ; Ensures a consistent starting directory.
InstallKeybdHook ; how it works: https://lexikos.github.io/v2/docs/commands/InstallKeybdHook.htm
@karolzlot
karolzlot / discord_hide_to_try.ahk
Last active March 13, 2022 03:13
This script is written in AHK v2
#SingleInstance Force
#Warn ; Enable warnings to assist with detecting common errors.
SendMode "Input" ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir A_ScriptDir ; Ensures a consistent starting directory.
; This script hides Discord to tray.
if (not ProcessExist("Discord.exe"))
{
Run "C:\Users\user\AppData\Local\Discord\Update.exe --processStart Discord.exe --process-start-args --start-minimized"
@karolzlot
karolzlot / tqdm1.py
Last active October 9, 2021 01:03
tdqm multiline example 1
from tqdm import tqdm
from time import sleep
with tqdm(total=4, desc='1st loop', position=2) as pbar1:
with tqdm(total=5, desc='2nd loop', position=1) as pbar2:
with tqdm(total=50, desc='3rd loop', position=0) as pbar3:
for i in range(4):
pbar2.reset()
for j in range(5):
@karolzlot
karolzlot / tqdm2.py
Created October 9, 2021 01:03
tqdm multiline example 2
from tqdm import tqdm
from time import sleep
with tqdm(total=4, desc='1st loop', position=2) as pbar1:
with tqdm(total=5, desc='2nd loop', position=1) as pbar2:
with tqdm(total=50, desc='3rd loop', position=0) as pbar3:
for i in range(4):
pbar2.reset()
for j in range(5):
@karolzlot
karolzlot / __main__.py
Created July 7, 2021 00:53
Pulumi + Python + Google Cloud Run -> version 1, with public access
import pulumi
import pulumi_gcp as gcp
region= "us-central1"
# Cloud Run Service is not enabled by default, let's enable it
enableCloudRun = gcp.projects.Service("EnableCloudRun",
service= "run.googleapis.com",
)
@karolzlot
karolzlot / gdrive_list_revisions.py
Created June 28, 2021 05:12
Example script to list all file revisions in google drive (only in root folder)
from __future__ import print_function
import os.path
from googleapiclient.discovery import build
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request
from google.oauth2.credentials import Credentials
# If modifying these scopes, delete the file token.json.
SCOPES = ['https://www.googleapis.com/auth/drive.metadata.readonly']