tech-troubleshooting-tavern

U+1F916, U+1F37B, U+1F469 U+200D U+1F4BB

View the Project on GitHub MarcyMarxy/tech-troubleshooting-tavern

Tech Troubleshooting Tavern

🤖 🍻 👩‍💻 GitHub Pages site: https://marcymarxy.github.io/tech-troubleshooting-tavern/

Table of Contents

Principles

WSL VSCode Setup

For Mac: VSCode+zsh(package install)

Git GitHub

Wouldn’t hurt

git --version
git status

Routine

git init
git add .
git commit -m "write some messages"
git push
Author identity unknown
*** Please tell me who you are.
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
git remote add origin https://github.com/???.git
git branch -M main
git push -u origin main

References:

Wrong account

Delete all

git remote rm origin
ls 

Debug

Python debugger pdb

import pdb

Set breakpoint

pdb.set_trace()

Inspect variables

p state
state
n
c

Quit

q
quit

Testing

Assertions unittest vs pytest

unittest: “Method-Based Assertions”

self.assertSomething(expected, actual)

Think: “I’m telling the test case to assert something”

pytest: “Plain Python Assertions”

assert condition

Think: “I’m writing a normal Python assertion”

What you want to test unittest pytest
Equality self.assertEqual(a, b) assert a == b
Truthiness self.assertTrue(x) assert x
Falseness self.assertFalse(x) assert not x
Type checking self.assertIsInstance(obj, cls) assert isinstance(obj, cls)
None check self.assertIsNone(x) assert x is None
Not None self.assertIsNotNone(x) assert x is not None
Container membership self.assertIn(item, container) assert item in container
Not in container self.assertNotIn(item, container) assert item not in container
Exception raised self.assertRaises(Exc, func, *args) pytest.raises(Exc, func, *args)
Approximate equality self.assertAlmostEqual(a, b) assert abs(a - b) < tolerance

Docstring Formats

Markdown

https://validator.w3.org/#validate_by_input

Emoji Unicode
emojipedia

LaTex

TinyTex + LaTex Workshop

parskip.sty not found
pdflatex --version
tlmgr install parskip
tlmgr install titlesec

I LIKE

Black

Python code formatter.

Sphinx

Generate documentation from comments and docstrings using Sphinx.
In terminal, type:

sphinx-quickstart

Enter basic project information. In conf.py, add:

import os
import sys

sys.path.insert(0, os.path.abspath('.'))
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

extensions = ['sphinx.ext.autodoc']

autodoc_member_order = 'bysource'

html_theme = 'sphinx_rtd_theme'

In index.rst, add:

.. automodule:: <module name>
   :members:
   :undoc-members:
   :show-inheritance:
   :special-members: __init__

In terminal, type:

sphinx-apidoc -o docs . -f
make html

In VS Code, use “Live Server” extension to preview.

Web safe colors

https://www.colorhexa.com/web-safe-colors

HTTP response status codes

https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status

True Random Number Generator

https://www.random.org/

Example Domains

https://www.iana.org/help/example-domains