วันอาทิตย์ที่ 29 มีนาคม พ.ศ. 2569

Hyper V Window Server 2016

 Hyper V Window Server ไม่มี license เป็น Free เป็น No GUI Server เหมาะกับ Web server

1. ลง mongodb

2.Nodejs

3. python 3.11

4. totalcmd 

5. FileManager

6. Chrome

7. Sqlserver

user จะเป็นคนเดืยวกับ ใน Vm 

ทำแล้ว ต่อ CloudFlare web ออกได้เลย


CloudFlared setup web

Change DNS to cloudflare

login cloudflare.com

1. ไป domain

2. On Board Domain

3. exist domain และ auto import

  Free plan

4. ได้ name server 2ตัว ไป update ที่ parent nameserver เช่น whois.com

5. รอเวลา

จะได้ domain ที่ add prefix ได้

สร้าง app node ทดสอบ helloworld ที่ port 3000

const http = require('node:http');

const hostname = '127.0.0.1';
const port = 3000;

const server = http.createServer((req, res) => {
  res.statusCode = 200;
  res.setHeader('Content-Type', 'text/plain');
  res.end('Hello World');
});

server.listen(port, hostname, () => {
  console.log(`Server running at http://${hostname}:${port}/`);
});


 PC to Cloudflare

1. login https://dash.cloudflare.com/

2. create Turnel

3. download https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-windows-amd64.msi

และ install โปรแกรมจะอยู่ใน c:\program file(x86)\cloudflare

4. run register 

     cloudflared.exe service install <key from web>

5. see in cloudflared tunnel status ว่า ok.ใหม

ต่อกับ web

ไปที่ home ของ Cloudflare

1. tunnel เลือก config

2    public application route -> ชื่อของ prefix+host และ localhost:port (ex:3000)

จะ Add กี่ตัวก้ให้แยกตาม port 

ลอง browser ตามชื่อ web จะแสดง Hello World 



วันอังคารที่ 2 กันยายน พ.ศ. 2568

ให้ Visual studio compile C#มี Version

 

ใน AssemblyInfo.cs

[assembly: AssemblyVersion("1.0.*")]


ให้ แก้ใน Post Build

powershell -Command "(Get-Item '$(TargetPath)').VersionInfo.FileVersion" > "$(TargetDir)version.txt"

วันจันทร์ที่ 19 พฤษภาคม พ.ศ. 2568

Mongodb ลง สำรอง และ ล้างตัวเก่า

 สามารถ ลง Mongodb ได้หลายตัว ในเครื่องเดียวกัน วิธีให้หา Version ติดๆกัน เช่น 6 กับ 7 

ปรกติ Installer จะ set default ให้ตัวล่าสุด

ให้ปิด Service ตัวเก่า แล้ว ไป command cmd  >mongod --config <config>.cfg ใน Program files..\mongodb..\server..\<version>


วิธีล้าง ใช้ mongo shell 

db.adminCommand("listDatabases").databases.
   map(d => d.name).
   filter(n => ["admin", "config", "local"].indexOf(n) == -1 ).
   map(n => db.getSiblingDB(n).dropDatabase())

python
from pymongo import MongoClient

# Connect to MongoDB
client = MongoClient('mongodb://localhost:27017/')

# Get the list of all database names, excluding 'admin', 'config', 'local'
db_names = client.list_database_names()
db_names = [name for name in db_names if name not in ('admin', 'config', 'local')]

# Drop each of the filtered databases
for db_name in db_names:
    client.drop_database(db_name)
    print(f"Dropped database: {db_name}")


ต้องการ restore ก็ทำได้