Skip to content

Instantly share code, notes, and snippets.

View kaspim's full-sized avatar

Martin Kašpar kaspim

View GitHub Profile
@kaspim
kaspim / git_commands.txt
Last active April 1, 2024 18:37
Multiple Git repositories for same project and tip for Git command aliases
# Multiple Git repositories for same project and tip for Git command aliases
# Add second remote
git remote add origin git@gitlab.com:kaspim/test.git
git remote add github git@github.com:kaspim/test.git
# Examples of Git global aliases
git config --global alias.pushall '!git remote | xargs -L1 git push --all'
git config --global alias.pullall '!git remote | xargs -L1 git pull --all'
git config --global alias.fetchall '!git remote | xargs -L1 git fetch --all'
# MikroTik Hairpin NAT with IP address preserve of the incoming connection (for fail2ban etc.)
/ip firewall address-list
add address=192.168.0.0/24 list=LAN
/ip firewall nat
add action=masquerade chain=srcnat dst-address=!192.168.0.1 src-address-list=LAN dst-address-list=LAN
add action=dst-nat chain=dstnat dst-address-type=local dst-port=80 protocol=tcp src-address-list=LAN to-addresses=192.168.0.2 to-ports=80
add action=dst-nat chain=dstnat dst-port=80 in-interface-list=WAN protocol=tcp to-addresses=192.168.0.2 to-ports=80
add action=dst-nat chain=dstnat dst-address-type=local dst-port=443 protocol=tcp src-address-list=LAN to-addresses=192.168.0.2 to-ports=443
@kaspim
kaspim / rsync_awdd.sh
Last active December 26, 2020 19:04
Script for backing up folders using rsync with recycle bin folder and delayed deletion of deleted files.
#!/bin/bash
# Rsync archive with delaying deletion
# Sample command: rsync_awdd.sh -s /home/kaspim -d /mnt/backup/home/kaspim -t /mnt/backup/trash/kaspim -a 90
while [ ! $# -eq 0 ]
do
case $1 in
--help | -h)
echo "rsync_awdd.sh"
@kaspim
kaspim / gist:08583c38641981e6934891e5859a1284
Created December 2, 2020 08:14
VBA script for extracting URLs from cells in Excel
Public Function GetURL(c As Range) As String
On Error Resume Next
If Len(c.Hyperlinks(1).SubAddress) = 0 Then
GetURL = c.Hyperlinks(1).Address
Else
GetURL = c.Hyperlinks(1).Address & "#" & c.Hyperlinks(1).SubAddress
End If
End Function