numpy advance index

# # tips: torch.tensor has the same indexing rules as numpy.ndarray import numpy as np a = np.array([ [11,12,13,14,15,16,17], [21,22,23,24,25,26,27], [31,32,33,34,35,36,37], [41,42,43,44,45,46,47], [51,52,53,54,55,56,57], ]) a[np.array([0,2,4])] a[np.array([0,2,4])].shape # 2D index will change data shape a[np.array([0,2,4]).reshape(-1,1)] a[np.array([0,2,4]).reshape(-1,1)].shape # 2D index as first index, can work with second array as index a[np.array([0,2,4]).reshape(-1,1), np.array([1,3,5])] a[np.array([0,2,4]).reshape(-1,1), np.array([1,3,5])].shape # np.where result as index idx = np.where(a[:,2]>30)[0] a[idx.reshape(-1,1),2:6].shape != a[idx.reshape(-1,1),range(2,6)].shape == a[idx,2:6].shape == a[idx][:,2:6].shape # boolean…

Ubuntu Install Docker

sudo apt-get install \ ca-certificates \ curl \ gnupg \ lsb-release curl -fsSL | sudo gpg –dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg echo \ “deb [arch=$(dpkg –print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] \ $(lsb_release -cs) stable” | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null sudo apt-get update sudo apt-get install docker-ce docker-ce-cli sudo usermod -aG docker $USER sudo systemctl enable docker sudo systemctl start docker

Insert source code in Google Docs

First,  you’d better disable the  auto-capitilization as follow: go to Tools > Preferences and UN-check “Automatically capitalize words.” then, Google docs has many add-on. try to use the Code Pretty Reference

Modify Windows Console Color using C++

Using function SetConsoleTextAttribute() to modify。 Following are the color code and output sample image。  

Linux: HowTo Identify Server ECC Memory Modules

You can get this information by visiting your BIOS setup menu. Another option is to use dmidecode command to dump bios memory information from a shell prompt: # dmidecode –type 16 # dmidecode 2.11 SMBIOS 2.5 present. Handle 0x0016, DMI type 16, 15 bytes Physical Memory Array Location: System Board Or Motherboard Use: System Memory Error Correction Type: Single-bit ECC Maximum Capacity: 64 GB Error Information Handle: Not Provided Number…

OwnCloud Change Data Directory

Stop your webserver Check if your config.php already contains a datadirectory entry. If it does, remember that location (let’s assume it’s ‘/var/www/owncloud/data’ for now). Change or create the “datadirectory” entry in config.php file, so that it points to wherever you want to have your data from now on. Assuming the directory you want to move the data folder to is ‘/media/usbdisk/ocdata’, your config.php should look like this after the change:…

How do I find out what ports are listening on?

sudo lsof -i -P | grep -i “listen”

RGB color table

Basic colors Color HTML / CSS Name Hex Code#RRGGBB Decimal Code(R,G,B) Black #000000 (0,0,0) White #FFFFFF (255,255,255) Red #FF0000 (255,0,0) Lime #00FF00 (0,255,0) Blue #0000FF (0,0,255) Yellow #FFFF00 (255,255,0) Cyan / Aqua #00FFFF (0,255,255) Magenta / Fuchsia #FF00FF (255,0,255) Silver #C0C0C0 (192,192,192) Gray #808080 (128,128,128) Maroon #800000 (128,0,0) Olive #808000 (128,128,0) Green #008000 (0,128,0) Purple #800080 (128,0,128) Teal #008080 (0,128,128) Navy #000080 (0,0,128)


ASCII printable code chart

Primes Table

The First 1,000 Primes