Skip to content

Instantly share code, notes, and snippets.

View realyukii's full-sized avatar
👀
Observing the pattern

ReYuki realyukii

👀
Observing the pattern
View GitHub Profile
@realyukii
realyukii / lsnet.sh
Last active May 24, 2024 03:15
List available network interface
#!/usr/bin/sh
for iface in $(ls /sys/class/net/); do
echo "Interface: $iface";
mode=$(iw $iface info 2>/dev/null)
if [[ $? -eq 0 ]]; then
mode=$(echo "$mode" | grep type | awk '{print $2}')
echo "Mode: $mode"
fi
ethtool -i $iface 2>/dev/null | grep -E 'driver|version';
@realyukii
realyukii / dnsmasq.conf
Created May 23, 2024 09:34
Make your laptop into a working repeater/hotspot
bind-interfaces
no-resolv
dhcp-range=192.168.33.2,192.168.33.20,12h
dhcp-option=3,192.168.33.1 # Gateway (gw)
dhcp-option=6,192.168.33.1 # DNS
log-queries
log-dhcp
@realyukii
realyukii / jsonl.py
Created June 7, 2024 01:16
prettfy jsonl with python
import json
import collections
with open('./test.jsonl', 'r') as json_file:
json_list = list(json_file)
for json_str in json_list:
result = json.loads(json_str, object_pairs_hook=collections.OrderedDict)
result = json.dumps(result, indent=4)
print(f"\n{result}")
@realyukii
realyukii / list_not_installed_pkg.sh
Last active August 8, 2024 07:37
Check if the required packages are installed or not on your arch linux system; the script was originally intended for https://wiki.lineageos.org/emulator
#!/bin/bash
# Define the list of packages
packages=(
bc bison ccache curl flex git git-lfs gnupg gperf imagemagick
lib32-readline lib32-zlib libelf liblz4 libsdl2 libssl libxml2
lzop rsync schedtool squashfs-tools xsltproc zip zlib
)
# Initialize an empty array to hold missing packages
@realyukii
realyukii / set-charge-threshold.service
Created August 8, 2024 01:41
[systemd service] add a battery's threshold on supported laptop
# put the file on /etc/systemd/system
[Unit]
Description=Set Battery Threshold
[Service]
Type=oneshot
ExecStart=/bin/bash -c 'echo 80 > /sys/class/power_supply/BAT1/charge_control_end_threshold'
RemainAfterExit=true
[Install]
@realyukii
realyukii / paccu.sh
Created August 8, 2024 03:04
[ARCH LINUX PACMAN] print the sorted date and formatted output of pacman -Qei
#!/usr/bin/bash
pacman -Qei | grep --color=never -E '^(Name|Install Date)' | awk -F': ' '/^Name/ {name=$2} /^Install Date/ {print $2, name}' | awk '
BEGIN {
# Define month names for conversion
split("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec", months, " ")
}
{
# Extract the date and time parts
if ($1 ~ /^Mon|Tue|Wed|Thu|Fri|Sat|Sun/) {
@realyukii
realyukii / meta_pkg.sh
Last active August 8, 2024 14:14
on Arch Linux, there's a meta package, and a group package. this script will looking for installed meta package on your system with pacman.
#!/bin/bash
# Script to search for meta-packages in the local system
# Function to search for meta-packages
search_meta_packages() {
echo "Searching for meta-packages..."
for pkg in $(pacman -Qq); do
# Check if the package has dependencies but no installed files
files=$(pacman -Ql $pkg) # List package files
@realyukii
realyukii / check_users.sh
Last active August 9, 2024 04:24
check if list of users exists on SQL table
#!/bin/bash
# note
# you can use grep to count occurrences of each character in a string
# check total of non-exists and exists user with: grep -c '0' output_file.txt
email_file="emails.txt" # File containing emails, assuming delimeted by CRLF
database="evaluasi"
# Loop through each email in the file
@realyukii
realyukii / data_manipulation.md
Created August 9, 2024 04:35
XLSX, SQL and CSV

When working on automation workflow, it's often easier to work with CSV format because it's easy to use and easy to parse.

you can export xlsx file to csv too and play around with it.

for example you have line-separated data like

username;password;email
reakl yuki;qwerty;[email protected]
@realyukii
realyukii / match_md5.sh
Last active August 10, 2024 10:54
track the related video based on MPV state
#!/usr/bin/bash
if [ $# -eq 0 ]; then
echo "Usage: match_md5.sh <video_path>"
exit 1
fi
find "$1" -type f -exec sh -c '
# another alternative for $HOME: readlink
MPV_STATE_PATH="$HOME/.local/state/mpv/watch_later"