Skip to content

Instantly share code, notes, and snippets.

import numpy as np
def plot_confusion_matrix(cm,
title='Confusion matrix',
given a sklearn confusion matrix (cm), make a nice plot
FangliangBai / Porting Virtualenv
Last active July 22, 2019 13:18
Transfer the venv from one computer to another one.
1. Two computers install `Python` and `virtualenv` of same version.
2. On source computer:
pip freeze > requirements.txt
pip download -d your_offline_packages_folder_dir -r requirements.txt
3. On target computer:
pip install --no-index --find-links=your_offline_packages_folder_dir -r requirements.txt
FangliangBai / Excellent Softwares
Last active July 19, 2019 14:56
List of Excellent Softwares -- keep updating
uTools Win Extension of Everything
mackup Lnx Keep your application settings in sync
Blender Lnx 三维动画制作
FangliangBai / Ubuntu 16.04 use PulseAudio Volume Control
Created July 19, 2019 08:53
Ubuntu 16.04 use PulseAudio Volume Control
% Description:
% Allow user to output audio from HDMI or other audio devices.
% Reference:
$ sudo apt install pulseaudio
% Reboot
$ sudo apt install pavucontrol
FangliangBai / Ubuntu 16.04 recover files which were deleted by rm command
Created July 18, 2019 10:05
Ubuntu 16.04 recover files which were deleted by rm command
% - This snip is for ext4 partition.
% - Do this operation immediately after you deleting the files.
% - There is a possibility that some files are not recoverable.
% - Reference:
% Install extundelete.
filename = os.path.join(data_dir, trainfilename)
row_img = []
with open(filename) as fid:
content =
content = content.split('\n')
content = content[:-1]
for i in content:
img =, as_grey=False, plugin=None, flatten=None, **plugin_args)