Skip to content

Instantly share code, notes, and snippets.

View red-avtovo's full-sized avatar
⛩️
Zen

Aleksandr red-avtovo

⛩️
Zen
View GitHub Profile
@red-avtovo
red-avtovo / gitMigrate.sh
Created October 13, 2017 22:34
push remote git repository to other remote
#!/bin/bash
#move all branches from repo1 to repo2
repo1=origin
repo2=gogs
branches=$(git branch -r | grep -v $repo2 | grep -v $repo1/HEAD)
echo $branches | while read line ; do
branch=${line:${#repo1}+1}
git checkout $branch
@red-avtovo
red-avtovo / rdpKicker.vbs
Created October 13, 2017 23:03
Kick all rdp clients from Win Server
Dim serverName
serverName = InputBox("Server name to look sessions in","Server name prompt")
rem MsgBox(serverName)
Set oShell = WScript.CreateObject("WScript.shell")
rem qwinsta /server:server
Set oResult = oShell.Exec ("qwinsta /server:"&serverName)
strText = StrConv(oResult.StdOut.ReadAll(), "ibm866", "windows-1251")
Function StrConv(Text, SourceCharset, DestCharset)
Set Stream = CreateObject("ADODB.Stream")

Create Root CA (Done once)

Create Root Key

Attention: this is the key used to sign the certificate requests, anyone holding this can sign certificates on your behalf. So keep it in a safe place!

openssl genrsa -des3 -out rootCA.key 4096
@red-avtovo
red-avtovo / fast-pritunl-ovpn.sh
Last active December 17, 2021 19:04
Script to connect docker machine to pritunl VPN server fast
#!/bin/bash
# download a file https://pritunl-host/key/kUcPewwukHSXxONlf9NJq7KdcUsMuRwR.tar
echo "Enter url to tar with profile:"
read tar_url
mkdir vpn
wget -O- ${tar_url} | tar x -C vpn
docker run -d \
--net=host \
@red-avtovo
red-avtovo / K8S CRD exporter.sh
Created August 14, 2020 13:17
Export all CRS from the cluster in order to import it to IDE supporting crds autocompletion
kubectl get crd | sed -n '1!p' | awk '{print $1}' | xargs -I {} sh -c 'echo "Saving {}"; kubectl get crd {} -o yaml > {}.yaml'
@red-avtovo
red-avtovo / board.rs
Created August 15, 2020 09:54
Find word on board
#[cfg(test)]
mod test {
#[test]
fn word() {
let board = vec![
vec!['A','B','C','E'],
vec!['S','F','C','S'],
vec!['A','D','E','E']
];
let board2 = vec![
@red-avtovo
red-avtovo / unifi_update.sh
Created September 4, 2020 18:28
Install UniFi controller on Linux
echo "Input version number to install [e.g. 5.4.23]:"
read version
wget http://dl.ui.com/unifi/$version/unifi_sysvinit_all.deb -O unifi_$version\_sysvinit_all.deb
sudo apt install -f ./unifi_$version\_sysvinit_all.deb
@red-avtovo
red-avtovo / .p10k.zsh
Created September 27, 2020 09:59
p10k_minimal
# Generated by Powerlevel10k configuration wizard on 2020-09-04 at 19:59 CEST.
# Based on romkatv/powerlevel10k/config/p10k-classic.zsh, checksum 42402.
# Wizard options: compatible, classic, unicode, dark, flat heads, flat tails, 1 line,
# sparse, fluent, transient_prompt, instant_prompt=verbose.
# Type `p10k configure` to generate another config.
#
# Config for Powerlevel10k with classic powerline prompt style. Type `p10k configure` to generate
# your own config based on it.
#
# Tip: Looking for a nice color? Here's a one-liner to print colormap.
@red-avtovo
red-avtovo / gen.sh
Created October 19, 2020 16:23
Virtual EXT4FS drive
dd if=/dev/zero of=test.img bs=4k count=60000
#240 Mb
mkfs.ext4 test.img
tune2fs -c0 -i0 test.img
mount -o loop test.img /mnt/
@red-avtovo
red-avtovo / repeat_to_succed.sh
Created October 24, 2020 22:15
The only working so far way to downgrade debian packages
#FIND
apt-show-versions | grep newer | awk '{ print $1 }' | xargs -I {} apt-show-versions -a {} | grep $(lsb_release -sc) > repo_versions.log
#DOWNGRADE
cat repo_versions.log | awk '{ print $1 "=" $2 }' | xargs -I {} sudo DEBIAN_FRONTEND=noninteractive apt install --reinstall {} -y --allow-downgrades
#CHECK
apt-show-versions | grep newer