Skip to content

Instantly share code, notes, and snippets.

@hanminghui
hanminghui / sed_scripts
Last active December 28, 2019 04:13
[sed_scripts] some sed scripts examples #sed #linux #shell
# replace blank line, even line contains spaces
s/^ *$/.LP/
# replace spaces at begin of the line
s/^ *//
# replace spaces at end of the line
s/ *$//
# replace spaces more than one to just one space
s/ */ /g
# extract outline from latex files
@hanminghui
hanminghui / extract_in_subdirecories.sh
Last active September 13, 2024 19:43
[Shell Scripts] some shell scripts #shellscripts
# there are many subdirectories, and each file has a .tgz file in it.
# run this to check path, test first
for d in ./*/
do (cd $d && echo $PWD)
done
# run this to extrat files to its directory.
for d in ./*/
do (cd $d && find . -name '*.tgz' -not -name '.*' -exec tar xvzf {} -C $PWD \;)
@hanminghui
hanminghui / check_file_md5.txt
Created May 22, 2019 12:04
[some commands in Windows] #windows
certutil -hashfile filename MD5
certutil -hashfile filename SHA1
certutil -hashfile filename SHA256
@hanminghui
hanminghui / chmod.sh
Last active November 6, 2026 07:03
[Linux Commands] some linux commands #linux
# chmod [OPTION] [MODE] [FILE]
# mode: '[ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+'
# [ugoa] user, group, others(not in group), all
# [-+=] remove, add,
# [rwxXst] read, write, execute,
chmod u+x filename
@hanminghui
hanminghui / write_dict_to_excel.py
Created May 7, 2019 06:56
[dict_to_excel] write python dict to excel using pandas #pandas #excel
import pandas as pd
import xlsxwriter
# an example dict
table_result = []
table_row = {}
element = 3.14
table_row['col_1'] = 1000
table_row['col_2'] = 3e-5
table_row['col_3'] = 2.242