2021年7月23日 星期五

Python 3.8 time.time() Precision on AMD Ryzen 7 3700X 8 cores 16 threads CPU on Ubuntu 20.04.2 LTS

https://stackoverflow.com/questions/1938048/high-precision-clock-in-python


 Python 3.8 time.time() Precision on AMD Ryzen 7 3700X 8 cores 16 threads CPU on Ubuntu 20.04.2 LTS


Test 1 time.time()

import time

lis = [time.time() for _ in range(1000)]

for index, x  in enumerate(lis):

print(str(index).zfill(3), str('%.15f'%x)) # milli micro nano pico femto


From below result, within the same micro second, the nano second differs by 200-300ns.

A rough description is that Python's time.time() can make timestamps in 200-300ns.


000 1627032470.455012798309326

001 1627032470.455013036727905

002 1627032470.455013036727905

003 1627032470.455013036727905

004 1627032470.455013275146484

005 1627032470.455013275146484

006 1627032470.455013275146484

007 1627032470.455013513565063

008 1627032470.455013513565063


Test 2 time.time_ns()

import time

lis = [time.time_ns() for _ in range(1000)]

for index, x  in enumerate(lis):

print(str(index).zfill(3), x) # milli micro nano not pico femto


Stackoverflows says:

"For Linux and Mac precision is +- 1 microsecond or 0.001 milliseconds"

"Windows uses +- 16 milliseconds precision due to clock implementation problems due to process interrupts"

My test says that it is 100ns not 1us. 10 times higher precision.


second milli micro nano

000 1627032860 145 901 780

001 1627032860 145 902 021

002 1627032860 145 902 131

003 1627032860 145 902 231

004 1627032860 145 902 311

005 1627032860 145 902 431

006 1627032860 145 902 522

007 1627032860 145 902 592

008 1627032860 145 902 682

009 1627032860 145 902 792

010 1627032860 145 902 882

011 1627032860 145 902 962

012 1627032860 145 903 042


So, precision on Ubuntu is 100ns, meaning for every 2 consecutive execution the interval is 100ns.

2021年7月15日 星期四

2021 Logitech M590 Slient Mouse Button Mapping on Ubuntu 20

 https://askubuntu.com/questions/152297/how-to-configure-extra-buttons-in-logitech-mouse


Install

sudo apt-get install xbindkeys xautomation x11-utils

Identify
$ xev -event mouse | grep Button --before-context=1 --after-context=2 ButtonPress event, serial 25, synthetic NO, window 0x6800001, root 0x1d7, subw 0x6800002, time 232287448, (36,34), root:(112,161), state 0x10, button 1, same_screen YES -- ButtonRelease event, serial 25, synthetic NO, window 0x6800001, root 0x1d7, subw 0x6800002, time 232287512, (36,34), root:(112,161), state 0x110, button 1, same_screen YES -- ButtonPress event, serial 25, synthetic NO, window 0x6800001, root 0x1d7, subw 0x6800002, time 232316577, (49,29), root:(213,376), state 0x10, button 8, same_screen YES -- ButtonRelease event, serial 25, synthetic NO, window 0x6800001, root 0x1d7, subw 0x6800002, time 232316671, (50,29), root:(214,376), state 0x10, button 8, same_screen YES 

Bind
xbindkeys --defaults > $HOME/.xbindkeysrc
gedit $HOME/.xbindkeysrc

Content
"xte 'keydown Control_L' 'keydown Tab' 'keyup Tab' 'keyup Control_L'"
b:1 + Release



2021年7月14日 星期三

2021 Installing VirtualBox 6.1.22 for Linux on Ubuntu 19.10 / 20.04 / 20.10 / 21.04

Check

$ uname -a
Linux ricky-ryzen 5.8.0-43-generic #49~20.04.1-Ubuntu SMP Fri Feb 5 09:57:56 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

$ lsb_release -a
Description: Ubuntu 20.04.2 LTS


Download

https://download.virtualbox.org/virtualbox/6.1.22/virtualbox-6.1_6.1.22-144080~Ubuntu~eoan_amd64.deb

Install

sudo dpkg -i the.deb


Preinstall

sudo apt-get install libsdl1.2debian

sudo apt --fix-broken install

Python __init__.py Failed to experiment

Consider mydir/spam/module.py


import os
def rprint():
    print(os.path.dirname(os.path.abspath(__file__)))
    print(__file__)
if __name__=='__main__':
    rprint()


$ python3 module.py
/home/ricky/d/lab/w3c/24.Python/01.init.py/mydir/spam
module.py



A file mydir/caller1.ok.py will be ok

import spam.module
spam.module.rprint()


A file mydir/caller2.ok.py will be ok

from spam import module
module.rprint()


But a file mydir/caller3.error.py gives an error

import spam
spam.rprint()

$ python3 caller3.fail.py 
Traceback (most recent call last):
  File "caller3.fail.py", line 2, in <module>
    spam.rprint()
AttributeError: module 'spam' has no attribute 'rprint'


Failed to experiment __init__.py


End


2021年7月13日 星期二

My usual Git Projects

2021-07-13


CaltexPower

flaskw3html

GrandTalent

K11Auto

MetaTraderApiMT4

MetaTraderApiMT5

MyNodeExpress

OnlineCode

pytelegram

RickyBank

ZeroMQCppPy




2021年7月12日 星期一

Wireshark on Ubuntu 20

 https://linuxhint.com/install_wireshark_ubuntu/


$ sudo apt update

$ sudo apt install wireshark

$ sudo usermod -aG wireshark $(whoami)


$ wireshark

$ sudo wireshark

NodeJS on Ubuntu 20

 https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-20-04


sudo apt update

sudo apt install nodejs

nodejs -v # 10.19.0


sudo apt install npm


Yeah!

GitExtension on Ubuntu 20

 GitExtension on Ubuntu 20


https://github.com/gitextensions/gitextensions/wiki/How-To:-run-Git-Extensions-on-Linux


sudo apt install git

git --version # 2.25.1

sudo apt install kdiff3

kdiff3 --version # 1.8.1


Mono

sudo apt install gnupg ca-certificates
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb https://download.mono-project.com/repo/ubuntu stable-focal main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list
sudo apt update
sudo apt install mono-devel
sudo apt install mono-complete
mono --version # 6.12.0.122

SSH
apt-get install ssh-client
sudo apt install ksshaskpass

Yeah! Done!

Main Ubuntu 20.04.2 Installation PyCharm Vim apt install Python Netbeans Eclipse

General

sudo apt install hardinfo
lsb_release -a # linux standard base returns 20.04
lspci | grep Realtek
uname -a # 5.8.0 or 5.13
sudo hostname ricky-pc


tool
sudo apt-get install ncdu
# use up down left right q c


ufw
sudo ufw status
# Status: inactive
sudo ufw enable
sudo ufw status
# Status: active
ufw status numbered
ufw delete 1

sudoer
sudo nano /etc/sudoers # or sudo visudo
# add line to bottom, must be after $sudo line
leungric ALL=(ALL:ALL) NOPASSWD:ALL
sudo ls -al /root
# no prompt

ssh
sudo apt install ssh
sudo systemctl enable --now ssh
sudo systemctl status ssh
sudo ufw allow ssh/tcp


rdp (not quite working)

sudo apt-get install -y xrdp
sudo systemctl enable xrdp


vnc (ugly but working)
# https://tecadmin.net/install-vnc-server-on-ubuntu-20-04/
sudo apt install tigervnc-standalone-server -y
vncpasswd
# enter 8 char pw
vncserver -localhost no
# New '1037u:1 (leungric)' desktop at :1 on machine 1037u
# Starting applications specified in /home/leungric/.vnc/xstartup
# Log file is /home/leungric/.vnc/1037u:1.log
# Use xtigervncviewer -SecurityTypes VncAuth,TLSVnc -passwd /home/leungric/.vnc/passwd 1037u:1 to connect to the VNC server.
vncserver -list
# X DISPLAY #RFB PORT #PROCESS ID
# :1 5901 2141
sudo ufw allow 5901/tcp
sudo ufw status
# 5901/tcp ALLOW anywhere
# Windows TightVNC Viewer 192.168.1.103:1
# guacamole 192.168.1.103 5901 can work

vnc "authentucation is required to create a color profile" (working in 2022)
# https://devanswers.co/how-to-fix-authentication-is-required-to-create-a-color-profile-managed-device-on-ubuntu-20-04-20-10/
vnc, CTRL ALT T, nautilus
sudo nano /etc/polkit-1/localauthority.conf.d/02-allow-colord.conf

polkit.addRule(function(action, subject) {
 if ((action.id == "org.freedesktop.color-manager.create-device" ||
 action.id == "org.freedesktop.color-manager.create-profile" ||
 action.id == "org.freedesktop.color-manager.delete-device" ||
 action.id == "org.freedesktop.color-manager.delete-profile" ||
 action.id == "org.freedesktop.color-manager.modify-device" ||
 action.id == "org.freedesktop.color-manager.modify-profile") &&
 subject.isInGroup("{users}")) {
 return polkit.Result.YES;
 }
});

sudo reboot
vncserver -kill :2
vncserver -localhost no
vnc-server -list
# Windows 10 TightVNC Viewer 192.168.1.103:3


# a working xfce4 xstartup

cat xstartup.working.xfce 

#!/bin/sh
xrdb $HOME/.Xresources
xsetroot -solid grey
#x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#x-window-manager &
# Fix to make GNOME work
export XKL_XMODMAP_DISABLE=1
/etc/X11/Xsession
startxfce4 &


vnc service (seems better)
# https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-vnc-on-ubuntu-20-04



Python
sudo apt install python3-distutils
sudo apt install python3-apt
sudo apt install python3-pip
sudo apt install python-is-python3


Office

sudo apt install thunderbird
sudo apt install openvpn unzip network-manager-openvpn
sudo apt install vim


Chrome

wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb

sudo apt install ./google-chrome-stable_current_amd64.deb


Signal

wget -O- https://updates.signal.org/desktop/apt/keys.asc | gpg --dearmor > signal-desktop-keyring.gpg
cat signal-desktop-keyring.gpg | sudo tee -a /usr/share/keyrings/signal-desktop-keyring.gpg > /dev/null
echo 'deb [arch=amd64 signed-by=/usr/share/keyrings/signal-desktop-keyring.gpg] https://updates.signal.org/desktop/apt xenial main' |\
  sudo tee -a /etc/apt/sources.list.d/signal-xenial.list
sudo apt update && sudo apt install signal-desktop


C++
sudo apt install make
sudo apt install gcc
sudo snap install netbeans --classic

Java Eclipse
sudo apt update
sudo apt install default-jre
sudo snap install --classic eclipse

Wireshark
sudo apt install wireshark


Editors
sudo apt install ghex
# sublime, vscode, notepad++(ugly)

Compiling Realtek RTL8125 Network Card Driver on Ubuntu 20.04.2 LTS

 https://askubuntu.com/questions/1259947/cant-get-rtl8125b-working-on-20-04

 

lspci -knn | grep Realtek
06:00.0 Ethernet controller [0200]: Realtek Semiconductor Co., Ltd. RTL8125 2.5GbE Controller [10ec:8125] (rev 04)
 

$ lsb_release -a
No LSB modules are available.
Distributor ID:    Ubuntu
Description:    Ubuntu 20.04.2 LTS
Release:    20.04
Codename:    focal
 

 Here's a solution I found;
    Go to the Realtek website 992
    Download the Unix(Linux) r8125 driver. You will need to give an email address.
    1754×445
    Go to /Downloads directory. Extract the Tarball.
    In Terminal, go into r8125-xxxx folder and run the autorun.sh
    $ sudo ./autorun.sh
Everything should run automatically and you should get ethernet connection now.

 

TUF GAMING B550M-PLUS 

AMD B550
Realtek RTL8125B 2.5Gb Ethernet

 

 

 

 $ sudo ./autorun.sh

Check old driver and unload it.
rmmod r8125
Build the module and install
At main.c:160:
- SSL error:02001002:system library:fopen:No such file or directory: ../crypto/bio/bss_file.c:69
- SSL error:2006D080:BIO routines:BIO_new_file:no such file: ../crypto/bio/bss_file.c:76
sign-file: certs/signing_key.pem: No such file or directory
Warning: modules_install: missing 'System.map' file. Skipping depmod.
DEPMOD 5.8.0-43-generic
load module r8125
Updating initramfs. Please wait.
update-initramfs: Generating /boot/initrd.img-5.8.0-43-generic
Completed.


ip link

sudo ip link set enp6s0 up

2021年7月8日 星期四

2021 Stack Overflow Tech List






-------------------------------------------------------------------------------------------





















-------------------------------------------------------------------------------------------












2023 Promox on Morefine N6000 16GB 512GB

2023 Promox on Morefine N6000 16GB 512GB Software Etcher 100MB (not but can be rufus-4.3.exe 1.4MB) Proxmox VE 7.4 ISO Installer (1st ISO re...