Tips¶
- You can use the built-in function
sortedto sort any iterable collection. It always a (new) list containing sorted data. Some mutable collections (e.g., list) have thee methodsortto sort elements in-place. BothsortedandCollection.sortaccept an argumentkeyfor specifying customized sorting criteria.
Sort a List¶
Convert a Tensor to a Numpy Array or List in PyTorch
Tips¶
There are multiple ways to convert a Tensor to a numpy array in PyTorch.
First,
you can call the method Tensor.numpy.
my_tensor.numpy()
Second,
you can use the function numpy.array.
import numpy as np
np.array(my_tensor)
It is suggested that you use the function numpy.array
to convert a Tensor to a numpy array.
The reason is that numpy.array is more generic.
You can also use it to convert other objects (e.g., PIL.Image)
to numpy arrays
while those objects might not have a method named numpy
Convert an Image to Differnt Modes Using Pillow in Python
Get Information of Application Windows in Python
Tips¶
- PyGetWindow does not support Linux currently.
Installation¶
pip3 install pyobjc-framework-quartz pygetwindow
Quickly Open a Directory in Terminal in Mac
Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!
OpenInTerminal
is a Finder Toolbar app for macOS
to open the current or selected directory in Terminal, iTerm, Hyper or Alacritty.
Installation and Configuration
-
Install OpenInTerminal
brew cask install openinterminal -
Launch …
Add New Document to Right-Click Menu in Mac
Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!
Right Click to Create New File on macOS
Automator
This solution is stupid.
You must right click on a file/folder in order for Quick Action to show up in the …