Skip to content

Instantly share code, notes, and snippets.

View sevkin's full-sized avatar

Vsevolod Balashov sevkin

View GitHub Profile
@sevkin
sevkin / getfreeport.go
Last active May 4, 2025 15:24
get free port in golang
// GetFreePort asks the kernel for a free open port that is ready to use.
func GetFreePort() (port int, err error) {
var a *net.TCPAddr
if a, err = net.ResolveTCPAddr("tcp", "localhost:0"); err == nil {
var l *net.TCPListener
if l, err = net.ListenTCP("tcp", a); err == nil {
defer l.Close()
return l.Addr().(*net.TCPAddr).Port, nil
}
}
@sevkin
sevkin / Makefile
Created May 21, 2019 10:45
SSL generate without questions
CN := example.com
gen_key:
openssl req -nodes -newkey rsa:4096 -keyout $(CN).key.new -noout -subj \
"/C=RU/CN=www.$(CN)"
gen_csr:
openssl req -new -key $(CN).key -out $(CN).csr -subj \
"/C=RU/CN=www.$(CN)"
@sevkin
sevkin / bootstrap.yml
Last active December 24, 2019 14:47
ansible bootstrap python on deb based distros
- hosts: all
any_errors_fatal: True
gather_facts: no
become: True
tasks:
- name: test python-apt
raw: "which python && python -c \"import apt\""
ignore_errors: True
changed_when: False
failed_when: False
@sevkin
sevkin / vcf2csv.py
Last active August 14, 2021 11:59
конвертер контактов из яндекс почты в список для "рассылки"
import vobject # pip install vobject
import argparse
import csv
import sys
def notify_skip(card: vobject.vCard) -> None:
print(sys.stderr, 'skipped:', card,
file=sys.stderr)
pass
@sevkin
sevkin / Schematic.desktop
Last active January 9, 2022 14:15
diptrace ubuntu tricks
# 1. install wine (from winehq site, not repo)
# 2. wine dipfree_en.exe
# 3. apt install winbind to resolve ntlm_auth
# 4. add MESA_GL_VERSION_OVERRIDE=4.5COMPAT in .desktop files to resolve GLXBadFBConfig (on my intel video)
# 5. follow https://askubuntu.com/questions/323437/how-to-prevent-wine-from-adding-file-associations
# to back xdg-open <url> in browser
# ( rm ~/.local/share/appliations/wine-extension-htm; update-mime-database ~/.local/share/mime/ )
# 5.1. check it
# xdg-settings get default-web-browser
@sevkin
sevkin / ipqos.conf
Created December 26, 2021 06:30
ssh hangs on raspberry pi
# /etc/ssh/sshd_config.d/ipqos.conf
# https://discourse.osmc.tv/t/solved-ssh-connection-sometimes-hangs/76504/5
IPQoS cs0 cs0
@sevkin
sevkin / no_space_left_inodes.sh
Last active May 3, 2023 07:48
100% inodes used / no space left
# 1. search where is the most space use
for i in /*; do echo $i; find $i |wc -l; done
# or
for i in /var/*; do echo $i; find $i |wc -l; done
# 2. delete unused files (in my case php sessions)
@sevkin
sevkin / setup_cura5_ubuntu.sh
Created June 8, 2022 18:45
cura 5 ubuntu 22.04 mesa opengl
# setup cura 5 on ubuntu 22.04 with mesa opengl
# 1. unpack appimage
./Ultimaker-Cura-5.0.0-linux.AppImage --appimage-extract
cd ./squashfs-root
# 2. fix "dri not found"
# libGL error: MESA-LOADER: failed to open crocus: /usr/lib/dri/crocus_dri.so: cannot open shared object
# file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)
@sevkin
sevkin / fedora_cant_login.md
Created July 30, 2022 22:46
fedora existing user can`t login

https://www.reddit.com/r/Fedora/comments/88rze5/fedora_wont_let_me_login_into_preexisting_user/

I've kept my /home partition the same across distros. I just installed Fedora KDE spin, but not it won't let me login through SDDM. This hasn't been an issue with other distributions like Ubuntu or Arch. Not the best first impression...

How do I fix this?

I get the following error when trying to login in the console:

 -- username : /home/username: change directory failed: permission denied
@sevkin
sevkin / mimeapps.list
Created November 28, 2022 18:12
Thunar's volatile default application
# src: ~/.config/mimeapps.list
# url: https://binfalse.de/2019/06/27/thunar-s-volatile-default-application/
# default open
[Default Applications]
text/plain=xed.desktop
# open with submenu
[Added Associations]
text/plain=code-oss.desktop;nvim.desktop;