Skip to content

Instantly share code, notes, and snippets.

View Hansimov's full-sized avatar

Hansimov

View GitHub Profile
@Hansimov
Hansimov / copy_folder.py
Created July 20, 2021 02:29
python copy folder recursively
cmd_cp_folder = 'cp -a {} {}'
def copy_folder(src, dst):
src = os.path.join(src, '.')
shell_cmd(cmd_cp_folder.format(src,dst))
copy_folder('dir1', 'par/dir2')
@Hansimov
Hansimov / elapsed_time.py
Created July 20, 2021 02:32
Python get program start, end and elapsed time
import datetime
def time2str(t): # time to string
if isinstance(t, datetime.datetime):
return t.strftime('%Y-%m-%d %H:%M:%S')
elif isinstance(t, datetime.timedelta):
return '{} hr {:02} min {:02} s'.format(t.seconds//3600, (t.seconds//60)%60, t.seconds%60)
else:
return str(t)
@Hansimov
Hansimov / python-tips-and-solutions.md
Last active July 1, 2023 18:50
Collection of useful Python tips and solutions in daily work
  • Reload packages
  • multiprocessing not work
  • Generate requirements.txt
@Hansimov
Hansimov / .cshrc
Last active July 14, 2023 09:18
cshell config (.cshrc)
# set color of promt
# https://www.cs.umd.edu/~srhuang/teaching/code_snippets/prompt_color.tcsh.htmlet
set red="%{\033[1;31m%}"
set green="%{\033[0;32m%}"
set yellow="%{\033[1;33m%}"
set blue="%{\033[1;34m%}"
set cyan="%{\033[1;36m%}"
set white="%{\033[0;37m%}"
set clrend="%{\033[0m%}"
# set prompt="%{\033[30;43m%}%/ #%{\033[0;37;40m%} %{\033[0m%}"
@Hansimov
Hansimov / .tmux.conf
Last active January 15, 2024 07:52
.tmux.conf
# TMUX Guide
# https://tmuxguide.readthedocs.io/en/latest/tmux/tmux.html#tmux-conf
# tmux(1) - Linux manual page
# https://man7.org/linux/man-pages/man1/tmux.1.html#FORMATS
# 256 Colors - Cheat Sheet - Xterm, HEX, RGB, HSL
# https://www.ditig.com/256-colors-cheat-sheet
# kill tmux process (if stuck) with following commands
# ps aux | grep tmux
# kill -9 <pid>
@Hansimov
Hansimov / clean_code_notes.md
Last active August 31, 2022 18:20
Clean Code Notes

Clean Code Books

  • Clean Code: A Handbook of Agile Software Craftmanship
  • Clean Architecture: A Craftsman's Guide to Software Structure and Design
  • The Clean Coder: A Code of Conduct for Professional Programmers
  • Clean Agile: Back to Basics
  • Agile Software Development: Principles, Patterns, and Practices
  • Clean Craftsmanship: Disciplines, Standards, and Ethics
  • Refactoring: Improving the Design of Existing Code
@Hansimov
Hansimov / windows_git_bash_netrc.md
Created June 6, 2022 16:56
Windows Git bash use token in _netrc
  1. Go to GitHub > Settings > Developer Settings > Personal access tokens > Generate new token, and copy it

  2. Create _netrc under C:\Users\<username>, write the following content into it:

    machine github.com
    login <username>
    password ghp_*****************************
    
  3. Then git bash will use this token to communicate with remote server

@Hansimov
Hansimov / vscode_plugins_xhr_failed.md
Last active June 20, 2022 07:22
VSCode: Failed to fetch plugins XHR failed

Ctrl+Shift+P > Settings > Http: Proxy> Set http://proxy-prc.intel.com:913


@Hansimov
Hansimov / pip-install-connect-timeout.md
Last active April 10, 2023 12:35
Python pip install timeout

Method 1: Download *.whl to local and install manually

Run shell as Administrator:

python -m pip install <package-name>.whl

  • If this package has some dependencies, you also need to download and install these dependencies mannualy, which are also shown in the WARNING info as /simple/<dependency-package>/.
  • Do not use the --force-reinstall option, since this will make pip to fetch dependencies remotely, which is not suitable for this case.
  • It is possible to write a script to extract the dependencies from the WARNING info, and fetch the .whl automatically from pypi.org and install it.
  • See: https://gist.github.com/Hansimov/a9763c1f1ea76fd014e1164f0e6a8917