Skip to content

Instantly share code, notes, and snippets.

View wannadrunk's full-sized avatar

WannaDrunk wannadrunk

  • Earth
View GitHub Profile
@wannadrunk
wannadrunk / debian-preseed.txt
Created November 25, 2021 19:01
Preseed sample
#_preseed_V1
#### Contents of the preconfiguration file (for bullseye)
### Localization
# Preseeding only locale sets language, country and locale.
d-i debian-installer/locale string en_US
# The values can also be preseeded individually for greater flexibility.
#d-i debian-installer/language string en
#d-i debian-installer/country string NL
#d-i debian-installer/locale string en_GB.UTF-8
@wannadrunk
wannadrunk / reverse RPi WiFi AP.md
Created November 24, 2021 07:14
refer to a few instruction to setup RPi as the WiFi AP, here is how to remove it.

Remove the packages

sudo apt purge hostapd dnsmasq

Remove all settings

if these setting files are existed, here is how to roll back

/etc/dhcpcd.conf

@wannadrunk
wannadrunk / loop-test.sh
Last active November 15, 2021 06:24
Bash script to loop test
#!/bin/bash
clear
while :
do
if [ ! -f /usr/bin/neofetch ]
then
echo -e 'Please install neofetch\nsudo apt install neofetch'
exit
else
neofetch
@wannadrunk
wannadrunk / splitevdo.sh
Last active November 12, 2021 15:39
Bash script to split long video to be 5-minute ones using ffmpeg. If you wish shorter or longer, update -t at line 21
#!/bin/bash
if [ -f "$1" ]
then
hour=$(ffmpeg -hide_banner -report -i "$1" 2>&1 | grep "Dura" | awk {'print $2'} | cut -f 1 -d ":")
min=$(ffmpeg -hide_banner -report -i "$1" 2>&1 | grep "Dura" | awk {'print $2'} | cut -f 2 -d ":")
filename=$(basename -- "$1")
filename="${filename%.*}"
filename=$(echo "${filename// /_}")
@wannadrunk
wannadrunk / shellinabox.md
Last active September 24, 2021 19:37
การทำให้ linux command ทำงานเป็นหน้าเวป
@wannadrunk
wannadrunk / chkpid.py
Created September 23, 2021 17:13
Python function to validate the checksum of Thai ID.
def chkpid(pid):
pid = "".join(pid.split())
thai_num = "๐๑๒๓๔๕๖๗๘๙"
if len(pid) != 13:
return False
if not(pid.isdigit()):
return False
if pid[0] in thai_num:
return False
@wannadrunk
wannadrunk / boinc-linux.md
Last active October 11, 2021 19:30
BOINC บน Linux

BOINC - Distributed Computing

เป็นการเอา computing resources (PC, Mobile, Server) ของเราที่เหลืออยู่ เข้าไปช่วยในการประมวลผลในโครงการด้านต่างๆ

ในการนำ computing resources ของเราเข้าร่วมนั้น ก่อนอื่นต้องทำการลงทะเบียน account กับโครงการต่างๆ เพื่อที่นำ account key มาใช้ใน boinc-client

โครงการที่แนะนำ ก็มี

@wannadrunk
wannadrunk / telegram-bot.md
Last active September 23, 2021 17:48
บันทึกความจำการทำ Telegram Bot ด้วย Python โดยใช้ python-telegram-bot
  • ใน Telegram ให้ทำการสร้าง bot account กับ @botfather ก่อน จะได้ token มาตัวหนึ่ง
  • การเขียน Python ควรทำ virtual environment เสมอสำหรับงานนั้น แล้วจึงทำการติดตั้ง lib ต่างๆ ที่จะใช้งานนั้นๆ
$ python3 -m venv .venv
$ . .venv/bin/activate
(.venv) $ pip install python-telegram-bot
#!/app/bot/.venv/bin/python
@wannadrunk
wannadrunk / python-as-service.md
Last active September 20, 2022 15:06
How to run Python script as systemd service.
  1. in Python script, make sure include #!/path/to/venv/python in the first line
  2. add a systemd service $ sudo systemctl edit --force --full name.service. In the editor complete at least these statments,
[Unit]
Description=Python Service
Wants=network.target
After=network.target

[Service]
ExecStartPre=/bin/sleep 10
@wannadrunk
wannadrunk / diskspace.sh
Created September 12, 2021 07:02
Bash script to send df information to LINE Notify / Telegram
#!/bin/bash
### Author: cHoo
### Date: August 2019
### Version: 1.01
### Description: Script to check diskspace.
# Import global variable
CONFLE="/opt/scripts/setting-global.ini"
if [ -f $CONFLE ]
then