Skip to content

Instantly share code, notes, and snippets.

View ph20's full-sized avatar

Alexander Grynchuk ph20

  • Capgemini Engineering
  • Ukraine
View GitHub Profile
@ph20
ph20 / code_style.py
Created January 9, 2025 11:54
Code style
import winreg
import datetime
from zvapp.logic.GENERAL import GEN
class Login:
# def login():
# login = {}
# user_servers = Login.get_registry_servers("user_servers", "Software\\Ardom\\ZVPYTHON\\Servers")
# login['winreg'] = user_servers
# login['serversList'] = list(Login.JSON_try(user_servers,'user_servers').keys())
#!/usr/bin/env python3
"""
Add (or remove) a “# <relative‑path>” comment on the first line of selected files,
while skipping everything ignored by .gitignore.
New in v2
──────────
• Respects .gitignore automatically
• Supports Dockerfile, Makefile, *.sh and .gitlab-ci.yml
"""
@ph20
ph20 / gist:9c9c1de8ddbc2e3b0665356abfe9bf26
Created August 14, 2024 17:13
scan and show profile name directory name for google chrome profiles
find ~/.config/google-chrome/ -name "Preferences" -exec sh -c '
for file; do
dir=$(dirname "$file")
profile_name=$(jq -r .profile.name "$file")
echo "$dir: $profile_name"
done
' sh {} +
@ph20
ph20 / build-python3-static.sh
Last active March 2, 2024 00:10
Script compiles a static version of Python 3.8 and its dependencies into a minimized, portable package, streamlining deployment across diverse environments.
et -e # Exit on error
# Define versions
OPENSSL_VERSION="openssl-1.1.1k"
ZLIB_VERSION="zlib-1.2.12"
LIBFFI_VERSION="libffi-3.3"
PYTHON_VERSION="3.8.18"
# Define the final installation directory
FINAL_INSTALL_DIR="/opt/python3.8-static"
@ph20
ph20 / check_internet.sh
Created February 23, 2024 09:58
Automatically Managing Network Routes on Raspberry Pi for Reliable Internet Connectivity
#!/bin/bash
# IP for Google's DNS server used for testing connectivity
TEST_IP=8.8.8.8
# Ping TEST_IP using wlan0. If successful, ensure routing through wlan0
if ping -I wlan0 -c 4 $TEST_IP > /dev/null; then
echo "Internet connectivity is available through wlan0. Adjusting routes..."
# Get the default gateway IP for wlan0
GATEWAY_IP=$(ip route show default via | grep wlan0 | awk '{print $3}')
@ph20
ph20 / deploy_sshd.ps1
Created February 9, 2024 16:54
Install ssh server on windows
# enable/instgall sshd server
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
# Start the SSH service
Start-Service sshd
# OPTIONAL: Set the SSH service to start automatically
Set-Service -Name sshd -StartupType 'Automatic'
@ph20
ph20 / seahub.service
Created December 26, 2023 19:13
workable seafile config /etc/systemd/system/seahub.service
[Unit]
Description=Seafile hub
After=network.target seafile.service
[Service]
Type=forking
# change start to start-fastcgi if you want to run fastcgi
ExecStart=/opt/seafilepro/seafile-server-latest/seahub.sh start
ExecStop=/opt/seafilepro/seafile-server-latest/seahub.sh stop
User=seafilepro
@ph20
ph20 / seafile.service
Created December 26, 2023 19:11
workable seafile systemd config /etc/systemd/system/seafile.service
[Unit]
Description=Seafile
# add mysql.service or postgresql.service depending on your database to the line below
After=network.target
After=mysql.service
Requires=mysql.service
[Service]
Type=forking
ExecStart=/opt/seafilepro/seafile-server-latest/seafile.sh start
@ph20
ph20 / seafile.conf
Created December 26, 2023 19:09
seafile workable config
[fileserver]
port = 8082
[database]
type = mysql
host = 127.0.0.1
port = 3306
user = seafile
password = P@sswd
db_name = seafile-db
@ph20
ph20 / seafevents.conf
Last active December 26, 2023 19:08
seafile workable config
[DATABASE]
type = mysql
host = 127.0.0.1
port = 3306
username = seafile
password = P@sswd
name = seahub-db