แสดงกระทู้

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - อั๋น ทรงวุฒิ

หน้า: [1] 2 3 ... 21
1
อ้างถึง
https://github.com/wg/wrk

git clone https://github.com/wg/wrk
cd wrk
make
sudo mv wrk /usr/local/bin

wrk -t12 -c400 -d30s http://127.0.0.1:8080/index.html

ยิง request 30 วินาที โดยใช้ 12 threads แล้วเช็คสถิติ
This runs a benchmark for 30 seconds, using 12 threads, and keeping 400 HTTP connections open.

2
WSL และ VMWARE ไม่สามารถทำงานร่วมกันได้

การปิดเปิด HYPER-V จะทำให้ใช้งานได้เพียงตัวใดตัวหนึ่ง

หากต้องการใช้ VMWARE

อ้างถึง
Bcdedit /set hypervisorlaunchtype off

restart เครื่อง


หากต้องการใช้ WSL

อ้างถึง
Bcdedit /set hypervisorlaunchtype auto

restart เครื่อง


3
Opensource ของฟรีทั้งหลาย (MySQL, PostgreSQL, etc.) / install Frappe framework -- ubuntu 20.04
« เมื่อ: 28 กุมภาพันธ์ 2022, 10:35:52 PM »
sudo apt install -y  curl  git python-dev redis-server python3-pip  mariadb-server-10.3 nvim xvfb libfontconfig wkhtmltopdf  mariadb-client-10.5 libmysqlclient-dev  cron

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
(re-login)

nvm install 14
npm install -g yarn

[/etc/mysql/mariadb.conf.d/50-server.conf]
collation-server = utf8mb4_unicode_ci
bind-address = 0.0.0.0

sudo mysql
grant all privileges on *.* to frappe@'%' identified by 'frappepassword' with grant option;
grant all privileges on *.* to root@localhost identified by 'frappepassword' with grant option;
flush privileges;
exit
sudo /etc/init.d/mysql restart

pip3 install frappe-bench bpytop
bench init frappe-bench

cd frappe-bench
bench new-app hicare
## bench new-site hi.care // bench new-site default.site --db-host 127.0.0.1 --db-root-password frappepassword
bench use hi.care
bench start

4
ไปเจอ Server กากๆ ใน LA
เขียน  315 MB/s
อ่าน 4.0 MB/s

ย้ายโลด เสียดายตัง

5
ความเร็วในการเขียน

อ้างถึง
dd if=/dev/zero of=tempfile bs=1M count=4096 conv=fdatasync,notrunc status=progress oflag=direct

ความเร็วในการอ่าน

อ้างถึง
dd if=tempfile of=/dev/null bs=1M count=4096 status=progress iflag=direct

ทดลองกับ SSD ใน PC

เขียน 116 MB/s
อ่าน  235 MB/s

ทดลองกับ VPS ต่างประเทศ
เขียน 937 MB/s
อ่าน  119 MB/s

6
อ้างถึง
find . -type f -name '*' -size 0 -print0 | xargs -r0 rm

7
เกี่ยวกับเซิร์ฟเวอร์ [ Network Server ] / Re: Linux Server ใน AndroidBox
« เมื่อ: 15 พฤศจิกายน 2021, 08:35:13 AM »
ประมาณนี้นะครับ ที่เหลือก็ตัวใครตัวมัน

8
เกี่ยวกับเซิร์ฟเวอร์ [ Network Server ] / Re: Linux Server ใน AndroidBox
« เมื่อ: 15 พฤศจิกายน 2021, 08:28:56 AM »
อ้างถึง
pkg install nodejs
pkg install yarn
pkg install php

9
เกี่ยวกับเซิร์ฟเวอร์ [ Network Server ] / Re: Linux Server ใน AndroidBox
« เมื่อ: 15 พฤศจิกายน 2021, 08:19:49 AM »
เมื่อติดตั้งสำเร็จ จะพบข้อความดังนี้

RunC requires support for devices cgroup support in kernel.

If CONFIG_CGROUP_DEVICE was enabled during compile time,
you need to run the following commands (as root) in order
to use the RunC:

  mount -t tmpfs -o mode=755 tmpfs /sys/fs/cgroup
  mkdir -p /sys/fs/cgroup/devices
  mount -t cgroup -o devices cgroup /sys/fs/cgroup/devices

If you got error when running commands listed above, this
usually means that your kernel lacks CONFIG_CGROUP_DEVICE.

Setting up containerd (1.4.3) ...
Setting up docker (20.10.2) ...
NOTE: Docker requires the kernel to support
device cgroups, namespace, VETH, among others.

To check a full list of features needed, run the script:
https://github.com/moby/moby/blob/master/contrib/check-config.sh

10
Service ssh ใน termux จะทำงานที่ port 8022
เปิดใช้งานด้วยคำสั่ง sshd

การที่จะเข้าใช้จากเครื่องอื่นผ่าน usb port ทำได้โดย

อ้างถึง
adb forward tcp:8022 tcp:8022

เวลาเข้า Login ใช้งาน ก็ให้ใช้คำสั่ง

ssh  localhost -p 8022

อันนี้จาก ubuntu desktop นะครับ

11
เกี่ยวกับเซิร์ฟเวอร์ [ Network Server ] / Linux Server ใน AndroidBox
« เมื่อ: 15 พฤศจิกายน 2021, 08:08:18 AM »
เนื่องจาก AndroidBox เป็น Hardware ที่สเป็คสูง ราคาประหยัด จึงสามารถดัดแปลงใช้เป็น Server ได้

เริ่มต้นด้วยการติดตั้ง Termux และ Termux-boot โดยให้โหลดจาก F-droid เป็นหลัก เนื่องจากของ Google Play เขาหยุดพัฒนาต่อแล้ว

Termux สำหรับเป็น Openssh server
Termux boot สำหรับให้ทำงานตอนเปิดเครื่องใหม่ทุกครั้ง

เมื่อติดตั้ง termux  แล้วให้ลง openssh server ด้วยคำสั่ง

อ้างถึง
pkg install openssh

เมื่อติดตั้ง  termux-boot app เรียบร้อยแล้วให้เข้าไปสร้างไฟล์ดังนี้

~/.termux/boot/start-sshd:

อ้างถึง
#!/data/data/com.termux/files/usr/bin/sh
termux-wake-lock
sshd


การติดตั้ง

อ้างถึง
pkg install root-repo
pkg install docker

เป็นต้น

12

Server บางแห่ง มีการปิดค่า error ไม่ให้แสดงออกมาบนหน้าจอ แต่บางครั้ง เราจำเป็นต้องเช็ค error เหล่านั้น ก็สามารถเปิดเป็นกรณีพิเศษได้ โดยเพิ่มคำสั่งดังต่อไปนี้ลงไป

อ้างถึง

<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

14
โค๊ด: [Select]
#  install pcscd python-pyscard python-pil
import os
import io
import binascii
import sys
#import traits
import codecs
from PIL import Image
from smartcard.System import readers
from smartcard.util import HexListToBinString, toHexString, toBytes
# Thailand ID Smartcard
def thai2unicode(data):
 result = ''
 result = bytes(data).decode('tis-620')
 return result.strip();
def getData(cmd, req = [0x00, 0xc0, 0x00, 0x00]):
 data, sw1, sw2 = connection.transmit(cmd)
 data, sw1, sw2 = connection.transmit(req + [cmd[-1]])
 return [data, sw1, sw2];
# Check card
SELECT = [0x00, 0xA4, 0x04, 0x00, 0x08]
THAI_CARD = [0xA0, 0x00, 0x00, 0x00, 0x54, 0x48, 0x00, 0x01]
# CID
CMD_CID = [0x80, 0xb0, 0x00, 0x04, 0x02, 0x00, 0x0d]
# TH Fullname
CMD_THFULLNAME = [0x80, 0xb0, 0x00, 0x11, 0x02, 0x00, 0x64]
# EN Fullname
CMD_ENFULLNAME = [0x80, 0xb0, 0x00, 0x75, 0x02, 0x00, 0x64]
# Date of birth
CMD_BIRTH = [0x80, 0xb0, 0x00, 0xD9, 0x02, 0x00, 0x08]
# Gender
CMD_GENDER = [0x80, 0xb0, 0x00, 0xE1, 0x02, 0x00, 0x01]
# Card Issuer
CMD_ISSUER = [0x80, 0xb0, 0x00, 0xF6, 0x02, 0x00, 0x64]
# Issue Date
CMD_ISSUE = [0x80, 0xb0, 0x01, 0x67, 0x02, 0x00, 0x08]
# Expire Date
CMD_EXPIRE = [0x80, 0xb0, 0x01, 0x6F, 0x02, 0x00, 0x08]
# Address
CMD_ADDRESS = [0x80, 0xb0, 0x15, 0x79, 0x02, 0x00, 0x64]
# Photo_Part1/20
CMD_PHOTO1 = [0x80, 0xb0, 0x01, 0x7B, 0x02, 0x00, 0xFF]
# Photo_Part2/20
CMD_PHOTO2 = [0x80, 0xb0, 0x02, 0x7A, 0x02, 0x00, 0xFF]
# Photo_Part3/20
CMD_PHOTO3 = [0x80, 0xb0, 0x03, 0x79, 0x02, 0x00, 0xFF]
# Photo_Part4/20
CMD_PHOTO4 = [0x80, 0xb0, 0x04, 0x78, 0x02, 0x00, 0xFF]
# Photo_Part5/20
CMD_PHOTO5 = [0x80, 0xb0, 0x05, 0x77, 0x02, 0x00, 0xFF]
# Photo_Part6/20
CMD_PHOTO6 = [0x80, 0xb0, 0x06, 0x76, 0x02, 0x00, 0xFF]
# Photo_Part7/20
CMD_PHOTO7 = [0x80, 0xb0, 0x07, 0x75, 0x02, 0x00, 0xFF]
# Photo_Part8/20
CMD_PHOTO8 = [0x80, 0xb0, 0x08, 0x74, 0x02, 0x00, 0xFF]
# Photo_Part9/20
CMD_PHOTO9 = [0x80, 0xb0, 0x09, 0x73, 0x02, 0x00, 0xFF]
# Photo_Part10/20
CMD_PHOTO10 = [0x80, 0xb0, 0x0A, 0x72, 0x02, 0x00, 0xFF]
# Photo_Part11/20
CMD_PHOTO11 = [0x80, 0xb0, 0x0B, 0x71, 0x02, 0x00, 0xFF]
# Photo_Part12/20
CMD_PHOTO12 = [0x80, 0xb0, 0x0C, 0x70, 0x02, 0x00, 0xFF]
# Photo_Part13/20
CMD_PHOTO13 = [0x80, 0xb0, 0x0D, 0x6F, 0x02, 0x00, 0xFF]
# Photo_Part14/20
CMD_PHOTO14 = [0x80, 0xb0, 0x0E, 0x6E, 0x02, 0x00, 0xFF]
# Photo_Part15/20
CMD_PHOTO15 = [0x80, 0xb0, 0x0F, 0x6D, 0x02, 0x00, 0xFF]
# Photo_Part16/20
CMD_PHOTO16 = [0x80, 0xb0, 0x10, 0x6C, 0x02, 0x00, 0xFF]
# Photo_Part17/20
CMD_PHOTO17 = [0x80, 0xb0, 0x11, 0x6B, 0x02, 0x00, 0xFF]
# Photo_Part18/20
CMD_PHOTO18 = [0x80, 0xb0, 0x12, 0x6A, 0x02, 0x00, 0xFF]
# Photo_Part19/20
CMD_PHOTO19 = [0x80, 0xb0, 0x13, 0x69, 0x02, 0x00, 0xFF]
# Photo_Part20/20
CMD_PHOTO20 = [0x80, 0xb0, 0x14, 0x68, 0x02, 0x00, 0xFF]
# Get all the available readers
readerList = readers()
print ('Available readers:')
for readerIndex,readerItem in enumerate(readerList):
 print(readerIndex, readerItem)
# Select reader
readerSelectIndex = 0 #int(input("Select reader[0]: ") or "0")
reader = readerList[readerSelectIndex]
print ("Using:", reader)
connection = reader.createConnection()
connection.connect()
atr = connection.getATR()
print ("ATR: " + toHexString(atr))
if (atr[0] == 0x3B & atr[1] == 0x67):
 req = [0x00, 0xc0, 0x00, 0x01]
else :
 req = [0x00, 0xc0, 0x00, 0x00]
# Check card
data, sw1, sw2 = connection.transmit(SELECT + THAI_CARD)
print ("Select Applet: %02X %02X" % (sw1, sw2))
# CID
data = getData(CMD_CID, req)
cid = thai2unicode(data[0])
print ("CID: " + cid)
# TH Fullname
data = getData(CMD_THFULLNAME, req)
print ("TH Fullname: " +  thai2unicode(data[0]))
#print(thai2unicode2(data[0])))
# EN Fullname
data = getData(CMD_ENFULLNAME, req)
print ("EN Fullname: " + thai2unicode(data[0]))
# Date of birth
data = getData(CMD_BIRTH, req)
print( "Date of birth: " + thai2unicode(data[0]))
# Gender
data = getData(CMD_GENDER, req)
print ("Gender: " + thai2unicode(data[0]))
# Card Issuer
data = getData(CMD_ISSUER, req)
print ("Card Issuer: " + thai2unicode(data[0]))
# Issue Date
data = getData(CMD_ISSUE, req)
print ("Issue Date: " + thai2unicode(data[0]))
# Expire Date
data = getData(CMD_EXPIRE, req)
print ("Expire Date: " + thai2unicode(data[0]))
# Address
data = getData(CMD_ADDRESS, req)
print ("Address: " + thai2unicode(data[0]))
'''
# PHOTO
photo = getData(CMD_PHOTO1, req[0])
photo += getData(CMD_PHOTO2, req[0])
photo += getData(CMD_PHOTO3, req[0])
photo += getData(CMD_PHOTO4, req[0])
photo += getData(CMD_PHOTO5, req[0])
photo += getData(CMD_PHOTO6, req[0])
photo += getData(CMD_PHOTO7, req[0])
photo += getData(CMD_PHOTO8, req[0])
photo += getData(CMD_PHOTO9, req[0])
photo += getData(CMD_PHOTO10, req[0])
photo += getData(CMD_PHOTO11, req[0])
photo += getData(CMD_PHOTO12, req[0])
photo += getData(CMD_PHOTO13, req[0])
photo += getData(CMD_PHOTO14, req[0])
photo += getData(CMD_PHOTO15, req[0])
photo += getData(CMD_PHOTO16, req[0])
photo += getData(CMD_PHOTO17, req[0])
photo += getData(CMD_PHOTO18, req[0])
photo += getData(CMD_PHOTO19, req[0])
photo += getData(CMD_PHOTO20, req[0])
data = HexListToBinString(photo)
f = open(cid + ".jpg", "wb")
f.write (data)
f.close
'''
# Exit program
sys.exit()

15
sudo apt install swig
sudo apt-get install python3-dev pcscd
sudo apt install libpcsclite-dev  python-pil
pip3 install pyscard image

sudo systemctl enable pcscd.service
sudo systemctl start pcscd.service
sudo systemctl status pcscd.service

หน้า: [1] 2 3 ... 21