Skip to content

too confusing to use #24

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

Closed
ChocoTonic opened this issue Mar 21, 2022 · 10 comments
Closed

too confusing to use #24

ChocoTonic opened this issue Mar 21, 2022 · 10 comments

Comments

@ChocoTonic
Copy link

can you make more documentation on how to actually use this?

@fspv
Copy link
Owner

fspv commented Mar 21, 2022

Hi @ChocoTonic!

Thanks for your feedback, but can you actually give more details on what exactly is missing?

I tried to use the existing guide https://github.com/prius/leetcode-anki#installation

And it worked without modifications

spv@laptop test $ git clone git@github.com:prius/leetcode-anki.git
Cloning into 'leetcode-anki'...
remote: Enumerating objects: 234, done.
remote: Counting objects: 100% (234/234), done.
remote: Compressing objects: 100% (164/164), done.
remote: Total 234 (delta 110), reused 150 (delta 52), pack-reused 0
Receiving objects: 100% (234/234), 54.61 KiB | 319.00 KiB/s, done.
Resolving deltas: 100% (110/110), done.
spv@laptop test $ cd leetcode-anki/
spv@laptop leetcode-anki $ virtualenv -p python3 leetcode-anki
created virtual environment CPython3.8.10.final.0-64 in 105ms
  creator CPython3Posix(dest=/tmp/test/leetcode-anki/leetcode-anki, clear=False, global=False)
  seeder FromAppData(download=False, pip=latest, setuptools=latest, wheel=latest, pkg_resources=latest, via=copy, app_data_dir=/home/spv/.local/share/virtualenv/seed-app-data/v1.0.1.debian.1)
  activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
spv@laptop leetcode-anki $ . leetcode-anki/bin/activate
spv@laptop [venv:leetcode-anki] leetcode-anki $ export LEETCODE_SESSION_ID="xxx"
spv@laptop [venv:leetcode-anki] leetcode-anki $ make generate
# You have to set the variables below in order to
# authenticate on leetcode. It is required to read
# the information about the problems
test ! "x/tmp/test/leetcode-anki/leetcode-anki" = "x" || (echo "Need to run inside venv" && exit 1)
pip install -r requirements.txt
Requirement already satisfied: python-leetcode==1.2.1 in ./leetcode-anki/lib/python3.8/site-packages (from -r requirements.txt (line 1)) (1.2.1)
Requirement already satisfied: setuptools==57.5.0 in ./leetcode-anki/lib/python3.8/site-packages (from -r requirements.txt (line 2)) (57.5.0)
Requirement already satisfied: genanki in ./leetcode-anki/lib/python3.8/site-packages (from -r requirements.txt (line 3)) (0.13.0)
Requirement already satisfied: tqdm in ./leetcode-anki/lib/python3.8/site-packages (from -r requirements.txt (line 4)) (4.63.0)
Requirement already satisfied: python-dateutil in ./leetcode-anki/lib/python3.8/site-packages (from python-leetcode==1.2.1->-r requirements.txt (line 1)) (2.8.2)
Requirement already satisfied: six>=1.10 in ./leetcode-anki/lib/python3.8/site-packages (from python-leetcode==1.2.1->-r requirements.txt (line 1)) (1.16.0)
Requirement already satisfied: certifi in ./leetcode-anki/lib/python3.8/site-packages (from python-leetcode==1.2.1->-r requirements.txt (line 1)) (2021.10.8)
Requirement already satisfied: requests in ./leetcode-anki/lib/python3.8/site-packages (from python-leetcode==1.2.1->-r requirements.txt (line 1)) (2.27.1)
Requirement already satisfied: urllib3>=1.15 in ./leetcode-anki/lib/python3.8/site-packages (from python-leetcode==1.2.1->-r requirements.txt (line 1)) (1.26.9)
Requirement already satisfied: frozendict in ./leetcode-anki/lib/python3.8/site-packages (from genanki->-r requirements.txt (line 3)) (2.3.0)
Requirement already satisfied: chevron in ./leetcode-anki/lib/python3.8/site-packages (from genanki->-r requirements.txt (line 3)) (0.14.0)
Requirement already satisfied: cached-property in ./leetcode-anki/lib/python3.8/site-packages (from genanki->-r requirements.txt (line 3)) (1.5.2)
Requirement already satisfied: pyyaml in ./leetcode-anki/lib/python3.8/site-packages (from genanki->-r requirements.txt (line 3)) (6.0)
Requirement already satisfied: idna<4,>=2.5; python_version >= "3" in ./leetcode-anki/lib/python3.8/site-packages (from requests->python-leetcode==1.2.1->-r requirements.txt (line 1)) (3.3)
Requirement already satisfied: charset-normalizer~=2.0.0; python_version >= "3" in ./leetcode-anki/lib/python3.8/site-packages (from requests->python-leetcode==1.2.1->-r requirements.txt (line 1)) (2.0.12)
python3 generate.py
INFO:root:Fetching 2214 problems 2214 per page
100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2214/2214 [00:28<00:00, 78.79problem/s]
INFO:root:Generating flashcards
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2213/2213 [00:00<00:00, 25723.16flashcard/s]
spv@laptop [venv:leetcode-anki] leetcode-anki $ ls -lah leetcode.apkg 
-rw-rw-r-- 1 spv spv 6.4M Mar 21 19:23 leetcode.apkg

The only problem is that sometimes leetcode API returns a 503 error (service unreachable), but this is not related to this application, you have to just retry.

@ChocoTonic
Copy link
Author

ChocoTonic commented Mar 22, 2022

your response was perfect and I got it working on my Linux machine. You should include what you have up there in your installation instructions

it would have been helpful to know what OS this was made for.

I also noticed that the frequency field is broken and will always show 0 for every question.

I was also wondering if there is per question company data available since it's available in the Visual Studio Code leetcode extension for free or the information was scraped from a premium account

@SenseCode
Copy link

SenseCode commented Mar 23, 2022

I am using windows system, and after git clone and set up the environment using the following commands, I am stuck on the export session Id, I don't know what I should input for a leetcode_session_id...

virtualenv -p python3 leetcode-anki
cd leetcode-anki
leetcode-anki\Scripts\activate 

@fspv
Copy link
Owner

fspv commented Mar 23, 2022

I see. I obviously didn't test it for Windows. I have no idea if environment variables there exist. I will test this evening. If they don't then the cookie can be passed via arguments to the script, which is not implemented yet.

@SenseCode
Copy link

I see. I obviously didn't test it for Windows. I have no idea if environment variables there exist. I will test this evening. If they don't then the cookie can be passed via arguments to the script, which is not implemented yet.

Thanks, looking forward to your testing in windows and updated document !

fspv added a commit that referenced this issue Mar 23, 2022
Added more information on how to use the generator and prerequisites
@fspv
Copy link
Owner

fspv commented Mar 23, 2022

I have added a bit more documentation d3a141c

With regards to running it on Windows, I spent 40 minutes trying to figure out how to install git, virtualenv, and other stuff there without much luck. My Windows programming knowledge is very limited, so I stopped at this point, as I can't invest so much time into that. If somebody is willing to help with the steps to get it working on Windows, I definitely wouldn't mind.

I found that in order to set an environment variable on Windows you need to use SET or SETX commands instead of export, but didn't test it myself.

@SenseCode
Copy link

Thanks, currently hard to make it work. Will test other time to see.

@ChocoTonic
Copy link
Author

I spent half an hour trying to get it to work on Windows and gave up. not worth the effort to try to get it to work there when it works easily on Linux

@xnorpx
Copy link
Contributor

xnorpx commented Jun 11, 2022

@prius thanks for a great project

I did this to get it running on Windows

I had git and python 3.8+ already installed.

git clone https://github.com/prius/leetcode-anki
cd leetcode-anki
set LEETCODE_SESSION_ID="yyy"
python -m venv leetcode-anki
.\leetcode-anki\Scripts\activate.bat
pip install -r requirements.txt
python generate.py

@fspv
Copy link
Owner

fspv commented Jun 12, 2022

Hi @xnorpx! Thank you so much for working on that and sharing this. I extended the README based on your comment #29

@fspv fspv closed this as completed Jun 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants