Skip to content

Instantly share code, notes, and snippets.

View Egor3f's full-sized avatar

Egor Egor3f

View GitHub Profile
@Egor3f
Egor3f / backup.sh
Created November 22, 2024 16:50
My own backup script (may be not useful for everyone and is certainly dirty, but works)
#!/bin/bash
### config ###
user_home=/home/user
log_dir=$user_home/restic_logs
script_dir=`cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P`
tiers="1"
backup_dirs_1="/mnt/data/media $user_home /mnt/data2 /var/lib/docker/volumes /home/borg/matrix"
# backup_dirs_2=""
@Egor3f
Egor3f / brewfat.py
Last active October 6, 2024 06:19
Show the most dependant brew packages (packages that were installed manually with the most dependencies count)
#!/opt/homebrew/bin/python3
import subprocess
curpkg = ''
count = 0
pkgs = {}
for pkg in subprocess.check_output('brew deps --tree --installed', shell=True).decode('utf-8').split('\n'):
pkg = pkg.strip()
if len(pkg) > 0 and pkg[0].isalnum():
curpkg = pkg
package sparse_gogo
import (
"fmt"
"strconv"
"testing"
)
const MIN_SIZE = 4
const MAX_SIZE = 20
package sparse_gogo
import (
"fmt"
"testing"
)
func BenchmarkMapCreate(b *testing.B) {
for i := 0; i < b.N; i++ {
m := map[int]string{
@Egor3f
Egor3f / temp.sh
Created March 7, 2022 13:33
Raspberry pi temperature
#!/bin/bash
while true; do
cur_second=`date +"%-S"`
if (( $cur_second == 0 )); then
minute=$cur_minute
echo -n $'\n'`date +"%d.%m.%y %H:%M"`:
elif (( $cur_second % 10 == 0 )); then
echo -n ' |'
fi
@Egor3f
Egor3f / makecert.sh
Last active November 18, 2024 09:52
Create custom root CA and certificates for your local services. Easy to use interactive wrapper over openssl. Works in all modern browsers, supports domains and IP's. Usage: bash <(curl -s makecert.sh)
#!/usr/bin/env bash
ROOTCERT=root.crt
ROOTKEY=root.key
ROOTDAYS=2000
CERTDAYS=500
if [[ ! -f $ROOTKEY ]]; then
read -e -p "Root CA Organization name: " -i "PersonalRootCA" rootorgname
openssl genrsa -out $ROOTKEY 4096 &&
@Egor3f
Egor3f / setup.sh
Created February 26, 2022 18:24
Setup server
#!/bin/bash
sudo apt install -y htop mc fail2ban python3-pip
sudo pip3 install thefuck
@Egor3f
Egor3f / mysql_split.py
Created December 15, 2019 07:15
Split mysql dump to multiple files by database (python3)
import sys, re
fileName = sys.argv[1]
with open(fileName, 'r', encoding='utf-8') as f:
firstSection = ''
currentFile = None
for line in f:
if line.startswith('CREATE DATABASE'):
if currentFile:
currentFile.close()