Skip to content

Instantly share code, notes, and snippets.

View yunginnanet's full-sized avatar
👋
looking for work

kayos yunginnanet

👋
looking for work
View GitHub Profile
@yunginnanet
yunginnanet / relocate.sh
Last active August 29, 2023 02:42
carefully move directory to diff location and then create symlink in original location to new location
#!/usr/bin/env bash
# included shebang for completeness but likely you'd wanna tack this onto a profile or bashrc, something that gets sourced by your shell
function isDir() {
if [ -d "$1" ]; then return 0; else
echo "$1 is not a directory, bail"
return 1
fi
}
@yunginnanet
yunginnanet / docker.sh
Last active October 8, 2024 23:26
install docker on ubuntu one liner
# pretty version
#
##!/bin/bash
#
## optional
#apt-get update
#apt-get -y full-upgrade
#
## pre-deps
#apt-get -y install git curl wget ca-certificates curl gnupg lsb-release
#!/usr/bin/env bash
_port=${LXD_PORT:-"8443"}
_fqdn=${LXD_FQDN:-"ebaumsworld.com"}
set -e
function req {
go version || return 1
git version || return 1
ssh -V || return 1
}
function ensure_path {
while :; do data="$(sensors | grep Tctl | awk '{print $2}' | tr -d '+' | awk -F '.' '{print $1}')"; case $data in 4[0-9]) col="blue" ;; 5[0-9]) col="green" ;; 5[0-9]) col="green" ;; 6[0-9]) col="yellow" ;; 7[0-9]) col="red" ;; 8[0-9]) col="red" ;; 9[0-9]) col="red" ;; *) col="white" ;; esac ; out="$(echo "$data°C" | toilet -f fig.mono12 | colorize $col/black --attr bold)"; clear; echo "$out"; sleep 0.5; done
@yunginnanet
yunginnanet / getBaud.go
Last active December 12, 2022 00:01
get current baud rate of tty/serial device in linux via ioctl syscall
package main
import (
"os"
"strconv"
"golang.org/x/sys/unix"
)
func getBaudRate(name string) (int, error) {
{
"name": "GitHub Go Search",
"description": "Add Golang GitHub results to your search engines",
"version": "0.1",
"manifest_version": 2,
"icons": {
"20": "icon.svg",
"48": "icon.svg",
"96": "icon.svg"
#!/usr/bin/env bash
_IF=$1
# note that if you have different masks i'm bad at bash and this is only removing '/24' atm
/bin/ip --brief a | grep "$_IF" | sed 's|/24||g' | awk -F 'P' '{print $NF}' | sed 's| |\n|g' | grep \. | sort | while read line; do
echo -e "-A INPUT -i $_IF -s $line -j LOG --log-prefix '[$line SPOOF DROP] '\n-A INPUT -i $_IF -s $line -j DROP";
done
@yunginnanet
yunginnanet / run-on-all-nodes.sh
Last active October 19, 2022 07:10
for clusters, run command on all nodes in hosts
#!/usr/bin/env bash
# further development here: https://git.tcp.direct/tcp.direct/proxmox-scripts
_ignore=("tcp.ac")
get-targets() {
cat /etc/hosts | awk '{print $NF}' | grep -v localhost | grep -v "$(uname -n | awk -F '.' '{print $1}')" | /bin/grep "[a-z]"
}
@yunginnanet
yunginnanet / ipt-dedup.sh
Last active February 24, 2022 07:32 — forked from wallneradam/ipt-dedup.sh
Iptables rules deduplication script (with ipv6 support) **v6 only lightly tested**
#!/bin/sh
ipt="iptables -w"
ip6t="ip6tables -w"
dedup() {
iptables-save | sed -n "/$1/,/COMMIT/p" | grep "^-" | sort | uniq -dc | while read l
do
c=$(echo "$l" | sed "s|^[ ]*\([0-9]*\).*$|\1|")
rule=$(echo "$l" | sed "s|^[ ]*[0-9]* -A\(.*\)$|-t $1 -D\1|")
@yunginnanet
yunginnanet / hashmap.sh
Last active February 25, 2022 17:31
ingest key/values - deduplicate the keys and append the values where they belong (made for processing files with ip:port format into nmap commands)
#!/usr/bin/env bash
_TEMPLATE="nmap -p [v] [k] -oX [k].xml"
_KVSEP=':'
# - - - - - - - - - - - - - - - - - - - - - - -
# example usage:
#
# _TEMPLATE="nmap -p [v] [k] -oX [k].xml"
#