A "Best of the Best Practices" (BOBP) guide to developing in Python.
- "Build tools for others that you want to be built for you." - Kenneth Reitz
- "Simplicity is alway better than functionality." - Pieter Hintjens
People
![]() :bowtie: |
😄 :smile: |
😆 :laughing: |
---|---|---|
😊 :blush: |
😃 :smiley: |
:relaxed: |
😏 :smirk: |
😍 :heart_eyes: |
😘 :kissing_heart: |
😚 :kissing_closed_eyes: |
😳 :flushed: |
😌 :relieved: |
😆 :satisfied: |
😁 :grin: |
😉 :wink: |
😜 :stuck_out_tongue_winking_eye: |
😝 :stuck_out_tongue_closed_eyes: |
😀 :grinning: |
😗 :kissing: |
😙 :kissing_smiling_eyes: |
😛 :stuck_out_tongue: |
sourceURL := "http://example.com" | |
// Resolve URL up to 12 redirects. | |
client := &http.Client{ | |
CheckRedirect: func() func(req *http.Request, via []*http.Request) error { | |
redirects := 0 | |
return func(req *http.Request, via []*http.Request) error { | |
if redirects > 12 { | |
return errors.New("stopped after 12 redirects") | |
} |
# The command finds the most recent tag that is reachable from a commit. | |
# If the tag points to the commit, then only the tag is shown. | |
# Otherwise, it suffixes the tag name with the number of additional commits on top of the tagged object | |
# and the abbreviated object name of the most recent commit. | |
git describe | |
# With --abbrev set to 0, the command can be used to find the closest tagname without any suffix: | |
git describe --abbrev=0 | |
# other examples |
#!/usr/bin/env bash | |
# | |
# gh-dl-release! It works! | |
# | |
# This script downloads an asset from latest or specific Github release of a | |
# private repo. Feel free to extract more of the variables into command line | |
# parameters. | |
# | |
# PREREQUISITES | |
# |
I have two Github accounts: oanhnn (personal) and superman (for work). I want to use both accounts on same computer (without typing password everytime, when doing git push or pull).
Use ssh keys and define host aliases in ssh config file (each alias for an account).
const { execSync } = require('child_process'); | |
function executeGitCommand(command) { | |
return execSync(command) | |
.toString('utf8') | |
.replace(/[\n\r\s]+$/, ''); | |
} | |
const BRANCH = executeGitCommand('git rev-parse --abbrev-ref HEAD'); | |
const COMMIT_SHA = executeGitCommand('git rev-parse HEAD'); |
SHELL:=/bin/bash | |
VIRTUAL_ENV=env | |
JUPYTER_ENV_NAME=env | |
PORT=8888 | |
PYTHON=${VIRTUAL_ENV}/bin/python3 | |
# .ONESHELL: | |
DEFAULT_GOAL: help | |
.PHONY: help run clean build venv ipykernel update jupyter |
# Local: | |
# https://stackoverflow.com/questions/21151178/shell-script-to-check-if-specified-git-branch-exists | |
# test if the branch is in the local repository. | |
# return 1 if the branch exists in the local, or 0 if not. | |
function is_in_local() { | |
local branch=${1} | |
local existed_in_local=$(git branch --list ${branch}) | |
if [[ -z ${existed_in_local} ]]; then | |
echo 0 |