แสดงกระทู้

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.


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

หน้า: [1] 2 3 ... 11
1
WSL และ VMWARE ไม่สามารถทำงานร่วมกันได้

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

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

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

restart เครื่อง


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

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

restart เครื่อง


2
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

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

อ้างถึง
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

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

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

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

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

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

ssh  localhost -p 8022

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

6
เกี่ยวกับเซิร์ฟเวอร์ [ 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

เป็นต้น

7

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

อ้างถึง

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

8
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

9
พัฒนาเว็บไซต์ Webbased Developer / yii2 : json reply
« เมื่อ: 29 กรกฎาคม 2021, 10:47:19 PM »
ใช้ Gii สร้าง Models ก่อน

ไฟล์ :: Controller

อ้างถึง
use app\models\Billist;   // เรียก Model ที่สร้างเอามาใช้ค้นข้อมูล

public function actionIndex($id=0)
{
     \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
     if ($id==0) // ไม่ระบุ id
     {
        $billist = Billist::find()->all();
        if (count($billist)>0)  return $billist;
        else return array('data'=>'None');
     }
     else // ถ้าระบุ id มา ให้ไปหามาตอบ
     {
        $billist=Billist::find($id)->one(); 
        return $billist;
     }
}

10
เราทำเว็บสักตัวนึง อยากรู้ว่าโดน Request ได้มากแค่ไหน
สามารถใช้ autocannon ทดสอบได้ครับ

อ้างถึง
https://github.com/mcollina/autocannon



autocannon -c100 -d5 p 10 http://localhost:3000


11
พัฒนาเว็บไซต์ Webbased Developer / Yii2 + Vuetify
« เมื่อ: 14 กรกฎาคม 2021, 03:39:49 PM »
Yii2 basic + Vuetify

[config/web.php]

อ้างถึง
'components' => [

        'assetManager' => [
            'bundles' => [
               'yii\web\JqueryAsset' => false,
               'yii\bootstrap\BootstrapPluginAsset' => false,
               'yii\bootstrap\BootstrapAsset' => false,
            ],
        ],


[views/layouts/main.php]

อ้างถึง
<?php

/* @var $this \yii\web\View */
/* @var $content string */

use app\widgets\Alert;
use yii\helpers\Html;
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use yii\widgets\Breadcrumbs;
use app\assets\AppAsset;

AppAsset::register($this);
?>
<?php $this->beginPage() ?>

<!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>">
<head>
  <link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900" rel="stylesheet">
  <link href="https://cdn.jsdelivr.net/npm/@mdi/[email protected]/css/materialdesignicons.min.css" rel="stylesheet">
  <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/vuetify.min.css" rel="stylesheet">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui">
  <meta charset="<?= Yii::$app->charset ?>">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <?php $this->registerCsrfMetaTags() ?>
  <title><?= Html::encode($this->title) ?></title>
  <?php $this->head() ?>
</head>
<body>

<?php $this->beginBody() ?>
        <?= $content ?>
<?php $this->endBody() ?>

  <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vuetify.js"></script>
</body>
</html>

<?php $this->endPage() ?>

12
Nginx

log access to drop file in /etc/nginx/ but don't log 404

location = /robots.txt {
        access_log drop;
        log_not_found off;
}

log access to drop file in /etc/nginx/ but don't log 404
location = /favicon.ico {
        access_log drop;
        log_not_found off;
}

เหมาะกับ Laravel
log access to denied file in /etc/nginx/ but don't log 404 and also deny all to dot files
location ~ /\. {
        access_log denied;
        log_not_found off;
        deny all;
}

log access to drop file in /etc/nginx/ but don't log 404 and also deny all to files starting with a dollar sign ($temp.config.php)
location ~ ~$ {
        access_log denied;
        log_not_found off;
        deny all;
}

Apache

เหมาะกับ Laravel
<FilesMatch "^\.">
    Order allow,deny
    Deny from all
</FilesMatch>

13
อ้างถึง
https://aria2.github.io/

อ้างถึง
sudo apt-get update
sudo apt-get install aria2

example, to make 8 connections:

อ้างถึง
aria2c -x 8 http://www.example.com/example.file

15
อยากทำระบบต้นแบบง่ายๆ โดยดึงข้อมูลจาก Google Sheet เรามีวิธี

1) คีย์ข้อมูลตัวอย่างลงใน Google sheet
2) เลือกเมนู ไฟล์ -> เผยแพร่ไปยังเว็บ => เผยแพร่
3) กดแชร์โดยคัดลอก Link มา
4) แกะ id ของ Sheet ซึ่งจะเป็นอักษรชุดยาวๆ ถูกคั่นด้วยเครื่องหมาย /
5) เอา id ไปแทนที่ใน url ตัวอย่าง

อ้างถึง
https://spreadsheets.google.com/feeds/list/spreadsheetID/worksheetID/public/values?alt=json
spreadsheetID = ค่า id จากข้อ 4
worksheetID = Tab worksheet ที่ 1,2,3 เอาง่ายๆ ก็ลองใส่ 1 ก่อน

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