10/11/2021

Code Auto Remove Slack เปลี่ยน API ใหม่ Code เดิมลบไม่ได้

Python Auto Remove Slack Chet History.

 เปลี่ยน API

  1. response = sc.api_call('conversations.history', channel=channel, limit=1000, oldest=oldest_ts, latest=latest_ts)


Code สำเร็จ
  1.  
  2.  
  3. from slackclient import SlackClient
  4. #from time import sleep
  5. import time
  6. #import datetime
  7. from datetime import datetime, timedelta
  8.  
  9. legacy_token = 'XXXX'  # don't if you share your code
  10. ########## Chanel Camera ##############
  11. channel = 'XXXX'  # Camera Channel.
  12.  
  13. sc = SlackClient(legacy_token)
  14. response = sc.api_call('channels.info', channel=channel)
  15.  
  16. #oldest_ts = response['channel']['created']
  17. date_days_ago = datetime.now() - timedelta(days=90)
  18. oldest_ts = time.mktime(date_days_ago.timetuple())
  19. print(datetime.fromtimestamp(oldest_ts))
  20.  
  21. #date_days_ago = datetime.now() - timedelta(days=60) # Keep File On Slack 60 Day.
  22. date_days_ago = datetime.now() - timedelta(days=7) # Keep File On Slack 7 Day.
  23. latest_ts = time.mktime(date_days_ago.timetuple())
  24. print(datetime.fromtimestamp(latest_ts))
  25.  
  26. #response = sc.api_call('channels.history', channel=channel, count=1000, oldest=oldest_ts, latest=latest_ts)
  27. response = sc.api_call('conversations.history', channel=channel, limit=1000, oldest=oldest_ts, latest=latest_ts)
  28. allmsgs = [item['ts'] for item in response['messages']]
  29. print(len(allmsgs))
  30. for msg in allmsgs:
  31.     sc.api_call('chat.delete', channel=channel, ts=msg)
  32.     time.sleep(1)
  33.  
  34. ########### Chanel Server  ###################
  35. channel = 'XXXXX' # Server Channel.
  36.  
  37. sc = SlackClient(legacy_token)
  38. response = sc.api_call('channels.info', channel=channel)
  39.  
  40. #oldest_ts = response['channel']['created']
  41. date_days_ago = datetime.now() - timedelta(days=90)
  42. oldest_ts = time.mktime(date_days_ago.timetuple())
  43. print(datetime.fromtimestamp(oldest_ts))
  44.  
  45. date_days_ago = datetime.now() - timedelta(days=60)
  46. latest_ts = time.mktime(date_days_ago.timetuple())
  47. print(datetime.fromtimestamp(latest_ts))
  48. #response = sc.api_call('channels.history', channel=channel, count=1000, oldest=oldest_ts, latest=latest_ts)
  49. response = sc.api_call('conversations.history', channel=channel, limit=1000, oldest=oldest_ts, latest=latest_ts)
  50. allmsgs = [item['ts'] for item in response['messages']]
  51. print(len(allmsgs))
  52. for msg in allmsgs:
  53.     sc.api_call('chat.delete', channel=channel, ts=msg)
  54.     time.sleep(1)

9/22/2021

VMware : VMware ESXi 6.5 Disk ช้าเปลี่ยน HDD เป็น SSD ก็ยังช้าอยู่

 VMware : VMware ESXi 6.5 Disk ช้าเปลี่ยน HDD เป็น SSD ก็ยังช้าอยู่
เครื่อง DL160 Gen8 การ์ด Raid b120i controller
ไม่รองรับ Vmware Version 6 ลง Vmware 6 แล้วไม่พบการ์ Raid แต่ลงตัว customize ของ HP ได้
https://porpramarn.blogspot.com/2021/04/server-vmware-vm70.html

ปัญหาที่พบคือการทำงานของ Harddisk ช้า copy ข้อมูลช้า ความเร็วได้ประมาณ 2 - 5 M/s เปลี่ยนเป็น SSD ก็ยังช้าอยู่

ทดลอง ติดตั้ง 5.5 ใช้งานได้ความเร็วตามปกติ
แต่ติดตั้ง 6.5 U3 ก็ช้าเหมือนเดิม

จากการหาข้อมูลและทดลองแก้ พบมีปัญหา ที่ Driver การ์ด Raid b120i controller ถ้าใช้ ต้องถอดตัวที่อยู่ใน Version 6.5 ออกแล้วติดตั้งตัว 5.5 แทน
Stop all virtual machines before you continue.
Step-by-step solution
1.Open an SSH session to your ESXi server installation and log on as root. Same password as for the web interface / console.
2.Go into "Maintenance mode". Note that all virtual machines must be stopped first.

esxcli system maintenanceMode set --enable true

3.Allow outgoing HTTP requests through the ESXi firewall, to retrieve the necessary file.
esxcli network firewall ruleset set -e true -r httpClient

4.Go into /tmp folder so we don't leave a mess.
cd /tmp

5.Use wget to download the .zip file from HP website. Note that I'm using http:// and not https://.
You can also use a program such as WinSCP to copy the file directly from your desktop PC to the ESXi server.
wget http://downloads.hpe.com/pub/softlib2/software1/pubsw-linux/p1749737361/v98767/hpvsa-5.5.0-88.zip

6. Unzip the file so we can get the .vib driver file we'll need.
unzip hpvsa-5.5.0-88.zip

7.Copy the file to a location where the installer can find it easily.
cp scsi-hpvsa-5.5.0-88OEM.550.0.0.1331820.x86_64.vib /var/log/vmware/

8.Uninstall the currently installed scsi-hpvsa driver. Be patient. Takes a minute.
esxcli software vib remove -n scsi-hpvsa -f

9.Install the old driver we just downloaded. Be patient. Takes a minute.
esxcli software vib install -v file:scsi-hpvsa-5.5.0-88OEM.550.0.0.1331820.x86_64.vib --force --no-sig-check --maintenance-mode

10.Now reboot your server.
reboot

11.Remember to disable "Maintenance mode". You can do this in vSphere Client or in the web interface.

ผลปรากฏว่า การทำงานของ Disk เร็วขึ้น Copy ข้อมูล และ Restore Database Axapta ได้เร็วขึ้นมาก
Speed Disk I/O rate ที่ กราฟ Performance เดิมไม่เกิน 5 M/s เป็น 200 - 500 M/s

VMware : VMware ESXi เปลี่ยน Compatibility เป็น Version ใหม่

 VMware : VMware ESXi เปลี่ยน Compatibility เป็น Version ใหม่
เช่น Compatibility ESXi 5.0 virtual machine ไปเป็น Compatibility ESXi 6.5 virtual machine ให้ตรงกับที่ Server Vmware run อยู่


เป็น

1. ปิดเครื่องที่จะทำ
2. คลิกขวาที่เครื่อง VMware เลือก Upgrade VM Compatibility

3. เลือก Version Compatibility ที่ต้องการ แล้วกด Upgrade
4. กด Yes

แล้ว Compatibility ก็จะเป็น Version เราเลือก

https://kb.vmware.com/s/article/1010675

9/20/2021

Axapta : Sort Container หลายค่า เช่น ใน Container มี PO, Item, Qty ต้องการเรียงทั้ง 3 ตัว

 Axapta : Sort Container หลายค่า เช่น ใน Container มี PO, Item, Qty ต้องการเรียงทั้ง 3 ตัว 

อันดับแรกเอาค่ามาต่อกัน ตามที่เราจะเรียง เช่นต้องการเรียง PO, Item 

แล้วค่อยนำค่าที่ไปแบ่ง | ใช้งาน

  1. static void SortContainer(Args _args)
  2. {
  3. container con = ["PO21-12914|901930810009|1|C-KCH","PO21-12914|901930810001|3|C-KCH","PO21-11930|014019310003|3|C-KCH","PO21-11930|014019310003|3|C-KCH","PO21-12914|014019310001|4|C-KCH","PO21-11930|014019310002|3|C-KCH"];
  4.     str temp1;
  5.     str temp2;
  6.     int i;
  7.     int j;
  8.     container sorCon;
  9.     ;
  10.     sorCon = con;
  11.     // Sort the container
  12.     for (i = 1; i <= conlen(sorCon) ; i++)
  13.     {
  14.         for (j = i + 1; j <= conlen(sorCon); j++)
  15.         {
  16.             temp1 = conpeek(sorCon, j);
  17.             temp2 = conpeek(sorCon, i);
  18.             if (temp1 < temp2)
  19.             {
  20.                 sorCon = condel(sorCon, j, 1);
  21.                 sorCon = conins(sorCon, j, temp2);
  22.                 sorCon = condel(sorCon, i, 1);
  23.                 sorCon = conins(sorCon, i, temp1);
  24.             }
  25.         }
  26.     }
  27.     conview(sorCon);
  28. }

https://rahulmsdax.blogspot.com/2018/10/sort-order-by-asc-container-in-ax-x.html

8/02/2021

Linux Mint : Config VPN On Linux Mint

Linux Mint : Config VPN On Linux Mint
https://support.hidemyass.com/hc/en-us/articles/202721596-OpenVPN-Setup-with-Network-manager-on-Linux-Mint-Mate

1. Load config VPN ที่เป็น Viscosity Inline Config

2. Install
Type:
  1. sudo apt-get install network-manager-openvpn network-manager-openvpn-gnome
and press Enter
Type:
y
and press Enter

3. Click on "Network Connections" and new window will appear. Then click on "Add" and then select "Import a saved VPN configuration" and click on "Create", as shown below:
4. New window will appear, here you need to go to that HMA VPN folder and to select the OpenVPN® configuration file for the location you wish to connect to and then click on "Open".
5. In this window, enter your HMA Username and Password into the appropriate fields in the "VPN" tab and make sure that "All users may connect to this network" is checked on the "General" tab and lastly press "Save"
6. Navigate to your Network Manager (located in the top right corner of your desktop). Click on VPN Connections and then click on the button next to the VPN server you configured previously. (In this example, it's USA.Kentucky.Louisville.UDP)
You will see a notification that you have established a successful VPN connection!