ลบ Credential ที่บันทึกไว้ใน Git

  1. ลบ Credential ที่บันทึกไว้ใน Git: Git อาจเก็บข้อมูลบัญชีที่คุณเคยล็อกอินไว้ใน Credential Manager (สำหรับ Windows) หรือ Keychain (สำหรับ macOS) หรือตัวจัดการ Credential ของระบบปฏิบัติการอื่นๆคุณสามารถลบ Credential ที่บันทึกไว้โดยใช้คำสั่ง:
    git credential-manager-core erase

    หลังจากรันคำสั่งนี้ Git จะถามให้คุณล็อกอินใหม่เมื่อคุณพยายามใช้งานคำสั่งที่ต้องยืนยันตัวตนอีกครั้ง เช่น git push หรือ git clone

  2. สำหรับ macOS (Keychain):
    • เปิดแอป Keychain Access และค้นหาชื่อ git หรือ github.com
    • ลบรายการที่เกี่ยวข้องกับ Git หรือ GitHub ออก
  3. สำหรับ Windows (Credential Manager):
    • เปิด Credential Manager (ใน Control Panel)
    • เลือก Windows Credentials หรือ Generic Credentials
    • ค้นหารายการที่มีชื่อ git หรือ github.com
    • ลบ Credential นั้นออก
  4. เปลี่ยนข้อมูลบัญชี Git ที่ตั้งค่าไว้ใน global config: หากคุณต้องการเปลี่ยนข้อมูลบัญชี (ชื่อผู้ใช้หรืออีเมล) ที่ Git บันทึกไว้ใน global config ให้ใช้คำสั่งนี้:
    git config --global --unset user.name
    git config --global --unset user.email

    หลังจากนั้น ตั้งค่าบัญชีใหม่ด้วยคำสั่ง:

    git config --global user.name "Your New Username"
    git config --global user.email "Your New Email"

เมื่อทำขั้นตอนเหล่านี้แล้ว Git จะขอให้คุณล็อกอินใหม่ในการใช้งานคำสั่งที่ต้องยืนยันตัวตน

ลบ index.php ของ Codeigniter 3 ใน docker


วิธีการลบ index.php?

  1. สร้างไฟล์ .htaccess

ต้องเริ่มจากการสร้างไฟล์ .htaccess ในไดเรกทอรีหลักของโปรเจคหรือไดเรกทอรีของ CodeIgniter ของเรา การสร้างไฟล์ .htaccess จะช่วยให้เราแก้ไขกฎการเขียนใหม่ได้โดยไม่ต้องเข้าถึงไฟล์กำหนดค่าเซิร์ฟเวอร์ โดยเนื่องจากเหตุนี้ .htaccess เป็นสิ่งสำคัญต่อความปลอดภัยของแอปพลิเคชันเว็บของเรา และต้องให้แน่ใจว่าไฟล์นี้ถูกซ่อน เพราะ htaccess เป็นตัวย่อที่ใช้สำหรับ Hypertext Access มันเป็นไฟล์กำหนดค่าที่ควบคุมไดเรกทอรี “.htaccess”

หลังจากสร้างไฟล์ .htaccess เสร็จแล้ว ให้เพิ่มโค้ดต่อไปนี้ในไฟล์นี้

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
  1. การลบไฟล์ index.php

เปิดไฟล์ config.php ในโปรแกรมแก้ไขข้อความของคุณและลบ index.php จากตรงนี้

เปลี่ยน:

$config['index_page'] = "index.php";

เป็น:

$config['index_page'] = "";

แต่ในบางกรณีบางครั้ง อาจเกิดกรณีที่การตั้งค่าเริ่มต้นสำหรับ url_protocol ไม่ทำงานอย่างเหมาะสม สำหรับการแก้ปัญหานี้ เราต้องเปิดไฟล์ config.php และ

เปลี่ยน:

$config['uri_protocol'] = "AUTO";

เป็น:

$config['uri_protocol'] = "REQUEST_URI";

มักจะตั้งค่าเป็น REQUEST_URI อยู่แล้ว ในกรณีนั้น เราไม่ต้องเปลี่ยนมัน

  1. เปิดใช้งาน apache mode rewrite

ตอนนี้เราจะต้องเปิดใช้งาน mod_rewrite ด้วยคำสั่งต่อไปนี้

$ sudo a2enmod rewrite
  1. รีสตาร์ท Apache

ตอนนี้เราต้องรีสตาร์ท Apache โดยเขียนคำสั่งต่อไปนี้

$ sudo service apache2 restart

วิธีแก้ Port ซ้ำ/Port ชน Linux ไม่สามารถรันโปรแกรมได้

ลิสต์รายการ Port ที่รันอยู่ sudo netstat -tulpn | grep LISTEN ลบ Process ที่รัน port อยู่ it will show the list of processes with port number and process id the number before /java is a process id. Now use kill command to kill the process kill -9 16085 -9 implies the process will be killed forcefully.

แก้พื้นที่เต็ม /dev/vda1 Docker

แก้พื้นที่เต็ม /dev/vda1 แก้ /dev/vda1 Disk เต็มของ Docker (คำสั่งเช็ค df -h) ปัญหา Build Docker แล้วพื้นที่ /dev/vda1 เพิ่มขึ้นจาก Images เก่าไม่ถูกเคลียร์ออก พิมพ์คำสั่งข้างล่าง ตามคำอธิบาย Make sure all docker containers are down: docker compose down Remove problematic overlay2: sudo rm -R /var/lib/docker/overlay2 Remove images: sudo rm -R /var/lib/docker/image Clear any other cached data: docker system prune -f Restart docker service: … Read more

รันไฟล์ python จากไฟล์ python อื่น (ส่ง Param ได้ด้วย)

ข้างล่างคือโค๊ดที่รันไฟล์ python test_arg.py โดยส่ง param เป็น arg1 arg2 arg3

// run file
import os
os.system('python test_arg.py arg1 arg2 arg3')

และใน test_arg.py ก็รับ param ด้วย sys.argv[_param ที่ n_]

// test_arg.py
import sys
# sys.argv[1] คือ  arg1 ตัวที่ 1
print(sys.argv[1])