Skip to content

Instantly share code, notes, and snippets.

@nijave
nijave / gigabyte-x470-gaming-7-sensors.sh
Last active April 7, 2024 10:27
Setup sensors for Gigabyte X470 Gaming 7 w/ Fedora
#!/bin/sh
# The chip info can be found via sensors-detect in lm_sensors
# Driver `to-be-written':
# * ISA bus, address 0xa40
# Chip `ITE IT8686E Super IO Sensors' (confidence: 9)
# Driver `it87':
# * ISA bus, address 0xa60
# Chip `ITE IT8792E Super IO Sensors' (confidence: 9)
@nijave
nijave / ubuntu-k8s.sh
Created March 27, 2024 22:09
Kubernetes and cri-o v1.29 repo setup for Ubuntu 22.04 (jammy)
K8S_VERSION_MINOR=1.29
# Repos for cri-o
curl -fsSL https://pkgs.k8s.io/addons:/cri-o:/stable:/v${K8S_VERSION_MINOR}/deb/Release.key |
gpg --dearmor -o /etc/apt/keyrings/cri-o-apt-keyring.gpg
echo "deb [signed-by=/etc/apt/keyrings/cri-o-apt-keyring.gpg] https://pkgs.k8s.io/addons:/cri-o:/stable:/v${K8S_VERSION_MINOR}/deb/ /" |
tee /etc/apt/sources.list.d/cri-o.list
# Repo for Kubernetes tools/components
curl -fsSL https://pkgs.k8s.io/core:/stable:/v${K8S_VERSION_MINOR}/deb/Release.key |
@nijave
nijave / metered.ps1
Created June 23, 2019 14:56
Powershell check if on metered network
[void][Windows.Networking.Connectivity.NetworkInformation, Windows, ContentType = WindowsRuntime]
$cost = [Windows.Networking.Connectivity.NetworkInformation]::GetInternetConnectionProfile().GetConnectionCost()
$cost.ApproachingDataLimit -or $cost.OverDataLimit -or $cost.Roaming -or $cost.BackgroundDataUsageRestricted -or ($cost.NetworkCostType -ne "Unrestricted")
@nijave
nijave / grantLogonAsService.ps1
Last active January 31, 2024 09:10
Grants a user SeServiceLogonRight via Powershell (and LSA APIs...)
Add-Type @'
using System;
using System.Runtime.InteropServices;
using System.Security.Principal;
public class LsaUtility
{
[DllImport("advapi32.dll")]
private static extern int LsaOpenPolicy(
ref LSA_UNICODE_STRING sysName,
@nijave
nijave / tg-tldr.sh
Created December 13, 2023 22:18
Terragrunt pretty print
# 1. Find colored lines
# 2. Strip out useless lines
# 3. Strip empty "colored" lines
grep --color=never $'\x1b''\[[0-9;]*' \
| grep -vE 'Terraform has been|Initializing |use this backend unless the backend configuration changes|commands will detect it and remind you to do so if necessary|Refreshing state...|Read complete after |Reading...| copy_backend_before_init |Terraform has compared your real infrastructure|No changes.' \
| sed -E '/^'$'\x1b''\[0m'$'\x1b''\[32m/d'
@nijave
nijave / tethering.sh
Created June 20, 2021 21:03
Android 10 Tethering Fix
#!/bin/sh
# Don't require DUN APN type
settings put global tether_dun_required 0
# use MagiskHide Props Config
# echo "net.tethering.noprovisioning=true" >> /system/build.prop
# iptables increment TTL for nat packets since carriers block these
# Requires kernel with CONFIG_IP_NF_TARGET_TTL enabled
sudo dnf install -y VirtualBox-server
# Make a vhd
qemu-img create -f vpc test.vhd 8G
virt-format -a test.vhd --partition=gpt --filesystem=ntfs
echo 'write /readme.txt "readme"' | guestfish -a test.vhd -m /dev/sda1
mkdir test
vboximg-mount --image $(pwd)/test.vhd --rw --root test
mkdir testfs
@nijave
nijave / iscsi.sh
Last active July 11, 2023 02:18
iSCSI initiator (client) commands
# List targets
iscsiadm -m discovery --type sendtargets -p <portal host/socket>
# Login to a target
iscsiadm -m node -T <target IQN> -l
# List active/logged in targets
iscsiadm -m session
# Logout of a target
@nijave
nijave / dd-k8s-ns.sh
Created June 1, 2023 15:32
Docker Desktop Kuberentes Auto Provision Namespace
docker run --rm --privileged --pid=host ubuntu:22.04 \
nsenter -t 1 -m -u -n -i \
sh -c "sed -i '/enable-admission-plugins/{/NamespaceAutoProvision/b; s/$/,NamespaceAutoProvision/}' /etc/kubernetes/manifests/kube-apiserver.yaml"
python3 -c '
import json
import sys
from urllib.parse import urlparse, parse_qs
print(json.dumps(parse_qs(urlparse(sys.argv[1]).query)))
'