Skip to content

Instantly share code, notes, and snippets.

View meetnick's full-sized avatar

Niccola meetnick

  • Belo Horizonte, MG - Brazil
View GitHub Profile
@meetnick
meetnick / README.md
Created September 4, 2024 23:25
Block Tor exit nodes using systemd

Here’s a shell script that pulls all Tor exit nodes and blocks them using iptables. The script will create an ipset hash for blocking the Tor exit nodes, and you can set up a systemd service and timer to run it periodically.

1. Shell Script: block_tor_exit_nodes.sh

#!/bin/bash

# Name of the ipset list
IPSET_NAME="tor-exit-nodes"
@meetnick
meetnick / process_log_file.sh
Last active August 12, 2024 16:58
Convert seconds past datetime to datetime
#!/bin/bash
# Function to calculate datetime after a given number of seconds from a starting datetime
calculate_datetime() {
local start_datetime="$1"
local elapsed_seconds="$2"
# Convert the start datetime to seconds since the epoch
local start_epoch=$(date -d "$start_datetime" +%s)

For my reference in the future I will record here the steps that I had to follow in order to install Openwrt on the tp-link router EX220. This was done using a Windows 11 machine.

Disclaimer: Use this tutorial at your own risk. We are not responsible for any damage/harms done to your device using the information from this tutorial.

Steps to install OpenWRT on EX220 router

OEM installation using the serial + TFTP method

These are the steps provided at the official https://openwrt.org/toh/tp-link/ex220_v1 page:

@meetnick
meetnick / Encryption.md
Last active June 4, 2024 19:47
ROG Zephyrus M16 on Linux
@meetnick
meetnick / Windows.md
Last active August 23, 2024 10:44
ASUS ROG Zephyrus M16 Tweak guide

As some people reported sleep-related problems and also other issues with the M16, which I also encountereed on my own and fixed on my device, I decided to write this down so that everyone with these problems can fix them on their machine if they run into them.

Some of them are also just features that some people are unaware of.

These fixes mostly involve changes in Windows Power Plan and Registry. I only tested them for Windows 10 for the Zephyrus M16 2021, but I'm sure they also work for Windows 11 and also for the 2022 version.

Note: My Windows is set to German. I took the English names for the power plan settings out of the registry. They might be called different depending on language settings. The names of the registry keys themselves are unaffected by your language setting.

@meetnick
meetnick / configure_ac_change_script.sh
Last active February 5, 2023 22:41
Script to run when AC power supply state changes
#!/bin/sh
# create udev rule
sudo tee "/etc/udev/rules.d/60-ac-or-battery-change.rules" > /dev/null <<'EOF'
# Rule for when switching to battery
ACTION=="change",SUBSYSTEM=="power_supply",ENV{POWER_SUPPLY_ONLINE}=="0",ENV{DISPLAY}=":1",ENV{XAUTHORITY}="/run/user/1000/gdm/Xauthority",ENV{DBUS_SESSION_BUS_ADDRESS}="unix:path=/run/user/1000/bus",RUN+="/usr/bin/su niccola -c '/usr/bin/ac_change.sh 0'"
# Rule for when switching to powersupply
ACTION=="change",SUBSYSTEM=="power_supply",ENV{POWER_SUPPLY_ONLINE}=="1",ENV{DISPLAY}=":1",ENV{XAUTHORITY}="/run/user/1000/gdm/Xauthority",ENV{DBUS_SESSION_BUS_ADDRESS}="unix:path=/run/user/1000/bus",RUN+="/usr/bin/su niccola -c '/usr/bin/ac_change.sh 1'"
EOF
Add-Type -AssemblyName PresentationCore,PresentationFramework
Add-Type -AssemblyName System.Windows.Forms
[System.Windows.Forms.Application]::EnableVisualStyles()
$ErrorActionPreference = 'SilentlyContinue'
$wshell = New-Object -ComObject Wscript.Shell
$Button = [System.Windows.MessageBoxButton]::YesNo
$ErrorIco = [System.Windows.MessageBoxImage]::None
$Ask = 'Do you want to run this as an Administrator?
"Yes" to Run as an Administrator
@meetnick
meetnick / gist:b92caf5834f2fa0ec57032cb6872cdf2
Created December 30, 2021 13:52
Disable sound power save ubuntu
#!/bin/bash
# Check for current power save state
cat /sys/module/snd_hda_intel/parameters/power_save
cat /sys/module/snd_hda_intel/parameters/power_save_controller
# Immediately disable session power save
echo "0" | sudo tee /sys/module/snd_hda_intel/parameters/power_save
echo "0" | sudo tee /sys/module/snd_hda_intel/parameters/power_save_controller
# Disable power save forever
@meetnick
meetnick / gist:3984c3f81426103de71d7423bd3f1a20
Last active December 29, 2021 23:09
Improve Ubuntu audio quality
#!/bin/bash
# install pulseeffects
sudo apt-get install pulseeffects lsp-plugins -y
# run pulseeffects and reset to its defaults
pulseeffects -r &
#
# 1) Install all presets
# 2) Install Perfect EQ preset
@meetnick
meetnick / LineageOS Android Encryption fixing
Created April 7, 2021 20:03
This is a guide for allowing encryption with Android LineageOS
# DON'T ENCRYPT YOUR PHONE WITH ANY LOCK PATTERN SET (e.g. PIN) BEFORE YOU FOLLOW THIS GUIDE
# Enter terminal (Example TWRP -> Advanced -> Terminal) and type:
df
# df output example:
# Filesystem 1K-blocks Used Available Use% Mounted on
# /dev/block/mmcblk0p12 12324784 546144 60353600 4% /data
# From the above output, we have to remember the mmcblk block and partition numbers (/dev/block/mmcblk0p12).
# Also need to remember 1K-blocks value amount (12324784)
# Now umount /data in TWRP. For this, go to Mount > deselect Data