Skip to content

Instantly share code, notes, and snippets.

View Strykar's full-sized avatar
:electron:
pkt_label

Avinash H. Duduskar Strykar

:electron:
pkt_label
View GitHub Profile
@Strykar
Strykar / server_nftables.sh
Last active May 20, 2022 09:09
Server firewall using nftables
#!/usr/sbin/nft -f
## vim: ft=pf
flush ruleset
define wan = eth0
define cjd = tun0
define wg_int = wg0
define vpn_gw = 192.168.10.1
define vpn_net = 192.168.10.0/24
define proto_allow = { ah, esp, igmp, ipv6 }
#!/hint/bash
#
# /etc/makepkg.conf
#
#########################################################################
# SOURCE ACQUISITION
#########################################################################
#
#-- The download utilities that makepkg should use to acquire sources
[Unit]
Description=AutoSSH tunnel to remote signald Unix socket
After=network-online.target
# Note: user systemd instances do not see system-level targets like
# network-online.target by default, so this ordering hint is not
# guaranteed to work in a user unit. For reliable boot ordering,
# either run this as a system unit, or ensure the user session is
# started after the network via PAM/loginctl-linger configuration.
[Service]
@Strykar
Strykar / _README.md
Last active January 14, 2021 02:39
Bash General-Purpose Yes/No Prompt Function ("ask")

This is a general-purpose function to ask Yes/No questions in Bash, either with or without a default answer. It keeps repeating the question until it gets a valid answer.

@Strykar
Strykar / gist:377ba77479e974326cb19aa894c8ee79
Created December 29, 2020 03:12
gawk crushing busybox awk
root@apu:~# time awk 'BEGIN { OFMT = "%.0f"; for (i = 0; i < 50000; i++) print (95/100 * 42) }' > /dev/null
real 0m0.517s
user 0m0.435s
sys 0m0.081s
root@apu:~# time awk 'BEGIN { for (i = 0; i < 50000; i++) printf("%.0f\n", (95/100 * 42)) }' > /dev/null
real 0m0.862s
user 0m0.624s
sys 0m0.237s
@Strykar
Strykar / update_sqm.sh
Last active November 9, 2025 11:13
Update SQM limits in openwrt 4 times a day
#!/bin/sh
# v0.1 Avinash H. Duduskar <strykar@live.com>
# This adjusts OpenWRT SQM settings by re-calculating up/down bandwidth
# Needs the Speedtest.net CLI binary - https://www.speedtest.net/apps/cli
# Call this script every 4 or 6 hours via cron
set -euf -o pipefail
_sqm_int="queue" # Your actual wan interface: ifstatus wan | grep -e l3_device
_pul="90" # Percentage of wan upload speed to set, 90-95 is good
_pdl="95" # Percentage of wan download speed to set, 90-95 is good
@Strykar
Strykar / owrt_ncurses-Makefile
Created December 17, 2020 07:14
Attempts at building Openwrt ncurses package with the tic and tput binaries to get htop to work with the kitty terminal
#
# Copyright (C) 2006-2015 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=ncurses
==========
VULKANINFO
==========
Vulkan Instance Version: 1.2.153
Instance Extensions: count = 17
===============================
VK_EXT_acquire_xlib_display : extension revision 1
@Strykar
Strykar / failover.sh
Last active November 3, 2022 21:03 — forked from Apsu/failover.sh
An example failover script for dual WAN, using a ping healthcheck and managing default routes appropriately
#!/bin/bash -x
set -euf -o pipefail
# Test if sudo exists, comment out if sudo isn't installed
command -v sudo >/dev/null 2>&1 || { printf 'I require to be run as root, or sudo to be installed. Aborting. \n' >&2; exit 1; }
# Setting gateway's needs root privileges, elevate with sudo, tested on kernel 5.8.5-arch1-1.
# Comment out if script is called as root
if [ "$EUID" != 0 ]; then
sudo "${BASH_SOURCE[0]}" "$@"
@Strykar
Strykar / Ucenter_Ublox-Linux
Created July 1, 2020 04:49
Connect to your Ublox GPS on a Linux machine from Ucenter on Windows.
socat -v /dev/cuaU0,ispeed=115200,ospeed=115200,echo=0,raw TCP4-LISTEN:1234,reuseaddr,nodelay