Skip to content

Instantly share code, notes, and snippets.

Avatar

Deliang Yang LanternD

View GitHub Profile
@LanternD
LanternD / upgrade_all_pip_packages.sh
Created Jul 25, 2020
Upgrade all pip upgradable packages
View upgrade_all_pip_packages.sh
# https://www.activestate.com/resources/quick-reads/how-to-update-all-python-packages/
pip3 list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip3 install -U
@LanternD
LanternD / 50-stm32-usb-cdc-vcp.rules
Last active Nov 26, 2019
Prevent the 10-second "Device or Resource Busy" on Ubuntu for STM32 USB Virtual Comm Port
View 50-stm32-usb-cdc-vcp.rules
# Prevent the notification "Device or resource busy" when the STM32 is connected to the System for the first 10 seconds.
# Put the file under /etc/udev/rules.d/
# Reload the rules with:
# $ sudo udevadm control --reload
# $ sudo udevadm trigger
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="5740", ENV{ID_MM_DEVICE_IGNORE}="1"\
MODE:="0666", \
SYMLINK+="stm32_vcp_%n"
@LanternD
LanternD / print_color_msg.py
Last active Sep 25, 2019
Print Colorful Text in Python
View print_color_msg.py
WARN = '\033[93m[WARN]\033[00m'
INFO = '\033[92m[INFO]\033[00m'
ERR = '\033[91m[ERR]\033[00m'
DBG = '\033[94m[DBG]\033[00m'
def prt_warn(s): print("\033[93m[WARN]\033[00m {0}".format(s))
def prt_info(s): print("\033[92m[INFO]\033[00m {0}".format(s))
def prt_err(s): print("\033[91m[ERR]\033[00m {0}".format(s))
def prt_dbg(s): print("\033[94m[DBG]\033[00m {0}".format(s))
@LanternD
LanternD / handful_pyspark_functions.md
Last active May 31, 2019
Handful Pyspark Functions
View handful_pyspark_functions.md

A list of useful pyspark functions that I used. A learning note.

Remove rows with NULL value (equivalent to empty string in csv)

non_empty_row_df = df.filter('your_column_name is not NULL')
@LanternD
LanternD / .vimrc
Last active Nov 28, 2018
Some Vim commands that I need every now and then. Keep updating.
View .vimrc
" I put these commands in a '.vimrc' file, but this is not my actually '.vimrc'.
" change the syntax highlight of the current buffer
:set syntax=c
" no syntax highlight
:set syntax=off
" .vimrc. Bind the syntax option to a specific file extension
autocmd BufNewFile,BufRead *.your_ext set syntax=json
@LanternD
LanternD / Nautilus-shortcuts-cheatsheet.md
Last active Nov 26, 2018
Some useful shortcuts in Ubuntu Nautilus (file browser)
View Nautilus-shortcuts-cheatsheet.md

List Version

  • Ctrl + W: Close Nautilus window
  • Ctrl+T: Open a new tab (same as chrome)
  • Ctrl + H: Toggle the hidden file display
  • Ctrl + Q: Quit Nautilus
  • Ctrl + L: Show path to current directory
  • Ctrl + 1/2: Toggle between list view (1) and icon view (2)
  • Ctrl + Shift + W: Close all Nautilus windows, = Ctrl + Q
  • Ctrl + Shift + N: Create new folder
@LanternD
LanternD / screen.md
Last active Nov 14, 2018 — forked from fredrick/screen.md
GNU Screen Cheat Sheet
View screen.md

GNU Screen Cheat Sheet

Basics

  • Ctrl+a c -> Cre­ate new win­dow
  • Ctrl+a A -> Set win­dow name
  • Ctrl+a w -> Show all win­dow
  • Ctrl+a 1|2|3|… -> Switch to win­dow n
  • Ctrl+a " -> Choose win­dow
  • Ctrl+a Ctrl+a -> Switch between win­dow
@LanternD
LanternD / handful-python-short-codes.py
Last active Sep 25, 2019
Collection of handful Python short snippets.
View handful-python-short-codes.py
# Useful short snippets in Python.
# Return the list of all the file names in the given directory
import os
def get_file_list(file_path):
files = []
for root, dirs, files in os.walk(file_path):
print('# of files: {0}'.format(len(files)))
@LanternD
LanternD / fixed_table_column_width_aligned_text_demo.tex
Created Jun 17, 2018
LaTeX - Fixed table column width while aligning text left/center/right
View fixed_table_column_width_aligned_text_demo.tex
\documentclass{article}
\usepackage{array}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\begin{document}
You can’t perform that action at this time.