Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

123 better help info #124

Merged
merged 14 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@ venv/
# idea
.idea/**

# test related
# demo
0to100**/
978*/
0*/
map.md
repo/
toc*.md
*.yaml
safaribooks/
*.yaml
toc.md

# pip install
build
Expand Down
Binary file removed 50a86373-910b-4a12-85ef-251b6d4f08f0.png
Binary file not shown.
Binary file removed 9b873c30-eccb-4c17-9d36-1c302060f5c3.png
Binary file not shown.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ test:
python -m pytest zero_to_one_hundred

testint:
bash demo.sh 0to100_zt && bash demo.sh 0to100_sb
bash demo.sh zt && bash demo.sh sb

format:
black zero_to_one_hundred
Expand Down
79 changes: 36 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
| [![Quality gate](https://sonarcloud.io/api/project_badges/quality_gate?project=obar1_0to100)](https://sonarcloud.io/summary/new_code?id=obar1_0to100) | [![Makefile CI](https://github.com/obar1/0to100/actions/workflows/makefile.yml/badge.svg)](https://github.com/obar1/0to100/actions/workflows/makefile.yml) |

We read training material from the web and learn from it by doing, but how do we keep that a bit organized? I came up with an idea: this small tool.
Given a 'url', it creates the entry in a markdown map and a folder and links them; in this way, you can easily jump between different sections inside your preferred ide. As you expand the map with new contents, you build some reference material, keep it local all the time, and searchable all the time on your daily coding.
Given a 'url', it creates the entry in a markdown map and a folder and links them; in this way, you can easily jump between different sections inside your preferred ide. As you expand the map with new contents, you build some reference material, keep it local all the time, and searchable all the time on your daily coding and use it to fee your local `llm` :).

## quick demo

Expand All @@ -16,27 +16,40 @@ Given a 'url', it creates the entry in a markdown map and a folder and links the
just open this repo in your GitHub Codespace and run the demo as:

```bash
bash demo.sh 0to100_zt
bash demo.sh zt
```

![](termtosvg_0oihyn7a.svg)
![](2dc4491c-fa27-4c5e-bd0c-71951b3ef0e5.png)
[here](./toc_zt.md)

```bash
bash demo.sh 0to100_sb
bash demo.sh sb
```

![](termtosvg_9evceaqa.svg)

![](z05502bb-4b90-422f-9624-568d9f02cd01.png)
[here](./toc_sb.md)


## oto100

0 to 100 ... learn anything from webresources (and not)
0 to 100 ... learn anything from the web

current commands:
commands:

```
['create_section', 'done_section', 'refresh_map', 'refresh_links', 'help']
create_section = create a new section
section=https://www.cloudskillsboost.google/paths/16
./main.py zt create_section "$section"

done_section = tag a section as done
section=https://www.cloudskillsboost.google/paths/16
./main.py zt done_section "$section"

refresh_map = refresh the section map
./main.py zt refresh_map

refresh_links = refresh links to sections in the readme.md(s)
./main.py zt refresh_links
```

> tip
Expand All @@ -57,9 +70,9 @@ ex

https://www.cloudskillsboost.google/doc
```
expand the last link to point to the section for the doc - handy as anchor tecnique
expand the last link to point to the section for the doc - handy as anchor technique

### 1st time usage:
### setup and usage:

```bash
# env
Expand All @@ -73,31 +86,12 @@ cat map.yaml
export MAP_YAML_PATH=map.yaml
# tip: add it to .bash_rc etc or some shell script

```

![](ab67dd2b-7c12-4cdf-a7a5-f773c2b67919.png)

```bash
chmod +x *.py
# run main
./main.py zt help
```

![](50a86373-910b-4a12-85ef-251b6d4f08f0.png)

### daily usage:

- create new section

```bash
url=https://cloud.google.com/docs
./main.py zt create_section $url

url=https://cloud.google.com/help
./main.py zt create_section $url
#...etc
```

![](9b873c30-eccb-4c17-9d36-1c302060f5c3.png)


## oto100 safari books :construction:

Expand All @@ -108,10 +102,14 @@ same as above but it can use some external lib to grab epub from oreilly
current commands:

```
['snatch_book', 'refresh_toc', 'help']
snatch_book = snatch a book from safari
./main.py sb snatch_book https://learning.oreilly.com/library/view/rewire-your-brain/9781119895947

refresh_toc = refresh the toc with al the books info
./main.py sb refresh_toc
```

### 0th time usage:
### setup and usage:

> use what you prefer to grab epub/pdf from oreilly
check this
Expand All @@ -120,8 +118,6 @@ or just save as pdf section by section with this
https://chromewebstore.google.com/detail/reader-view/ecabifbgmdmgdllomnfinbmaellmclnh


### 1st time usage:

```bash
# env
python -m venv .venv
Expand Down Expand Up @@ -157,7 +153,6 @@ chmod +x *.py

![](63fd79b5-ad41-45fd-a2dc-367f317bcc0c.png)

### daily usage:

- create new meta-book

Expand All @@ -170,24 +165,22 @@ and you have a `toc.md` for free to use as your index (bookmark it)

> as I use myself Lorenzo's great utility `safaribooks` I added some code to convert the downloaded epub contents into a related pdf and split that in chunks so I can easily use it on ipad or better remarkable for studying and later sync back in a repo for hands-on code... they call that **learning by doing** 🖖🏻

example:
![](2dc4491c-fa27-4c5e-bd0c-71951b3ef0e5.png)
![](z05502bb-4b90-422f-9624-568d9f02cd01.png)


### tools
> when you start to have a a few 0to100 based folders
>


[gist to sync multiple 0to100 based repos](https://gist.github.com/obar1/771b1992368262737d9f25fcf17ce1c1)
[gist venv auto activate for 0to100 folders](https://gist.github.com/obar1/212e4c778548f8bcdc6e9c1b05856f3f)

## online example

- 0to100
- zt

https://github.com/obar1/zero2hero

- 0to100sb
- sb
> mostly private contents, `sorry but I don't want to get suited :P`

https://github.com/obar1/0to100.oreilly
Binary file removed ab67dd2b-7c12-4cdf-a7a5-f773c2b67919.png
Binary file not shown.
64 changes: 35 additions & 29 deletions demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,70 +4,76 @@
function setup {
# set -x
export MAP_YAML_PATH=map.yaml

pip install .
chmod +x main*.py

chmod +x main.py
}
function setup0to100_zt {
function setup_zt {
cp ./zero_to_one_hundred/tests/test_ztoh/resources/gcp_map.yaml map.yaml
}

function setup0to100_sb {
function setup_sb {
cp ./zero_to_one_hundred/tests/tests_sb/resources/map.yaml map.yaml

# safari books from lorenzodifuccia
git clone https://github.com/lorenzodifuccia/safaribooks.git
pip install --quiet -r safaribooks/requirements.txt
}

function 0to100_zt {
function zt {
# 0to100
setup0to100_zt
setup_zt

./main.py zt help
content=$(cat << 'EOF'
content=$(
cat <<'EOF'
https://www.cloudskillsboost.google/0
https://www.cloudskillsboost.google/paths/16
https://www.cloudskillsboost.google/games/4424/labs/28651
https://www.cloudskillsboost.google/course_templates/3
https://www.cloudskillsboost.google/games/4422
https://storage.googleapis.com/cloud-training/cls-html5-courses/T-BQRS-I/M1/index.html

EOF
)
while IFS= read -r section || [[ -n "$section" ]]; do
./main.py zt create_section "$section"
done <<< "$content"
)
while IFS= read -r section || [[ -n "$section" ]]; do
./main.py zt create_section "$section"
done <<<"$content"

echo "# a_custom_header 0" >> 0to100/https§§§www.cloudskillsboost.google§0/readme.md
echo "# a_custom_header 0" >>0to100/https§§§www.cloudskillsboost.google§0/readme.md

./main.py zt done_section "https://www.cloudskillsboost.google/0"
./main.py zt done_section "https://www.cloudskillsboost.google/0"

ls -1R 0to100
cp toc.md toc_0to100.md
cp toc.md toc_zt.md
}

function 0to100_sb {
function sb {
# 0to100 safari books
setup0to100_sb
setup_sb

./main.py sb help

./main.py sb snatch_book https://learning.oreilly.com/course/clean-code-fundamentals/9780134661742
echo 'add any metadata you like'
echo '{"title": "Clean Code Fundamentals"}'> 9780134661742/9780134661742.json
echo '{"title": "Clean Code Fundamentals"}' >9780134661742/9780134661742.json
./main.py sb refresh_toc

./main.py sb snatch_book https://learning.oreilly.com/library/view/rewire-your-brain/9781119895947
echo 'pretend book was read fully and get % calc for free :P'
echo '{"page_curr": "100", "page_tot": "100", "url":"https://www.oreilly.com/library/view/rewire-your-brain/9781119895947"}' > 9781119895947/9781119895947.json
echo '{"page_curr": "100", "page_tot": "100", "url":"https://www.oreilly.com/library/view/rewire-your-brain/9781119895947"}' >9781119895947/9781119895947.json
./main.py sb refresh_toc

ls -1R 978*
cp toc.md toc_0to100_sb.md
cp toc.md toc_sb.md

}

setup
$1
#!/bin/bash

if [ $# -eq 0 ]; then
echo "No arguments were passed: use sb or zt"
else
setup
$1
fi
22 changes: 14 additions & 8 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,37 @@
#!/usr/bin/env python3
# coding: utf-8

from enum import Enum
import sys
import logging

from zero_to_one_hundred.exceptions.errors import UnsupportedOptionError
from zero_to_one_hundred.runner import run_core

from zero_to_one_hundred.validator.validator import Validator

if __name__ == "__main__":
logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')

err_msg = f'zt or sb available, passed {str(sys.argv)}'
try:
arg1= sys.argv[1]
match arg1:
case 'zt':
from zero_to_one_hundred.factories.ztoh_factory_provider import ZTOHFactoryProvider
from zero_to_one_hundred.repository.ztoh_persist_fs import ZTOHPersistFS as persist_fs
from zero_to_one_hundred.repository.ztoh_process_fs import ZTOHProcessFS as process_fs
from zero_to_one_hundred.factories.ztoh_factory_provider import ZTOHFactoryProvider
run_core(sys.argv, ZTOHFactoryProvider(persist_fs, process_fs))
case 'sb':
from zero_to_one_hundred.factories.sb_factory_provider import SBFactoryProvider
from zero_to_one_hundred.repository.sb_persist_fs import SBPersistFS as persist_fs
from zero_to_one_hundred.repository.sb_process_fs import SBProcessFS as process_fs
from zero_to_one_hundred.factories.sb_factory_provider import SBFactoryProvider
run_core(sys.argv, SBFactoryProvider(persist_fs, process_fs))
case _:
raise ValueError(err_msg)
except Exception as e:
logging.info(err_msg)
raise ValueError
except (ValueError,IndexError, TypeError,UnsupportedOptionError):
from zero_to_one_hundred.repository.a_persist_fs import APersistFS as persist_fs
from zero_to_one_hundred.factories.a_factory_provider import AFactoryProvider
run_core(sys.argv, AFactoryProvider(persist_fs))
except Exception as e:
Validator.print_e(e)


7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3

from pathlib import Path
from setuptools import setup
from setuptools import setup, find_packages

directory = Path(__file__).resolve().parent
with open(directory / "README.md", encoding="utf-8") as f:
Expand All @@ -12,10 +12,11 @@

setup(
name="0to100",
version="0.4.3",
version="0.5.3",
author="obar1",
packages=find_packages(),
author_email="[email protected]",
description="Simple python tool to learn everything and keep all local.",
description="Simple python tool to learn everything and keep it local.",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/obar1/0to100",
Expand Down
Loading
Loading