Skip to content

Instantly share code, notes, and snippets.

View LanternD's full-sized avatar
:octocat:
Code for fun

D.L. Yang LanternD

:octocat:
Code for fun
View GitHub Profile
@LanternD
LanternD / figure-envs.tex
Created December 12, 2020 20:12
LaTeX Figure Environment
% Style 1 (default)
\begin{figure}[!t]
\centering
\includegraphics[width=0.5\columnwidth]{./fig1.pdf}
\caption{Figure caption here.}
\label{fig:fig_label}
\end{figure}
@LanternD
LanternD / upgrade_all_pip_packages.sh
Created July 25, 2020 18:19
Upgrade all pip upgradable packages
# 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 November 26, 2019 19:55
Prevent the 10-second "Device or Resource Busy" on Ubuntu for STM32 USB Virtual Comm Port
# 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 January 28, 2021 03:36
Print Colorful Text in Python
# Fastest way:
WARN = '\033[93m[WARN]\033[00m'
INFO = '\033[92m[INFO]\033[00m'
ERR = '\033[91m[ERR]\033[00m'
DBG = '\033[94m[DBG]\033[00m'
print(INFO, "hello") # Usage
print(WARN, ERR, DBG, "your words here")
@LanternD
LanternD / handful_pyspark_functions.md
Last active May 31, 2019 23:51
Handful Pyspark Functions

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 November 28, 2018 21:19
Some Vim commands that I need every now and then. Keep updating.
" 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 April 15, 2024 06:36
Some useful shortcuts in Ubuntu Nautilus (file browser)

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 November 14, 2018 22:00 — forked from fredrick/screen.md
GNU Screen Cheat Sheet

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 December 12, 2020 20:24
Collection of handful Python short snippets.
"""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):
@LanternD
LanternD / fixed_table_column_width_aligned_text_demo.tex
Created June 17, 2018 01:19
LaTeX - Fixed table column width while aligning text left/center/right
\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}