For personal note-taking of useful commands
- New branch:
git checkout -b [name_of_your_new_branch]
- List branches:
git branch
- Stage files:
git add <filename>
- See changes:
git diff <branchname>
- Create PR:
git push
- Delete branch:
git branch -d <branchname>
- Commit Modified File:
git commit -am "commit message"
- See modified files:
git status
- Catch up with master on a feature branch:
git merge master
- Get rid of modification on file:
git reset <filename>
- Undo 1 commit:
git reset HEAD~1
- See commit log & hashes:
git log
- Unstage but keep all changes after this hash:
git reset <commithash>
--hard
to unstage + discard changes also
npx create-next-app --example with-tailwindcss scrypto-bond-frontend
git init
-
Sibling directory: 1) Single Method
import os, sys currentdir = os.path.dirname(os.path.realpath(__file__)) parentdir = os.path.dirname(currentdir) sys.path.append(parentdir)
- Modularization: Create
__init__.py
in thesibling_directory
with the following
from sibling_script import sibling_method
In the
main.py
do:from sibling_directory import sibling_method
- Modularization: Create
- Add
my_set = {1,3,5,7} my_set.add(8) my_set.remote(8)
from collections import defaultdict
def_dict = defaultdict(<DATA_TYPE OF DEFAULT VAL>)
# Defaultdict of defaultdict
defaultdict(lambda: defaultdict(int))
- Dictionary: Doesn't exist. Use comprehension
my_dictionary = {k: f(v) for k, v in my_dictionary.items()}
- Filter list:
filtered_list = filter(input_list, boolean_func)
- Set the same type as class in method's parameter:
Using forward declarations it is
class Foo: def foo_method(self, other_foo: "Foo"): return "Hello World!"
eval
ed after the whole module is loaded, so it can evaluate to theFoo
class.
- Create
requirements.txt
:pip freeze > requirements.txt
- Install all dependencies:
pip install -r requirements.txt
- Use Environment:
- Linux:
source env/bin/activate
- Windows:
.\env\Scripts\activate.bat
- Linux:
- Anaconda:
conda env create -n <envName> --file requirements.txt
conda activate <envName>