Skip to content

Instantly share code, notes, and snippets.

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

Yuki San RealYukiSan

👀
Observing the pattern
View GitHub Profile
@RealYukiSan
RealYukiSan / commandline_mode.md
Last active August 29, 2024 11:48
Frequently used command in neovim

The list will be updated over time.

LSP

  1. view LSP status -> LspInfo (by nvim-lspconfig), checkhealth lsp
  2. used by -> lua vim.lsp.buf.references()

Preference

  1. revert color scheme -> colorscheme vim
  2. list available colorscheme -> echo globpath(&runtimepath, 'colors/*.vim')
@RealYukiSan
RealYukiSan / cal.sh
Created August 28, 2024 00:23
expand day name on cal unix command
#!/usr/bin/sh
cal | python3 -c "
import sys
lines = sys.stdin.read().splitlines()
# Replace weekday abbreviations with full names, ensuring consistent spacing
header = lines[1]
header = header.replace('Su', 'Sunday ').replace('Mo', 'Monday ').replace('Tu', 'Tuesday ').replace('We', 'Wednesday').replace('Th', 'Thursday ').replace('Fr', 'Friday ').replace('Sa', 'Saturday ')
@RealYukiSan
RealYukiSan / 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"
@RealYukiSan
RealYukiSan / 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;yuki@mail.com
@RealYukiSan
RealYukiSan / 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
@RealYukiSan
RealYukiSan / 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
@RealYukiSan
RealYukiSan / 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/) {
@RealYukiSan
RealYukiSan / 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]
@RealYukiSan
RealYukiSan / 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
@RealYukiSan
RealYukiSan / 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}")