Skip to content

Instantly share code, notes, and snippets.

@yang-zhang
yang-zhang / howto move many files
Created May 21, 2018 02:45
How to move large number of files
!find source_folder -name '*.jpg' -exec mv {} target_folder \;
# Solve "mv: Argument list too long" error when using "mv *.jpg"
@yang-zhang
yang-zhang / howto stop delete all docker
Created May 21, 2018 02:52
How to stop and delete all docker containers and/or images
# Stop all running containers
docker stop $(docker ps -aq)
# Remove all containers
docker rm $(docker ps -aq)
# Remove all images
docker rmi $(docker images -q)
@yang-zhang
yang-zhang / visual_studio_code_cheatsheet.md
Last active May 29, 2018 01:19
Visual Studio Code Cheatsheet
  • Command palette (Ctrl-shift-p)
  • Select interpreter
  • Select terminal shell
  • Go to symbol (Ctrl-t)
  • Find references (Shift-F12)
  • Go to definition (F12)
  • Go back (alt-left)
  • View documentation
  • Hide sidebar (Ctrl-b)
  • Zen mode (Ctrl-k,z)
@yang-zhang
yang-zhang / fastai_fixup.py
Created May 30, 2018 01:36
Fixup function for text from fast.ai
re1 = re.compile(r' +')
def fixup(x):
x = x.replace('#39;', "'").replace('amp;', '&').replace('#146;', "'").replace(
'nbsp;', ' ').replace('#36;', '$').replace('\\n', "\n").replace('quot;', "'").replace(
'<br />', "\n").replace('\\"', '"').replace('<unk>','u_n').replace(' @.@ ','.').replace(
' @-@ ','-').replace('\\', ' \\ ')
return re1.sub(' ', html.unescape(x))
# https://github.com/fastai/fastai/blob/master/courses/dl2/imdb.ipynb
@yang-zhang
yang-zhang / pdb.md
Created May 30, 2018 15:00
pdb cheatsheet
  • s / n / c
  • u / d
  • p
  • l
@yang-zhang
yang-zhang / inds_topn.py
Created June 1, 2018 16:01
Get indices of n largest elements in a numpy array
# https://stackoverflow.com/questions/6910641/how-to-get-indices-of-n-maximum-values-in-a-numpy-array
import numpy as np
top_n = 3
arr = np.array([1, 3, 2, 4, 5])
arr.argsort()[-top_n:][::-1]
# array([4, 3, 1])
@yang-zhang
yang-zhang / ewma.ipynb
Last active June 3, 2018 18:45
Exponential moving average (EMA) aka exponentially weighted moving average (EWMA) in Python
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@yang-zhang
yang-zhang / mac_show_hidden.md
Created June 6, 2018 02:06
Custom Search How to Show Hidden Files on MacOS with a Keyboard Shortcut

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name: