Skip to content

Instantly share code, notes, and snippets.

View zulonas's full-sized avatar

Kasparas Zulonas zulonas

View GitHub Profile
export ZSH="$HOME/.oh-my-zsh"
### PROMT STYLE
git_prompt_string() {
local branch=$(git_current_branch)
if [[ -n $branch ]]; then
echo " [$branch]"
fi
}
@zulonas
zulonas / gist:4f72938611ef99ff2dc2097b0bb91579
Last active February 5, 2024 19:33
ACTIVATING USB FORWARDING TO WSL2

author: https://github.com/BerndNW18 source: MicrosoftDocs/WSL#1868 (comment)

Hi, here is my complete solution on how to forward a USB port to WSL2, using the latest usbipd-win. Note that my use-case is connecting to an rplidar fromSlamtec, which uses a Silicon Labs CP210x USB-to-serial Interface board to connect to the actual Lidar device. ACTIVATING USB FORWARDING TO WSL2 Purpose: make USB to Serial Bridge accessible in WSL2 to test the RPLidar SDK build on WSL Linux (Ubuntu)

  1. Install usbipd-win on the Windows-host: https://github.com/dorssel/usbipd-win/releases
  2. Install USBIP tools and hardware-database in Linux (WSL) bernd@myOmen:~$ sudo apt install linux-tools-generic hwdata
@zulonas
zulonas / find_git_rev_by_md5.sh
Last active December 26, 2022 11:45 — forked from mloberg/gist:3750653
Find file in git based on md5 checksum.
#!/bin/bash
CHECKSUM=$1
FILE=$2
if [[ -z "$CHECKSUM" ]]; then
echo "Usage: $0 md5 file"
exit 1
fi
if [[ -z "$FILE" ]]; then
@zulonas
zulonas / hexdump.lua
Created October 5, 2022 14:09
hex dump for lua
local function hex_dump(buf)
for byte=1, #buf, 16 do
local chunk = buf:sub(byte, byte + 15)
io.write(string.format('%08X ', byte - 1))
chunk:gsub('.', function (c) io.write(string.format('%02X ', string.byte(c))) end)
io.write(string.rep(' ', 3 * (16 - #chunk)))
io.write(' ', chunk:gsub('%c', '.'), "\n")
end
end
--- getopt(3)-like functionality for Lua 5.1 and later
-- This is free and unencumbered software released into the public domain.
--- getopt(argv, optstring [, nonoptions])
--
-- Returns a closure suitable for "for ... in" loops. On each call the
-- closure returns the next (option, optarg). For unknown options, it
-- returns ('?', option). When a required optarg is missing, it returns
-- (':', option). It's reasonable to continue parsing after errors.
-- Returns nil when done.
@zulonas
zulonas / mikrotik IPv6 Firewall
Last active February 7, 2022 12:52 — forked from tiernano/mikrotik IPv6 Firewall
Mikrotik IPv6 Firewall
/ipv6 firewall filter
add chain=input action=accept comment="Allow established connections" connection-state=established
add chain=input action=accept comment="Allow related connections" connection-state=related
add chain=input action=accept comment="Allow ICMP" protocol=icmpv6
add chain=input action=reject comment="Reject invalid packets" connection-state=invalid
add chain=input action=accept comment="Allow lo" in-interface=lo
add chain=input action=accept comment="Allow local network" in-interface=LAN
add action=add-src-to-address-list address-list=trying_to_login address-list-timeout=1d chain=input dst-port=22 protocol=tcp comment="list IP's who try remote login"
add action=drop chain=input comment="drop ssh brute forcers" dst-port=22 protocol=tcp src-address-list=ssh_blacklist
add chain=input action=reject comment="Reject TCP connections by default" protocol=tcp reject-with=tcp-reset
#!/bin/bash
sudo apt update -y && sudo apt dist-upgrade -y
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh && rm get-docker.sh
sudo groupadd docker
sudo usermod -aG docker $USER
#include <stdio.h>
#include <syslog.h>
#define LOG(FORMAT, ...) {\
openlog(NULL, LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);\
syslog(LOG_INFO, "%s:%d " FORMAT "\n", __BASE_FILE__, __LINE__, ##__VA_ARGS__);\
closelog();\
}
int main()
@zulonas
zulonas / dump_socket.sh
Created June 9, 2021 08:09 — forked from jhass/dump_socket.sh
Capture unix socket to pcap file with socat and tshark
#!/bin/bash
# Parameters
socket="/run/foo.sock"
dump="/tmp/capture.pcap"
# Extract repetition
port=9876
source_socket="$(dirname "${socket}")/$(basename "${socket}").orig"