ก๊วนซอฟท์แวร์ </softganz> SoftGang (Gang Software)

Web &amp; Software Developer Gang.

603 items|« First « Prev 8 9 (10/61) 11 12 Next » Last »|
โดย Little Bear on 4 พ.ค. 60 21:43

ต้องการให้สร้างลำดับของ sorder ของข้อมูลในกลุ่มที่มีค่า tpid เดียวกัน โดยเริ่มนับ sorder จาก 1 เป็นต้นไป และเริ่มนับ 1 ใหม่เมื่อเปลี่ยนค่า tpid

SET @f := null, @i = null;
UPDATE `jobtr`
SET
    sorder = IF(tpid = @f, @i := @i+1, @i := 1),
    tpid = (@f := tpid)
ORDER BY tpid, sorder, jobtrid;

หากไม่ต้องเริ่มต้น group

SET @i = 0;
UPDATE users SET uid = @i := @i+1 ORDER BY uid ASC;

โดย Little Bear on 10 มี.ค. 60 10:54

วันนี้อ่านข่าว ช่องโหว่ใน Apache Struts 2 เปิดทางรันโค้ดจากระยะไกล มีการโจมตีแล้ว แล้วลองมาเช็ค Apache บน production host พบว่ายังเป็น version 2.2 อยู่ ก็เลยลอง upgrade

เริ่มแรกด้วยการตรวจสอบรุ่นของ Apache ก่อน link

On Debian and Mac OS:

apachectl -v

On Red Hat and Amazon's EC2 Linux use:

httpd -v

On other verisons of Linux try:

apache2 -v

You can use two different flags:

-v # gives you the version number
-V # gives you the compile settings including version number.

If you want to run the command with the full directory like user3786265 did but don't know where your apache is located, use the whereis command:

whereis httpd

ที่ server ใช้ Directadmin ก็ใช้ DirectAdmin build

cd /usr/local/DirectAdmin/custombuild<br />
./build set apache_ver 2.4
./build update
./build clean
./build apache n
./build php n
service httpd restart

ผลปรากฏว่า start Apache ไม่ได้ ล่มทั้ง server เนื่องจากใช้ suPHP อยู่ด้วย

รีบหาข้อมูลโดยเร็ว ทำอย่างไรดี โทรศัพท์เริ่มกริ๊งกร๊างเข้ามาแล้ว......

ที่แรก คือ Updating Apache to the latest version

ที่ต่อมา คือ Invalid command 'suPHP_Engine'

ที่สำคัญคือ build suphp และ rewrite_confs

cd /usr/local/directadmin/custombuild
./build update
./build clean
./build php y
./build suphp y
./build rewrite_confs

เหตุที่เกิดปัญหา เนื่องจาก ไม่ได้ build suphp ของ Apache 2.4 ทำให้ start Apache ไม่ได้ และเมื่อ build suphp เสร็จแล้ว จะต้องสร้าง config ใหม่ด้วย build rewrite_confs

รอดตามไปอีกครั้งหนึ่ง ชีวิตนี้มีลุ้นทุกครั้งที่ต้องอัพเกรด server

โดย Little Bear on 31 ม.ค. 60 13:55

เข้าสู่ยุค https จึงจำต้องทำเสียแล้ว

มาลองติดตั้ง Let's Encrypt บน Directadmin กันอีกสักรอบ

1. เริ่มด้วยการแก้ไข config ของ Directadmin ให้สามารถใช้งาน Let's Encrypt ก่อน

nano /usr/local/directadmin/conf/directadmin.conf

สำหรับใครที่ใช้ path : /var/www/html/.well-known (ใช้โดเมนเดียว) ให้เพิ่ม

enable_ssl_sni=1
letsencrypt=1

ส่วนใครที่ใช้ path : /home/user/domains/domain.com/public_html/.well-known (ใช้หลายโดเมน) ให้เพิ่ม

enable_ssl_sni=1
letsencrypt=2

หรือจะสั่งผ่าน Terminal ก็ได้โดย

echo enable_ssl_sni=1 >> /usr/local/directadmin/conf/directadmin.conf
echo letsencrypt=2 >> /usr/local/directadmin/conf/directadmin.conf

แล้วสั่ง update config โดย

cd /usr/local/directadmin/custombuild
./build update
./build rewrite_confs

2. แล้วมาเพิ่ม Let's Encrypt ให้กับแต่ละเว็บ

กำหนดให้เว็บสามารถใช้งาน Secure SSL ก่อน

แล้วจึงไปเพิ่ม SSL Certificates ให้กับเว็บ โดยเลือก Free & automatic certificate from Let's Encrypt

(ต้องทำทั้ง www และ ไม่มี www)

ถ้าต้องการให้สามารถใช้งานได้ทั้ง https และ http ให้สร้าง link private _ html ให้ชี้ไปที่ public _ html ด้วยคำสั่ง

ln -s public _ html private _ html

แต่ถ้าต้องการให้ใช้งานเฉพาะ https อย่างเดียว ให้ rename public _ html ไปเป็น private _ html แล้วสร้าง folder public _ html ใหม่ และสร้างไฟล์ .htaccess โดยเพิ่มคำสั่ง

RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

Let's Encrypt ก็จะเป็นของเรา

โดย Little Bear on 17 พ.ย. 59 16:39

เก็บไว้เป็นข้อมูลในวันที่ต้องซื้อ harddisk ตัวใหม่ ว่าจะเลือกซื้อยี่ห้อไหนดี


ขอบคุณภาพจาก www.blognone.com จากเรื่อง Backblaze รายงานน่าเชื่อถือฮาร์ดดิสก์ไตรมาส 3 ซีเกต 8TB ทำความน่าเชื่อถือได้ดี

โดย Little Bear on 31 ต.ค. 59 10:52

top :: the Linux Top Command

top

iotop :: I/O Monitor

iotop

iftop :: Bandwidth Monitor

iftop

ดูรายละเอียดเพิ่มเติม

iptstate : IP Tables State

iptstate

ดูรายละเอียด

df :: Display Free Disk Space

df
โดย Little Bear on 27 ก.ย. 59 14:26

กลับมาใช้ Shift-ALT ในการเปลี่ยนภาษา

ดาวน์โหลดโปรแกรม Karabiner  A powerful and stable keyboard customizer for OS X.  มาติดตั้ง แล้วเลือก Change Key > For PC User > Use PC Style "Change Input Source" #1 อ่านรายละเอียดเพิ่มเติม

โดย Little Bear on 30 ส.ค. 59 10:12

ชีวิตหวนกลับมาหา Linux : Ubuntu อีกครั้งหลังส่ง MacBook ไปเข้าโรงซ่อมเป็นครั้งที่ 2 พร้อมกับการรอคอยการกลับมาอีกประมาณ 3 สัปดาห์ (รวมความแล้ว 1 ปีกว่า ๆ ไม่ได้ใช้งานเครื่องเกือบ 2 เดือน)

จึงต้องหวนกลับมาหาคำสั่ง Linux อีกครั้ง

แต่ชีวิตก็มีความสุขดี

ที่มา Geek | Linux basic comamnds

โดย Little Bear on 26 ส.ค. 59 11:46

Spec คร่าว ๆ

  • Core i7
  • RAM 16GB
  • SSD 512GB - 1TB
  • Display 4K
  • Weight < 1.3 kg

ตัวแรก Lenovo Y700 15 นิ้วรุ่นท็อป ราคา 56,900 บาท

รีวิว 1

ตัวที่สอง Lenovo เปิดตัว Yoga 910 พร้อมขอบจอสุดบางและ Yoga Tab 3 Plus แท็บเล็ตตั้งได้

 คำอธิบายภาพ : lenovo-yoka-910

ตัวที่สาม DELL XPS 13

 คำอธิบายภาพ : dell-xps-13

รายละเอียดเพิ่มเติม

อันนี้แถม เหตุเพราะน่าใช้ดีจัง

Lenovo Yoga Book แท็บเล็ตพับได้ เขียนได้สองฝั่ง เขียนบนกระดาษจริงแล้วภาพขึ้นจอด้วย

 คำอธิบายภาพ : lenovo-yoka-book

รายละเอียดเพิ่มเติม

ตัวต่อไป DELL Precision M5510 Standard SET

ชอบ Dell แต่ติดที่จอแค่ Full HD ไม่ใช่จอ 4K

 คำอธิบายภาพ : DELLPrecisionM5510

โดย Little Bear on 8 มี.ค. 59 11:33

Git เป็นระบบจัดการซอร์ส (source code management หรือบางที่ก็เรียกว่า version control system) ตัวหนึ่งที่ได้รับความนิยมจากนักพัฒนาซอฟต์แวร์ในปัจจุบัน เพียงแค่หน้าที่หลักของมันในการติดตามการเปลี่ยนแปลงและเรียกคืนไฟล์ตามช่วงเวลาต่างๆ ก็ทำให้การทำงานโดยใช้ Git บริหารไฟล์มีประสิทธิภาพมากขึ้นหลายเท่าตัว

เคยได้ยิน เคยได้ฟัง เคยอ่านมาบ้างนิดหน่อย

แต่ยังไม่เคยได้ลองใช้งานสักที

ลองตามไปอ่านแนวคิดเรื่อง GIT จาก Blognone ดูก่อน

แล้วไปลองใช้งานได้ที่ try.github.io

เสร็จแล้วก็ไปเข้าเรียนที่ GitReal

ถึงเวลาลองของจริงเสียที

ขั้นที่ 1 : สมัครใช้บริการ GitHub

เราจะใช้ github.com เป็น Git Server นะครับ จะได้ไม่ต้องติดตั้ง Git Server เอง

เข้าไปที่เว็บ GitHub ก่อนเลย แล้วสมัครใช้บริการให้เรียบร้อย เราจะได้ username เอาไว้อ้างอิงเวลาอัพไฟล์ขึ้น GitHub

ขั้นที่ 2 : สร้าง repository บน GitHub

ขั้นตอนที่ให้ลองใช้งานบน GitHub เพื่อสร้าง repository มีวิธีการคือ

  • Create and use a repository
  • Start and manage a new branch
  • Make changes to a file and push them to GitHub as commits
  • Open and merge a pull request

ลองทำตาม Hello World บนเว็บของ GitHub ได้เลยครับ

ในที่สุด เราก็จะได้ repository มา 1 ตัว ที่สามารถเอามาใช้งานบน Ubuntu ได้ด้วย

ขั้นที่ 3 : ติดตั้ง git บน Ubuntu

ก่อนอื่น เราต้องติดตั้ง git บน Ubuntu เสียก่อนด้วยคำสั่ง

sudo apt-get install git
sudo apt-get install git-core git-gui git-doc

หรือวิธีการติดตั้ง ssh key เพื่อจะได้ใช้ git push โดยไม่ต้องป้อนรหัสผ่านทุกครั้ง ได้ที่ How to Setup and Use Github in Ubuntu

ขั้นที่ 4 : ตั้งค่า config git

git config --global user.name "Your Name"
git config --global user.email "your@email.com"

ขั้นที่ 5 : ลอง git กันเลย

โหลดโครงการมาจาก GitHub

git clone git@github.com:username/projectname.git

เปลี่ยน username,projectname เป็นชื่อที่ต้องการ

คำสั่ง

เพิ่มไฟล์ที่แก้ไขเรียบร้อยก่อน push

git add --all
git add *
git add *.txt
git add folder

สั่ง commit เพื่อเตรียมอัพ

git commit -m "Message here"

สั่ง push ไฟล์ขึ้น git

git push origin master

ดึงไฟล์จาก git server git pull (or) switch branch [/code]

กรณีที่ไฟล์บน git server ถูกเปลี่ยนแปลงโดยที่เราแก้ไขไฟล์ที่ local โดยไม่ได้ pull ไฟล์ใหม่มา มีวิธีการแก้ไข 2 วิธีคือ

  1. ดึงมาใหม่แล้วให้รวมกัน

ให้ทำ stash แล้วก็ merge หลังจากนั้นก็ pull ที่ stash

git stash
git stash pop



git pull
git stash
git pull <remote name> <remote branch name> (or) switch branch
git stash apply --index

  1. แตก branch ใหม่

  2. ยกเลิกการแก้ไขที่ local

git reset --hard



คำสั่งอื่น ๆ

git fetch upstream
git merge upstream/master

และคำสั่งที่ใช้งานบ่อย ๆ

  • git remote -v to see your fetch and push remotes
  • git status to see what you have recently changed
  • git log to see a list of all committed changes done to your fork
  • git log --stat a more detailed list of all committed changes done to your fork
  • git log --graph --full-history --all --color --pretty=format:"%x1b[31m%h%x09%x1b[32m%d%x1b[0m%x20%s" a colorful text-base graph of changes. See image on the right.
โดย Little Bear on 11 ก.พ. 59 22:31

ซื้อมาหลายวันแล้ว

เคยลง Ubuntu MATE 15.10

วันนี้เห็นข้อมูล Ubuntu Core เลยขอเก็บลิงก์ไว้ก่อน จะได้เอามาลอง

อีกตัวคือ Raspbian ระบบปฏิบัติการสำหรับ Raspberry PI เป็น Debian

ซัมซุงพอร์ต Tizen ลง Raspberry Pi มุ่งเป้าพัฒนาเป็นระบบปฏิบัติการ IoT

ที่มา Ubuntu Core

ติดตั้ง Ubuntu MATE 15.10

sudo apt-get install bzip
bzip2 -d ubuntu-mate-15.10-desktop-armhf-raspberry-pi-2.img.bz2
sudo ddrescue -D --force ubuntu-mate-15.10-desktop-armhf-raspberry-pi-2.img /dev/mmcblk0

ติดตั้ง Ubuntu Mate 16.04

ดาวน์โหลดได้ที่ Ubuntu MATE for the Raspberry Pi 2 and Raspberry Pi 3

sudo apt-get install gddrescue xz-utils
unxz ubuntu-mate-16.04-desktop-armhf-raspberry-pi.img.xz
sudo ddrescue -D --force ubuntu-mate-16.04-desktop-armhf-raspberry-pi.img /dev/mmcblk0

ติดตั้ง Ubuntu Classic image for Raspberry Pi 2

ดาวน์โหลดได้ที่ Get started with a Raspberry Pi 2 (or 3) หรือ Ubuntu Classic image for Raspberry Pi 2

แตกไฟล์ แล้วเขียน

# Note: replace /dev/sdX with the device name of your SD card (e.g. /dev/mmcblk0, /dev/sdg1 ...)

xzcat ~/Downloads/ubuntu-16.04-preinstalled-server-armhf+raspi2.img.xz | sudo dd of=/dev/sdX bs=32M
sync
603 items|« First « Prev 8 9 (10/61) 11 12 Next » Last »|