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 / list_not_installed_pkg.sh
Created July 18, 2024 00:39
Check if the required packages are installed or not; 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}")
@RealYukiSan
RealYukiSan / 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
@RealYukiSan
RealYukiSan / 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';
@RealYukiSan
RealYukiSan / bash.md
Last active June 7, 2024 07:26
A note for shell history management

Configuration

put these line on your .bashrc:

...
alias dedup='history -n; history -w; history -c; history -r;'

# https://superuser.com/a/664061/1867794
# Eternal bash history.
# ---------------------
# Undocumented feature which sets the size to "unlimited".
@RealYukiSan
RealYukiSan / arch.md
Last active April 20, 2024 01:05
Start Guest OS on QEMU

Live Boot arch linux:

qemu-system-x86_64 \
-drive format=raw,file=./archlinux-2024.04.01-x86_64.iso,index=0,media=disk \
-enable-kvm -machine pc -cpu host -m 1G -nographic

Since the above command using -nographic, so we don't start VNC server, thus don't forget to add console=ttyS0 to kernel parameter, press on the bootloader to modify kernel parameter

not related link:

@RealYukiSan
RealYukiSan / note.md
Last active April 21, 2024 12:36
Play with linux system on QEMU

The idea came from Nir Lichtman video with the title: 'Making Simple Linux Distro from Scratch'

this gist just re-document it in the form of text

Requirement

  • compiled linux kernel
  • compiled static-linked busybox
  • installed qemu

Creating initramfs

@RealYukiSan
RealYukiSan / shell.js
Created April 11, 2024 07:21
use sh inside javascript
const { spawn } = require('node:child_process')
const readline = require('node:readline');
const { stdin: input, stdout: output } = require('node:process');
const rl = readline.createInterface({ input, output });
const shell = spawn('sh')
shell.stdout.on('data', (data) => {
process.stdout.write(data.toString())
@RealYukiSan
RealYukiSan / node-http.js
Created April 11, 2024 03:33
retry mechanism
const { get } = require("node:https")
require('dotenv').config();
function fetch(url) {
return new Promise((resolve, reject) => {
get(url, (res) => {
let buff = Buffer.alloc(0);
res.on("data", chunk => buff = Buffer.concat([buff, Buffer.from(chunk)]))
res.on("error", reject)
res.on("end", () => resolve(buff))
@RealYukiSan
RealYukiSan / note.md
Last active April 11, 2024 09:37
run ngrok in background

start the program in background

setsid ngrok tcp <port> &>/dev/null </dev/null

optional, if you want store the log, enable ngrok option --log=stdout

parse the json string with node

node -pe 'JSON.parse(process.argv[1])' $(curl -s http://localhost:4040/api/tunnels)
# atau