Skip to content

Instantly share code, notes, and snippets.

View phwt's full-sized avatar
💤

Phuwathid Summaviwat phwt

💤
  • Earth, Solar System
  • 21:23 (UTC +07:00)
View GitHub Profile
@phwt
phwt / rename-local-remote.sh
Last active March 13, 2024 01:33
Rename local Git directory to match the current remote name in GitHub
export GH_PAT="ghp_xxxxxxxxxxxxxxxxxxxxxxxx"
for dir in */; do
cd "$dir" || exit
if [ -d .git ]; then
cleaned_dir=$(echo $dir | sed 's:/*$::') # Remove trailing slash
if git remote get-url origin &>/dev/null; then
remote_url=$(git remote get-url origin)
repo_ref=$(basename "$(dirname "$remote_url")")/$(basename "$remote_url" | sed 's:.git*$::')
@phwt
phwt / get-config.sh
Created August 12, 2023 06:43
AdGuard Home Configuration in Docker
VOLUME_NAME="" # docker volume ls
MOUNTPOINT=$(docker volume inspect $VOLUME_NAME | jq -r ".[0].Mountpoint")
docker run --rm -i -v=$VOLUME_NAME:$MOUNTPOINT busybox cat $MOUNTPOINT/AdGuardHome.yaml | less
@phwt
phwt / pluralsight-move.py
Last active March 22, 2023 14:25
Move Pluralsight's exercise PDF out of its folder and prefix with folder name
import sys
from os import listdir, getcwd, rename
from os.path import isfile, join
try:
cwd = sys.argv[1]
except:
cwd = getcwd()
for items in listdir(cwd):
@phwt
phwt / jsx-emmet.md
Created June 18, 2022 08:55
Emmet with React JSX

Location: Settings (Cmd+,) > Workspace > Extensions > Emmet > settings.json

{
  "emmet.includeLanguages": {
    "javascript": "javascriptreact"
  }
}
ประสิทธิภาพในการกรอง N R P
95% N95 R95 P95
99% N99 R99 P99
99.97% N100 R100 P100
@phwt
phwt / 3.py
Created January 23, 2020 09:44
'''
จงเขียนเกมส์ Monster Fighting ที่เป็นการนำ Monster มาต่อสู้กัน
โดยเกมส์นี้จะผลัดกันเล่นคนละรอบ ในแต่ละรอบผู้เล่นจะต้องเลือกว่าจะให้ Monster ทำการโจมตี (A) หรือ ป้องกัน (D)
กฏการเล่นมีดังนี้
1. ถ้า Monster ทั้ง 2 ตัวโจมตีเข้าหากัน (เลือก A ทั้งคู่) ค่า HP จะลดเท่ากับค่าที่ถูกโจมตี เช่น
Mon 1 มี HP 15 เลือกโจมตีสุ่มค่าโจมตีได้ 5
Mon 2 มี HP 15 เลือกโจมตีสุ่มค่าโจมตีได้ 8
เมื่อจบรอบ Mon 1 จะมี HP 7 และ Mon 2 จะมี HP 10
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
const char* ssid = "LAB304-2.4GHz";
const char* password = "304304304";
void Line_Notify(int value1, int value2, int value3) {
Serial.println("hey");
HTTPClient http; //Declare object of class HTTPClient

Multimedia Technology

Selector

ใช้อ้างถึง Element ต่างๆในหน้า

  • *: เลือกทุกตัว
  • .class: Class
  • #id: ID
  • tag: Tag

Computer Programming

ตัวแปร

type variable_name = value;

Type

ประเภทตัวแปร

  • char