Skip to content

Instantly share code, notes, and snippets.

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

Boyan Atanasov BoyanHH

🏠
Working from home
View GitHub Profile
@BoyanHH
BoyanHH / pg_binary_coercible_datatypes.sql
Created August 22, 2023 11:08
PostgreSQL v11+ -> All binary coercible data types including domains
WITH binary_coercible_data_types AS (
SELECT pg_catalog.format_type(castsource, NULL) AS "st",
pg_catalog.format_type(casttarget, NULL) AS "tt"
FROM pg_catalog.pg_cast c LEFT JOIN pg_catalog.pg_proc p
ON c.castfunc = p.oid
LEFT JOIN pg_catalog.pg_type ts
ON c.castsource = ts.oid
LEFT JOIN pg_catalog.pg_namespace ns
ON ns.oid = ts.typnamespace
LEFT JOIN pg_catalog.pg_type tt
import subprocess
from os.path import isfile,join
from os import listdir,environ
from stat import S_ISREG, ST_CTIME, ST_MODE
import time
import os
import glob
import sys
import argparse
from pathlib import Path
import subprocess
from os.path import isfile,join
from os import listdir,environ
import time
import os
import sys
import argparse
##add exceptions
##prints are only for debugging
def check_directory_files(directory,max_files_per_dir,max_age,max_size):
root_dir_file_counter=0
current_time_in_seconds=time.time()
for root, directories, filenames in os.walk(directory):
file_counter = 0
for file in filenames:
path=root+"/"+file
file_age_in_seconds= current_time_in_seconds - os.path.getctime(path)
file_size = str(os.path.getsize(path))
import subprocess
import os
import sys
from datetime import datetime
DIR="/var/log"
MAX_DIR_SIZE=4
SCRIPT_FILES_LOCATION="/var/log/b-logcleaner/"
SELF_CLEANUP_TIME=59 #files older than 6 minutes
#ako se poqvi nova direktoriq !!!!
@BoyanHH
BoyanHH / boyans_ssh
Last active March 13, 2019 13:06
from remote database to local server(postgres) using ssh
import sys
import subprocess
def check_conn_using_key(remote_ip,remote_port,remote_user,timeout):
"""Checks if ssh exists on local machine, if an ssh server exists on the
remote machine and if a connection could be made.Accepted Parameters are
remote ip,remote port,remote user,timeout"""
timeout=str(timeout)
try:
ssh_check_cmd="ssh "+remote_user+"@"+remote_ip+" -p"+remote_port+" -o ConnectTimeout=5 -o PasswordAuthentication=no -o PubkeyAuthentication=yes exit"
@BoyanHH
BoyanHH / update_service_monitoring
Created March 12, 2019 15:50
zabbix api automatic master item/application/dependent
import psutil
import subprocess
import os
import argparse
import sys
import configparser
from collections import OrderedDict
from pyzabbix.api import ZabbixAPI,ZabbixAPIException
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocksConfig version="1">
<editor>
<colour_sets>
<ACTIVE_COLOUR_SET>
<str>
<![CDATA[modnokai night shift v2]]>
</str>
</ACTIVE_COLOUR_SET>
<ACTIVE_LANG>
@BoyanHH
BoyanHH / alram.ino
Last active January 28, 2019 10:24
Arduino alarm buzzer with sensor
/*
Trigger pin to pin 12
Echo pin to pin 13
Buzzer to pin 8
GND pin of buzzer and sensor to GND
*/
int temp=0;
int HZ=400;
void setup() {