บทความ

ทดสอบเขียน Gist by Github

ทดสอบครับ ตัวอย่างสคริปต์ PHP แสดง MAC Address

MySQL Connector C API (libmysqlclient) install and configure in MacOS

รูปภาพ
Preface I am the mad (maybe fool) guy who doesn’t prefer to install services (like MySQL, PostgreSQL and so on) into development machine, instead using docker containers , this way gives me a lot of flexibilities, for example, I could have multiple versions of MySQL servers (each version could be project-specific depends on requirements), besides no unnecessary processes are running in my development machine.     This writing for those concerns who don’t have MySQL server installed into MacOS powered development machine (like MacBook Pro ) but need to work with MySQL connection through programming languages (i.e Python in my case). Bellows are focused on ´ MySQL-Python ´, ´ mysqlclient ´ installation problems and solutions. If you have MySQL server installed through Homebrew , we don’t expect you are facing any connection related problem. Prerequisite As a requirement of my solution, I assume you already have Homebrew installed on your machine, other than going to the offic

เปลี่ยนรหัสผ่าน MySQL

รูปภาพ
ในกรณีที่ลืมรหัสผ่าน MySQL สามารถเปลี่ยนรหัสผ่านได้โดยทำตามขั้นตอนต่อไปนี้ Stop the MySQL service (Ubuntu and Debian) Run the following command: sudo /etc/init.d/mysql stop (CentOS, Fedora, and Red Hat Enterprise Linux) Run the following command: sudo /etc/init.d/mysqld stop Start MySQL without a password Run the following command. The ampersand (&) at the end of the command is required. sudo mysqld_safe --skip-grant-tables & Connect to MySQL Run the following command: mysql -uroot Set a new MySQL root password Run the following command: use mysql; update user set authentication_string=PASSWORD("mynewpassword") where User='root'; flush privileges; quit Stop and start the MySQL service (Ubuntu and Debian) Run the following commands: sudo /etc/init.d/mysql stop ... sudo /etc/init.d/mysql start (CentOS, Fedora, and Red Hat Enterprise Linux) Run the following commands: sudo /etc/init.d/mysqld stop ... sudo /etc/init.d/mysqld start Log

ฟอร์แมตตัวเลขและฟอแมตวันที่ สำหรับ django templates

รูปภาพ
การใช้งานฟอร์แมตตัวเลข บน HTML Template สำหรับ django มีขั้นตอนดังนี้ 1. ติดตั้งส่วนเสริมของ django ใน INSTALLED_APPS  'django.contrib.humanize', 2. เรียกใช้งานในหน้า HTML Template {% load humanize %} 3. วิธีเอาไปใช้งาน - แบบปกติ {{ myvalue|intcomma }} - จำนวนทศนิยม 2 ตำแหน่ง {{ floatvalue|floatformat:2|intcomma }} การใช้งานฟอร์แมตวันที่ บน HTML Template สำหรับ django มีขั้นตอนดังนี้ สามารถใช้คำสั่งฟิลเตอร์ (Filter) ได้เลย โดยไม่ต้องติดตั้งอะไรเพิ่มเติม ตัวอย่าง {{ mydatevalue|date:'d/m/Y H:i' }} จะได้ผลลัพธ์ ดังนี้ 27/11/2018 11:00 *มีฝรั่งเขียนอธิบายไว้ดีมาก ดูได้ที่:  simpleisbetterthancomplex **ดูอ้างอิงฟอร์แมตได้ที่นี่: django 2.1, ref. date format

ประกาศ jQuery ให้ใช้งานได้ทั้งโปรเจค สำหรับ Laravel

รูปภาพ
สำหรับการใช้ jQuery ใน Laravel แล้ว เราสามารถประกาศเป็นตัวแปรแบบ Global เพื่อให้สามารถเรียกใช้ jQuery ได้ทั้งโปรเจค โดยวิธีดังต่อไปนี้ ติดตั้ง jquery ผ่าน npm เสร็จแล้วใช้คำสั่งนี้ ... global.$ = global.jQuery = require('jquery'); โดยประกาศไว้ใน app.js (สำหรับ Laravel 5.4 ขึ้นไป)