Week 50 / 2022
git
- Cherry picking is the act of picking a commit from a branch and applying it to another.
- ..say a commit is accidently made to the wrong branch. You can switch to the correct branch and cherry-pick the commit to where it should belong.
- traditional merges are preferred instead ??
- nested
.git
? submodules? git commit -a --amend -m "message"
.-a
Tell the command to automatically stage files that have been modified and deleted, but new files you have not told Git about are not affected.--amend
Replace the tip of the current branch by creating a new commit.- How to group multiple commits into a single one? interactive rebase. You can do many smart tricks during an interactive rebase. 1
git rebase -i [commit-before-the-older-one-you-want]
2 open the editor and start marking squashable commits: You mark a commit as squashable by changing the wordpick
intosquash (s)
next to it. 3 Finally, name your new commit. - What is HEAD?
git log --oneline
- What is fast-forward?
pre-commit
- A framework for managing and maintaining multi-language pre-commit hooks.
- Git hook scripts
- not require root access.
- You specify a list of hooks you want and pre-commit manages the installation and execution of any hook written in any language before every commit.
- 1: install
python -m pip install pre-commit
- 2: add configcreate a file named
.pre-commit-config.yaml
. generate a very basic configuration using pre-commit sample-config - 3: Install the git hook scripts
pre-commit install
-> nowpre-commit
will run automatically on gitcommit
- repos: The repository mapping tells pre-commit where to get the code for the hook from.
repo
: repository url.rev
: the revision or tag to clone at.hooks
: A list of hook mappings. - hooks: configures which hook from the repository is used and allows for customization. All optional keys will receive their default from the repository's configuration.
id
: which hook to use. - Every time you clone a project using pre-commit running
pre-commit install
should always be the first thing you do. ?? - The first time pre-commit runs on a file it will automatically download, install, and run the hook.
- A git repo containing pre-commit plugins must contain a
.pre-commit-hooks.yaml
that tells pre-commit... - to try out a repository:
pre-commit try-repo
often useful to point it at a local directory while developing hooks. - cli: 1
pre-commit clean
clean out cached pre-commit files. 2pre-commit gc
clean unused cached repos. - keeps a cache of installed hook repositories which grows over time. run
pre-commit gc
periodically to clean out unused repos from the cache directory.
Career
- The key part is to communicate the value your solution brought to the organization.
- There are effective techniques to help you frame your thoughts. SOAR (situation, obstacles, actions, result) or STAR (situation, tasks, actions, results)
- flowcv, for cv creation
- Companies that don't have a broken hiring process
Docker
- dockerize react app? -> fastapi and react?
- react-scripts: not found, solved
frappe
- Stock Reconciliation is the process of counting and evaluating material/products, periodically at the year end.
Workflow
- Everything starts with an issue. This acts as ongoing work-in-progress notes and lets me record decisions, reference any research, drop in code snippets and sometimes even add screenshots and video. Any commits that I create that relate to an issue reference the issue number in their commit message.
- Development environment.
- Automated tests.
- Implementing the feature
- Code formatting with Black
- Linting
- Documentation. if a feature isn’t documented it doesn’t exist. Updating existing documentation isn’t much work at all if the documentation already exists, and over time these incremental improvements add up to something really comprehensive.
- Committing the change. If this completes the work on the issue I use "closes #N“, which causes GitHub to close the issue for me.
git commit -a -m "...., closes #N". unrelated changes in my working directory. If so, I use
git add [files] and then commit just withgit commit -m message
. - Branches and pull requests. ensure the new pull request links back to the issue in its description, then switch my ongoing commentary to comments on the pull request itself. make a commit (often just labelled “WIP prototype, refs #N”). I don’t like merge commits—I much prefer to keep my main branch history as linear as possible. I usually merge my PRs through the GitHub web interface using the squash feature, which results in a single, clean commit to main with the combined tests, documentation and implementation. Occasionally I will see value in keeping the individual commits, in which case I will rebase merge them. keep the main branch releasable at all times. Incomplete work should stay in a branch.
- Release notes, and a release.
- A live demo
- Tell the world about it
Python
*args
can be really useful, because it allows you to pass a varying number of positional arguments:my_sum(list_of_ints)
->my_sum(a, b, c, ..any num of positional args)
. takes all the parameters that are provided in the input and packs them all into a single iterable object namedargs
. All that matters here is that you use the unpacking operator (*
). Got tuble from unpacking not list.**kwargs
works just like*args
, but instead of accepting positional arguments it accepts keyword (or named) arguments.- the correct order for your parameters is:
- Standard arguments
- *args arguments
- **kwargs arguments
- In short, the unpacking operators are operators that unpack the values from iterable objects in Python. The single asterisk operator * can be used on any iterable that Python provides, while the double asterisk operator ** can only be used on dictionaries.
Abstract Base Class
- two approaches: Duck Typing and Inheritance
- ABC -> BaseClass -> Concerete.
- metaclass featuers
abc.ABC
- create an abstract base class (ABC) to document APIs (documentation is one of the stronger use cases for ABCs).
- The
abc.ABC
class introduces a metaclass – a class used to build the concrete class definitions. - Python's default metaclass is named
type
. - special attribute,
__abstractmethods__
. This attribute lists all of the names that need to be filled in to create a concrete class - A really comprehensive use of the abstract base classes in the Python standard library lives in the collections module.
collections.abc
module this module provides the abstract base class definitions for Python's built-in collections.- Python's
dict
class is a concrete implementation ofMutableMapping
.
Mysql/MariaDB
COALESCE()
function is used for returning the first non-null value in a list of expressions.