Skip to content

Instantly share code, notes, and snippets.

@felixmon
felixmon / jupyer_installation_windows.md
Last active September 15, 2020 08:03
Install Jupyter on Windows (errors)

Install Jupyter on Windows 10

1. Requirements

  1. Windows 10 64 bit
  2. Python 3.x 64 bit or errors will occour when installing pywinpty
  3. MS Visual Studio Build Tools (for c++ compiler)

2. Steps

  1. Set Python and Python/Scripts paths to system path (reboot required).
  2. pip install pywinpty
@felixmon
felixmon / windows-cmd-proxy.md
Last active August 25, 2020 08:24
Windows Command Line Proxy Settings

Add Socks5 support to pip:

pip install pysocks

Socks5 proxy settings
(temporary setting, will turn void after shell closed):

 set https_proxy=socks5://127.0.0.1:1081
 set http_proxy=socks5://127.0.0.1:1081
@felixmon
felixmon / excel_functions_guides.md
Last active June 18, 2020 03:03
Excel functions guides

TRANPOSE

使得一行的数值根据另外一列的数值的改变而改变,关键点是函数输入结尾是以数组形式(CTRL+SHIFT+ENTER),而不是直接ENTER

https://support.microsoft.com/zh-cn/office/transpose-%e5%87%bd%e6%95%b0-ed039415-ed8a-4a81-93e9-4b6dfac76027?ui=zh-cn

多级下拉菜单

一级菜单决定下一级菜单的内容,举例:一级菜单选择江苏省,那么二级菜单只能出现南京市、苏州市,而不会出现西安市。功能实现的核心:

  1. 定义名称
  2. 下拉菜单(数据验证-序列)的值采用INDIRECT形式(来引用上述定义名称)
@felixmon
felixmon / gs_win64c.md
Last active June 18, 2020 02:43
Using Ghostscript in Windows 10
  1. add path to system, the path may be something like "C:\Program Files\gs\gs9.52\bin"
  2. run command gswin64c -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER -dFirstPage=27 -dLastPage=27 -sOutputFile=OUTPUT.pdf ORIGINAL.pdf

Examples

Compress

gswin64c -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf
@felixmon
felixmon / enable_gpedit.bat
Created June 3, 2020 08:36
【Windows】Win10家庭版启用组策略gpedit.msc
::https://blog.csdn.net/u013642500/article/details/80138799
@echo off
pushd "%~dp0"
dir /b C:\Windows\servicing\Packages\Microsoft-Windows-GroupPolicy-ClientExtensions-Package~3*.mum >List.txt
dir /b C:\Windows\servicing\Packages\Microsoft-Windows-GroupPolicy-ClientTools-Package~3*.mum >>List.txt
for /f %%i in ('findstr /i . List.txt 2^>nul') do dism /online /norestart /add-package:"C:\Windows\servicing\Packages\%%i"
pause
@felixmon
felixmon / rm_files_size_range.sh
Last active May 17, 2020 04:29
remove / delete files with size range
# remove files less then 100k
find . -type 'f' -size -100k -delete
# remove tif files less than 160k
find . -name "*.tif" -type 'f' -size -160k -delete
# remove files that do NOT match with the pattern
find . -type f ! -name '*.txt' -delete
@felixmon
felixmon / shell_search.sh
Last active April 5, 2020 09:00
bash search
# replace the path with your own
# recommended usage:
# run: chmod +x shell_search.sh
# add path to $PATH
# add alias to .bash_aliases
# run: source ~/.bash_aliases
result=$(find /Users/path_of_your_own -iname "*$1*")
IFS=$'\n' # make newlines the only separator, or "for" loop splits when it sees any whitespace like space, tab, or newline.
for i in $result
@felixmon
felixmon / find_exec.sh
Created April 3, 2020 07:39
find -exec end trails and parameters {} \ ; +
# find file that is less than 100k and rm them
# https://unix.stackexchange.com/a/12904
find . -type f -size -100k -exec rm {} +
# find the files in the current directory that contain the text "chrome".
find . -exec grep chrome {} \;
# or
find . -exec grep chrome {} +
# find will execute grep and will substitute {} with the filename(s) found.
# The difference between ; and + is that with ; a single grep command for each file is executed
# whereas with + as many files as possible are given as parameters to grep at once.
@felixmon
felixmon / plot_hist.py
Last active April 2, 2020 12:15
matplotlib pyplot hist
# central limit theorem in Python
# 展现中心极限定理
# ref:https://zhuanlan.zhihu.com/p/25241653
import numpy as np
import matplotlib.pyplot as plt
random_data = np.random.randint(1, 7, 10000)
samples = []
samples_mean = []
samples_std = []
@felixmon
felixmon / beautiful_Python_codes.py
Last active March 31, 2020 15:46
beautiful Python codes
# Asterisks for unpacking into function call
# https://treyhunner.com/2018/10/asterisks-in-python-what-they-are-and-how-to-use-them/
fruits = ['lemon', 'pear', 'watermelon', 'tomato']
print(*fruits)
# output lemon pear watermelon tomato
date_info = {'year': "2020", 'month': "01", 'day': "01"}
filename = "{year}-{month}-{day}.txt".format(**date_info)
print(filename)
# output '2020-01-01.txt'