Monthly Shaarli

All links of one month in a single page.

December, 2020

Compiler Explorer
GitHub - khangich/machine-learning-interview: Machine Learning Interviews from FAAG, Snapchat, LinkedIn.
Setup ICPC World Finals Programming Environment on macOS

Install VMWare Fusion

Download official VMWare Fusion 12 and use one of these keys to activate:

ZF3R0-FHED2-M80TY-8QYGC-NPKYF
YF390-0HF8P-M81RQ-2DXQE-M2UT6
ZF71R-DMX85-08DQY-8YMNC-PPHV8

Create virtual machine

Fix DHCP

Open /etc/network/interfaces.d/ens33:

sudo nano /etc/network/interfaces.d/ens33

Change content to:

auto ens33
iface ens33 inet dhcp

Then run:

sudo dhclient ens33

Install open-vm-tools-desktop and codeblocks-contrib

Run in Terminal:

sudo apt-get update
sudo apt-get -y install open-vm-tools-desktop codeblocks-contrib

Share files with virtual machine

  • Click Virtual Machine > Sharing > Sharing Settings...
  • Check Enable Shared Folders
  • Add folders to be shared

Fix VMWare Fusion Shared folders not showing up

Mount /mnt/hgfs using vmhgfs-fuse:

sudo mount -t fuse.vmhgfs-fuse .host:/ /mnt/hgfs -o allow_other

To make mounting globally persistent, add the following line to /etc/fstab:

.host:/ /mnt/hgfs fuse.vmhgfs-fuse allow_other 0 0

Create shortcuts for common applications/folders

Go to Other Locations > /usr/share/applications and drag the shortcuts to Desktop.

To create shortcuts for folders, run in Terminal:

gnome-desktop-item-edit --create-new ~/Desktop

Replace CodeBlocks's default C++ template

sudo gvim /usr/share/codeblocks/templates/wizard/console/cpp/main.cpp

Make CodeBlocks use gnome-terminal

Open CodeBlocks, go to Settings > Environment... > Terminal to launch console programs: > gnome-terminal...

I trained a model. What is next?
Install CUDA for 940MX on Ubuntu 20.04
sudo apt-get update
sudo apt-get -y install g++ freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libglu1-mesa libglu1-mesa-dev

sudo apt-get --purge -y remove 'cuda*'
sudo apt-get --purge -y remove 'nvidia*'
sudo apt-get autoremove -y
sudo apt-get clean

sudo reboot
# Boot with temporary kernel parameter nomodeset

wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin
sudo mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/7fa2af80.pub
sudo add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/ /"
sudo apt-get update
sudo apt-get -y install cuda

echo 'export PATH=/usr/local/cuda-11.1/bin:$PATH' >> ~/.zshrc
echo 'export LD_LIBRARY_PATH=/usr/local/cuda-11.1/lib64:$LD_LIBRARY_PATH' >> ~/.zshrc

sudo nano /etc/default/grub
# Set GRUB_CMDLINE_LINUX="nogpumanager i915.enable_guc=2"
sudo update-grub

# Tell to the NVIDIA configuration tool to switch on NVIDIA graphic card
sudo prime-select nvidia

sudo rm /usr/share/X11/xorg.conf.d/11-nvidia-prime.conf

sudo nano /etc/X11/xorg.conf

Section "Device"
    Identifier     "intel"
    Driver         "modesetting"
    BusID          "PCI:0:2:0"
EndSection

Section "Screen"
    Identifier     "intel"
    Device         "intel"
EndSection

sudo apt purge xserver-xorg-video-intel

sudo reboot

https://developer.nvidia.com/rdp/cudnn-download
tar -xzvf cudnn-11.0-linux-x64-v8.0.5.39.tgz
sudo cp cuda/include/cudnn*.h /usr/local/cuda/include
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn*.h /usr/local/cuda/lib64/libcudnn*

cd /usr/local/cuda/targets/x86_64-linux/lib
sudo ln -sf libcudnn_adv_infer.so.8.0.5 libcudnn_adv_infer.so.8
sudo ln -sf libcudnn_adv_infer.so.8 libcudnn_adv_infer.so

sudo ln -sf libcudnn_adv_train.so.8.0.5 libcudnn_adv_train.so.8
sudo ln -sf libcudnn_adv_train.so.8 libcudnn_adv_train.so

sudo ln -sf libcudnn_cnn_infer.so.8.0.5 libcudnn_cnn_infer.so.8
sudo ln -sf libcudnn_cnn_infer.so.8 libcudnn_cnn_infer.so

sudo ln -sf libcudnn_cnn_train.so.8.0.5 libcudnn_cnn_train.so.8
sudo ln -sf libcudnn_cnn_train.so.8 libcudnn_cnn_train.so

sudo ln -sf libcudnn_ops_infer.so.8.0.5 libcudnn_ops_infer.so.8
sudo ln -sf libcudnn_ops_infer.so.8 libcudnn_ops_infer.so

sudo ln -sf libcudnn_ops_train.so.8.0.5 libcudnn_ops_train.so.8
sudo ln -sf libcudnn_ops_train.so.8 libcudnn_ops_train.so

sudo ln -sf libcudnn.so.8.0.5 libcudnn.so.8
sudo ln -sf libcudnn.so.8 libcudnn.so
CS 229 - Linear Algebra and Calculus refresher
Install CodeBlocks 20.03 + MinGW-w64

Install MSYS and MinGW-w64

  • Download MSYS2 and install it.

Update MSYS2:

pacman -Syy
pacman -Syu

Install MinGW-w64

pacman -S mingw-w64-x86_64-toolchain

Install all members.

Install CodeBlocks

Configure debugger

  • In the top menu go to Settings and select Debugger...
  • In the left pane select GDB/CDB debugger
  • Click Create Config and enter a name (e.g. Debug_MINGW64)
  • Select this new entry on the left
  • Set the location to C:\msys64\mingw64\bin\gdb.exe
  • Uncheck Disable startup scripts (-nx) GDB only
  • Leave the other settings to their defaults (including Debugger type = GDB) and press OK

Configure compiler

  • In the top menu go to Settings and select Compiler...
  • Under Selected compiler choose GNU GCC Compiler
  • Click Copy and enter a name (e.g. MINGW64)
  • Under Selected compiler choose this new entry (should be at the bottom of the list)
  • Click the tab Toolchain executables
  • Under Compiler's installation directory set the location to C:\msys64\mingw64
  • Click the tab Program Files and set the following settings:
    • C compiler: x86_64-w64-mingw32-gcc.exe
    • C++ compiler: x86_64-w64-mingw32-g++.exe
    • Linker for dynamic libs: x86_64-w64-mingw32-g++.exe
    • Linker for static libs: x86_64-w64-mingw32-gcc-ar.exe
    • Debugger: Debug_MINGW64 (as created earlier)
    • Resource compiler: windres.exe
    • Make program: mingw32-make.exe
Install Python 3.8 on Big Sur

Reinstall bzip2:

brew uninstall bzip2
brew install bzip2

Add this to ~/.zshrc:

# Workaround for pyenv to build
export LDFLAGS="-L$(brew --prefix openssl)/lib -L$(brew --prefix readline)/lib -L$(brew --prefix zlib)/lib -L$(brew --prefix bzip2)/lib"
export CFLAGS="-I$(brew --prefix openssl)/include -I$(brew --prefix bzip2)/include -I$(brew --prefix readline)/include -I$(xcrun --show-sdk-path)/usr/include"
How to Influence People: Negotiation vs. Persuasion Skills - YouTube
Top 100 Wiki Pages on Brilliant | Brilliant Math & Science Wiki