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 / 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 / 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]"
}
#!/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
{
"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"
@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) {
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
#!/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 {
@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
@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 / random.go
Created September 2, 2023 08:55
some toy i forgot i wrote
package main
import (
"errors"
"fmt"
"git.tcp.direct/kayos/common/entropy"
"git.tcp.direct/kayos/common/squish"
"github.com/manifoldco/promptui"
"os"
"strconv"