Skip to content

Instantly share code, notes, and snippets.

@foolishflyfox
foolishflyfox / .vimrc
Created August 29, 2019 07:22
vim 配置
set filetype=python
"au BufNewFile,BufRead *.py,*.pyw setf python
autocmd FileType python set expandtab
set helplang=cn "中文帮助文档(前提是下了中文包)
syntax enable
syntax on " 自动语法高亮
set number"显示行号
colorscheme desert" 设定配色方案
set guifont=Consolas:h12:cANSI"英文字体
set guifontwide=SimSun-ExtB:h12:cGB2312
@foolishflyfox
foolishflyfox / vsc_treejs.md
Created April 4, 2019 08:36
在 vscode 下为three.js 添加自动提示功能
@foolishflyfox
foolishflyfox / getip.py
Created March 23, 2019 05:46
Get local address with python
import socket
def getip():
try:
_s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
_s.connect(('8.8.8.8', 80))
ip = _s.getsockname()[0]
finally:
_s.close()
return ip
@foolishflyfox
foolishflyfox / python_cv.py
Last active February 4, 2019 13:06
常用的python计算机视觉操作函数
# 对一幅灰度图像进行直方图均衡化
def myhisteq(im, nbr_bins=256):
"""
@im: PIL.Image.Image, mode is L
@return: PIL.Image.Image
"""
np_im = np.asarray(im)
imhist, bins = np.histogram(np_im.flatten(), nbr_bins)
csum = np.cumsum(imhist)
csum = 255 * csum / csum[-1]
#!/usr/bin/env bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
#=================================================================#
# System Required: CentOS 6+, Debian 7+, Ubuntu 12+ #
# Description: One click Install Shadowsocks-Python server #
# Author: Teddysun <i@teddysun.com> #
# Thanks: @clowwindy <https://twitter.com/clowwindy> #
# Intro: https://teddysun.com/342.html #
#=================================================================#
@foolishflyfox
foolishflyfox / ss.md
Last active February 6, 2019 15:04
ShadowSocks 服务的安装与加速
  1. 安装服务:
wget --no-check-certificate https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks.sh
chmod +x shadowsocks.sh
./shadowsocks.sh 2>&1 | tee shadowsocks.log
  1. 加速1
@foolishflyfox
foolishflyfox / nfs_config.md
Created December 25, 2018 07:24
Edit files of a directory in remote server with NFS

Server Operations

Install nfs server

$ sudo apt-get update
$ sudo apt-get install -y nfs-kernel-server

Config nfs

@foolishflyfox
foolishflyfox / jupyter_animation.py
Last active August 9, 2024 08:09
Display sequence images or dynamic function as an animation in jupyter notebook
import matplotlib.pyplot as plt
from matplotlib import animation
from IPython.display import display, HTML
import numpy as np
def plot_sequence_images(image_array):
''' Display images sequence as an animation in jupyter notebook
Args:
image_array(numpy.ndarray): image_array.shape equal to (num_images, height, width, num_channels)
@foolishflyfox
foolishflyfox / jobs_control.md
Last active December 24, 2018 04:41
jobs control tools in linux

Commands:

  • ./tst.py &: run in background
  • nohup ./tst.py &: don't print output in stdout, and set the parent process as #0 process.nohup means No hangup signal.
  • setsid ./tst.py &: print output in stdout, set the parent process as #1 process.
  • disown %1: change the parent process of a background process
  • hot key ctrl+z: suspend foreground process
  • bg %1: trun foreground job #1 to background, equal to kill -CONT -pid_value
  • bg: trun all foreground job to background
  • fg %1: trun background job to foreground
@foolishflyfox
foolishflyfox / cv_framework_simplified.py
Last active December 24, 2018 07:41
Pytorch Computer Vision Framework (Simplified)
import torch
import torchvision
import torch.utils.data
from torchvision import transforms
from torch.backends import cudnn
# some hyperparameters setting
use_gpu = True
train_batch_size = 64
val_batch_size = 64