Skip to content

Instantly share code, notes, and snippets.

@yang-zhang
yang-zhang / ipy_hide_input
Created January 25, 2017 20:12 — forked from hannes-brt/ipy_hide_input
This is a simple command line tool that adds a small snippet of Javascript to the end of the HTML output of `ipython nbconvert` that hides the input code in the output. This works for both '--to html' and '--to slides' The tool works both when given a file name or by reading from stdin: ```bash ipy_hide_input input_file.slides.html ipython nbcon…
#! /usr/bin/env python
"""
The MIT License (MIT)
Copyright (c) 2013 Hannes Bretschneider
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
@yang-zhang
yang-zhang / howto autoreload
Last active May 19, 2018 02:00
Add autoreload to the top of notebook to reload modules before executing code
%load_ext autoreload
%autoreload 2
# https://ipython.org/ipython-doc/3/config/extensions/autoreload.html
@yang-zhang
yang-zhang / howto checkout remote branch
Created May 19, 2018 02:04
Check out remote github branch
git fetch origin
git checkout -b target_branch origin/target_branch
@yang-zhang
yang-zhang / howto add github remote
Created May 19, 2018 02:07
How to add github remote
git remote add upstream https://github.com/some_user/their_repo.git
@yang-zhang
yang-zhang / howto remove git file keep local
Created May 19, 2018 02:09
How to remove file from git but keep locally
git rm --cached -r file_to_remove_and_keep_local.py
@yang-zhang
yang-zhang / howto reload module py3
Created May 19, 2018 02:14
Reload module in Python3
from importlib import reload
reload(some_module)
@yang-zhang
yang-zhang / howto untar all tar files
Created May 20, 2018 02:25
How to untar all tar files in a directory
!for a in `ls -1 *.tar`; do tar xf $a; done
@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)