Skip to content

Instantly share code, notes, and snippets.

View hapylestat's full-sized avatar
:octocat:
Looking for time compression tool

hapylestat

:octocat:
Looking for time compression tool
View GitHub Profile
# Remove sparce space from qcow image
# https://serverfault.com/questions/432119/is-there-any-way-to-shrink-qcow2-image-without-converting-it-raw
qemu-img convert -O qcow2 source.qcow2 shrunk.qcow2
# show progress bar for tar
# https://superuser.com/questions/168749/is-there-a-way-to-see-any-tar-progress-per-file
# note: it requires "pv" package to be installed
_folder=./folder
@hapylestat
hapylestat / [vxlan] __overlay network
Last active November 30, 2022 20:24
How to create VXLAN Without any pain (drop in solution)
nets/kvm.conf
-------------
LANID="150"
LANGROUP="239.1.1.1"
LANDEV="eth0"
LINKIP="10.235.0.1/24"
LAN_MTU=1550
# in case if dynamic VxLAN groups work unstable, use direct remotes assigment
#REMOTES=""
@hapylestat
hapylestat / 02-port-forward-profile.sh
Created May 6, 2021 05:48
Port forwarding functions
#!/bin/bash
# Put the file to: /etc/profile.d/
port-forward(){
local port=\$1
local to_ip=\$2
if [ -z \${port} ] || [ -z \${to_ip} ]; then
echo "Usage: port-forward [port] [destination ip]"
return
@hapylestat
hapylestat / _readme.txt
Last active January 24, 2022 07:38
Enable podman uder wsl2 Ubuntu
!!!!!!!!!!!!!!!
!!!! WARNING -> Ubuntu 20.10 require WSL2 kernel 5.7+, to build one please follow instructions in build-wsl-kernel.sh
!!!!!!!!!!!!!!!
Step 1. Install/Upgrade WSL2 to Ubuntu 20.10 +
source /etc/os-release
sudo sh -c "echo 'deb http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/ /' > /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list"
wget -nv https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable/xUbuntu_${VERSION_ID}/Release.key -O- | sudo apt-key add -
apt install podman
Step 2. Install Podman
@hapylestat
hapylestat / git.config
Created April 22, 2021 06:34
Add new command "find" to search through backlog
[alias]
find = log --pretty=\"format:%Cgreen%H %Cblue%s\" --name-status --grep
@hapylestat
hapylestat / container-with-limits.sh
Created April 20, 2021 22:22
Example how to make container see proper limits
#!/bin/bash
#require lxcfs
podman run --rm -it --memory=100M \
-v /var/lib/lxcfs/proc/cpuinfo:/proc/cpuinfo:rw \
-v /var/lib/lxcfs/proc/diskstats:/proc/diskstats:rw \
-v /var/lib/lxcfs/proc/meminfo:/proc/meminfo:rw \
-v /var/lib/lxcfs/proc/stat:/proc/stat:rw \
Guide requires
===============
- iptables
- ipset
- sshguard with ipset backend
Steps:
- put/modify service files below in the directory /etc/systemd/system
- adjust sshguard.conf file with settings mentined below
- adjust iptables settings by adding the following lines at the BEGGINIG of INPUT filter
@hapylestat
hapylestat / _minio_installation.md
Last active September 13, 2021 02:35
The way how to install minio on your pc
#!/us/sbin/env python3
def read_single_keypress():
"""Waits for a single keypress on stdin.
This is a silly function to call if you need to do it a lot because it has
to store stdin's current setup, setup stdin for reading single keystrokes
then read the single keystroke then revert stdin back after reading the
keystroke.
@hapylestat
hapylestat / get_terminal_size.py
Created October 31, 2018 20:53
get terminal window size
def terminal_width():
"""
refactor/reassebly of https://gist.github.com/jtriley/1108174
"""
import platform
import struct
import os
current_os = platform.system()
if current_os == 'Windows':