به نام خداوند مهربان

 

The nvidia-smi tool can access the GPU and query information. For example:

 

> nvidia-smi
Fri Nov 11 02:08:18 2022
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 520.61.05    Driver Version: 520.61.05    CUDA Version: 11.8     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  NVIDIA GeForce ...  On   | 00000000:01:00.0 Off |                  N/A |
| 50%   61C    P2   301W / 350W |  23683MiB / 24576MiB |     69%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|    0   N/A  N/A   2747694      C   python                          23680MiB |
+-----------------------------------------------------------------------------+

 

 

  • حسن دلدار

Re-download with wget's -c (--continue):

wget -c https://ftp.fastsite.edu/images/bigimage.iso
  • حسن دلدار

Open a terminal and run sudo umount /tmp or, if that fails, sudo umount -l /tmp

and then:

sudo mount -t tmpfs -o size=7G,mode=1777 overflow /tmp

sudo mount -t tmpfs -o size=7G,mode=1777 overflow /dev/tmp

or

mount -o remount,size=5G /tmp/

 

print size of /tmp:

df -h /tmp

 

 

  • حسن دلدار

Connect your phone to PC via USB and then open a CMD (asume adb is installed):

List devices:

adb devices

 

To list all packages:
adb shell  pm list packages

 

For remove a package:

adb shell pm uninstall -k --user 0 com.android.chrome

or

adb uninstall --user 0 com.android.chrome
 

To open an ADB shell:

adb shell 

 

List all of the currently installed packages:

pm list packages

 

Uninstall the app(s):

pm uninstall -k --user 0 package name

ex:

pm uninstall -k --user 0 com.google.android.youtube

 

Change directory:

cd /storage/self/primary/Download

 

Install an apk:
pm install -r --user 0 com.android.chrome.apk

 

  • حسن دلدار

واسط ارتباطی بین برنامه ها و سیستم عامل در Android  را ABI گویند که دو مورد از مهمترین ABI ها : arm64-v8a و armeabi-v7a می باشد.

گوشی Xiaomi Redmi 4 (4X)  از نوع arm64-v8a می باشد. 
Supported ABIs table 1 from https://developer.android.com/ndk/guides/abis

  • حسن دلدار

برای نمایش درست فارسی در خروجی ها بهتر است فایل launch.json  را بشکل زیر تغییر داد:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            //"console": "integratedTerminal",
            "console": "internalConsole",
            "justMyCode": false,
        }
    ]
}

 

 
  • حسن دلدار

 

please update your PCI ID database with:

sudo update-pciids

And use the following command in your terminal:

lspci -nn | grep '\[03'
  • حسن دلدار

 

From the comment:

sudo update-alternatives --config python

Will show you an error:

update-alternatives: error: no alternatives for python3 

You need to update your update-alternatives , then you will be able to set your default python version.

sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.4 1
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 2

Then run :

sudo update-alternatives --config python

Set python3.6 as default.

Or use the following command to set python3.6 as default:

sudo update-alternatives  --set python /usr/bin/python3.6
  • حسن دلدار

ضریب همبستگی پیرسون یا Pearson correlation coefficient  :
ضریب همبستگی ابزاری آماری برای تعیین نوع و درجهٔ رابطهٔ یک متغیر کمی با متغیر کمی دیگر است. ضریب همبستگی، یکی از معیارهای مورد استفاده در تعیین همبستگی دو متغیر است. ضریب همبستگی شدت رابطه و همچنین نوع رابطه (مستقیم یا معکوس) را نشان می‌دهد. این ضریب بین ۱ تا ۱- است و در صورت عدم وجود رابطه بین دو متغیر، برابر صفر است.

  • حسن دلدار

Run python script in background

Introduction

If you want to run a python script in the background you can use an ampersand(&). But at first, we need to prepare our script for this.

For example, we have a python file my_script.py. At first, we need to add execution permission for this file using the next command:

chmod +x my_script.py

Then I recommend adding a shebang line to the top of this file. This allowed you don't indicate in the terminal that it is a python script.

#!/usr/bin/env python3

Now we need some logic that will show us that the script is running in the background. For example, a simple script that will have been printing time during the next ten seconds.

Script content:

 #!/usr/bin/env python3

from datetime import datetime

start_time = datetime.now()
print(f"Start time: {datetime.now().strftime('%H:%M:%S')}")

interval = 10

while interval != 0:
    if (datetime.now() - start_time).seconds == 1:
        start_time = datetime.now()
        print(f"Current time: {datetime.now().strftime('%H:%M:%S')}")
        interval -= 1

Using only ampersand (&)

For running the script use the next command:

your/path/my_script.py > output.log &

We save the script's output to the log file, so after running this command we will get output like this in the terminal:

[1] 3010186

This is a process id (PID). If you want to stop the script before its ending you can use the kill command:

kill PID

It is also possible to kill the process by using pkill command. If you run a few scripts with the same name they all will be stopped.

pkill -f my_script.py

We can see our process using the next command:

ps ax | grep my_script.py

Command output:

3010186 pts/0    R      0:03 python3 ./my_script.py
3012286 pts/1    S+     0:00 grep --color=auto my_script.py

After finishing the process all script output will be saved to output.log. It has the next content:

Start time: 10:46:21
Current time: 10:46:22
Current time: 10:46:23
Current time: 10:46:24
Current time: 10:46:25
Current time: 10:46:26
Current time: 10:46:27
Current time: 10:46:28
Current time: 10:46:29
Current time: 10:46:30
Current time: 10:46:31

The background script seems to work perfectly, but it's not quite true. For example, if you use ssh session connection, the disconnect will stop our script. As a solution, you could use nohup or a better screen. This allows us to return to the script after reconnecting the session.

Using the 'screen' command for background scripts

At first, you need to install the screen. Use the next command for this:

sudo apt install screen

Now we can run our script using the screen command. We need a little to modify the command for the identical logging as in the previous heading. For that, we need to add the next keys: -L for resolving logging and -Logfile path/to/filename.log to indicate log file (by default screenlog.0)

screen -L -Logfile ./output.log ./my_script.py &

Despite the screen output, logging still saves to our log file. 

Let's check the process list during performing the screen command using the next command:

ps ax | grep my_script.py

Command output:

3038184 pts/0    S      0:00 screen -L -Logfile ./output.log ./my_script.py
3038185 ?        Ss     0:00 SCREEN -L -Logfile ./output.log ./my_script.py
3038186 pts/3    Rs+    0:03 python3 ./my_script.py
3038214 pts/1    S+     0:00 grep --color=auto my_script.py

You can also detach the screen using Ctrl + a and also return back to the screen using the command screen -r.

 

 
  • حسن دلدار