Coder Social home page Coder Social logo

jwasham / computer-science-flash-cards Goto Github PK

View Code? Open in Web Editor NEW
8.1K 242.0 2.0K 456 KB

Mini website for testing both general CS knowledge and enforce coding practice and common algorithm/data structure memorization.

License: Creative Commons Attribution Share Alike 4.0 International

Python 35.10% CSS 4.98% HTML 53.59% JavaScript 5.04% Shell 0.47% Dockerfile 0.81%

computer-science-flash-cards's Introduction

Computer Science Flash Cards

This is a little website I've put together to allow me to easily make flash cards and quiz myself for memorization of:

  • General cs knowledge
    • vocabulary
    • definitions of processes
    • powers of 2
    • design patterns
  • Code
    • data structures
    • algorithms
    • solving problems
    • bitwise operations

Will be able to use it on:

  • desktop
  • mobile (phone and tablet)

It uses:

  • Python 3
  • Flask
  • SQLite

About the Site

Here's a brief rundown: https://startupnextdoor.com/flash-cards-site-complete/

Screenshots

UI for listing cards. From here you can add and edit cards.

Card UI


The front of a General flash card.

Memorizing general knowledge


The reverse (answer side) of a Code flash card.

Code view

Important Note

The set included in this project (cards-jwasham.db) is not my full set, and is way too big already.

Thanks for asking for my list of 1,792 cards. But it’s too much. I even printed them out. It’s 50 pages, front and back, in tiny text. It would take about 8 hours to just read them all.

My set includes a lot of obscure info from books I’ve read, Python trivia, machine learning knowledge, assembly language, etc.

I've added it to the project if you want it (cards-jwasham-extreme.db). You've been warned.

Please make your own set, and while you’re making them, only make cards for what you need to know. Otherwise, it gets out of hand.

How to convert to Anki or CSV

If you don't want to run a server, you can simply use Anki or a similar service/app. Use this script to convert from my sets (SQLite .db file), or yours, to CSV:

https://github.com/eyedol/tools/blob/master/anki_data_builder.py

Thanks @eyedol

Anki Flashcards:

Thanks @JackKuo-tw

How to run it on a server

  1. Clone project to a directory on your web server.
  2. Edit the config.txt file. Change the secret key, username and password. The username and password will be the login for your site. There is only one user - you.
  3. Follow this long tutorial to get Flask running. It was way more work than it should be: https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-uwsgi-and-nginx-on-ubuntu-16-04
    • wsgi.py is the entry point. It calls flash_cards.py
    • This is my systemd file /etc/systemd/system/flash_cards.service: view
      • you can see the paths where I installed it, and the name of my virtualenv directory
    • when done with tutorial:
    sudo systemctl restart flash_cards
    sudo systemctl daemon-reload
  4. When you see a login page, you're good to go.
  5. Log in.
  6. Click the "General" or "Code" button and make a card!
  7. When you're ready to start memorizing, click either "General" or "Code" in the top menu.

How to run it on local host (Quick Guide)

Provided by @devyash - [email protected] - Reach out to this contributor if you have trouble.

  1. Install dependencies:
    1. Install Python
    2. Add python as environment variable windows
    3. To install pip, securely download get-pip.py
    4. Run python get-pip.py in terminal
    5. Add pip to your PATH system variable windows
    6. Run pip install -r requirements.txt in terminal after going to correct folder
  2. Type python flash_cards.py - if you get error for flask then use python -m pip install Flask first then run flash_card.py file
  3. Open localhost:5000/
  4. Login using 'admin' and 'default' for the username and password, respectively.

NOTE: If you wish to use John's flash cards then also do following steps:

  1. Copy db files such as cards-jwasham-extreme OR cards-jwasham and paste them in db folder
  2. Edit file flash_cards.py line 8 and replace 'cards.db' with any of the other database files e.g.('cards-jwasham.db')
  3. Repeat the above steps from step 3

Every time you wish to run your db just open folder in terminal and run python flash_cards.py

How to run with Docker

Provided by @Tinpee - [email protected] - Reach out to this contributor if you have trouble.

Make sure you already installed docker and optionally docker-compose

  1. Clone project to any where you want and go to source folder.
  2. Edit the config.txt file. Change the secret key, username and password. The username and password will be the login for your site. There is only one user - you.
  3. Build image:
    • Docker: docker build . -t cs-flash-cards
    • Compose: docker-compose build
  4. Run container:
    • Docker: docker run -d -p 8000:8000 --name cs-flash-cards cs-flash-cards
    • Compose: docker-compose up
  5. Go your browser and type http://localhost:8000

If you already had a backup file cards.db. Run following command:

Note: We don't need to rebuild image, just delete old container if you already built.

docker run -d -p 8000:8000 --name cs-flash-cards -v <path_to_folder_contains_cards_db>:/src/db cs-flash-cards
  • <path_to_folder_contains_cards_db>: is the full path contains cards.db.
  • Example: /home/tinpee/cs-flash-cards/db, and cards.db is inside this folder.

For convenience, if you don't have cards.db, this container will auto copy a new one from cards-empty.db.


How to backup data ?

We just need store cards.db file, and don't need any sql command.

  • If you run container with -v <folder_db>:/src/db just go to folder_db and store cards.db anywhere you want.
  • Without -v flag. Type: docker cp <name_of_container>:/src/db/cards.db /path/to/save

How to restore data ?

  • Delete old container (not image): docker rm cs-flash-cards
  • Build a new one with -v flag: docker run -d -p 8000:8000 --name cs-flash-cards -v <path_to_folder_contains_cards_db>:/src/db cs-flash-cards
  • Voila :)

How to deploy docker file on heroku

- export CARDS_SETTINGS=/src/config.txt
gunicorn --bind  0.0.0.0:$8000 flash_cards:app
+ export CARDS_SETTINGS=/src/config.txt
gunicorn --bind  0.0.0.0:$PORT flash_cards:app
  • deploy docker file with following commands
heroku login
heroku container:login
heroku create
# Creating app... done, ⬢ your-app-name
heroku container:push web --app your-app-name
heroku container:release web --app your-app-name
heroku open --app your-app-name

Alternative for Node fans

@ashwanikumar04 put together an alternative flash cards site running Node: https://github.com/ashwanikumar04/flash-cards

Check out the demo!

Happy learning!

computer-science-flash-cards's People

Contributors

ahmadsherdar avatar dependabot[bot] avatar devyash avatar duongban avatar hofbi avatar jwasham avatar karta0807913 avatar kathu avatar linbingqiang avatar mun5424 avatar patilabhay679 avatar psnilesh avatar quincylarson avatar rashiq avatar romankondratiev avatar schneiderl avatar shivansh avatar sourabh3b avatar thasheelpk avatar toant13 avatar zevaverbach avatar zjyfdu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

computer-science-flash-cards's Issues

app moudle not found

There is a little mistake in wsgi.py.
app should be application. otherwise there is going to be an error.

from myproject import app as application
 
if __name__ == "__main__":
    application.run()
unable to load app 0 (mountpoint='') (callable not found or import error)

*** no app loaded. going in full dynamic mode ***

PYTHONPATH and Russian OS

I've met some problems to build and launch flash-cards project.

  1. If you are on Russian OS you mustn't add project to path which has a russian words.
  2. Instead PYTHONPATH you should use just PATH
    Primitives, but for starters could be useful

Any plans to make Flash cards easily printable?

First of all, thank you for a great tool. It is pretty useful :)

Are there any plans to Make the cards printable in a format such that, they can easily be converted into physical flash cards?

How to use your db?

I have changed database configuration like this:
app.config.update(dict( DATABASE=os.path.join(app.root_path, 'db', 'cards-jwasham.db'), SECRET_KEY='development key', USERNAME='admin', PASSWORD='default' ))
but I couldn't get you cards.

Using provided databases

This is presumably a very silly question but how can I use the cards that you have provided in the database cards-jwasham.db?

Is there a bit of code that I need to edit or dos it work out of the box?

For information, I am using the app locally via the python installation.

Thanks and cheers to you for the effort :)

Question on data

I was feeling a bit lazy to setup the web based flash card and since I'm used to Anki and I wanted to run away with your data set, I wrote a tiny py script to export the db to csv that I can import into Anki. Hope it's okay? Let me know. Thank you for your great resources.

Docker Image Launch Issue

Hi, I'm attempting to use the docker image. Everything successfully builds, but when I connect to localhost:8000, its says the site can't be reached. Any solutions? Thanks!

How to open this link?

This link that you have added for a brief rundown of the site is not working!
Shows this page:
screenshot 38
After clicking to View the Googley original here it goes to this page:
screenshot 37

Is there any other way to open it?
Cheers! 😄

Internal Server Error

Hi jwasham,

I followed your guide but I cant run the localhost. Could you mind helping me to fix this problem ?

image

Initial cards?

Hi,

Was inspired to go through your Google list and saw you added a reference to this project on my daily upstream merge :)

I was thinking maybe you can provide an SQLite dump of the cards that you created during studying? It would help from both the perspective of starting off quickly + cards that another person created are even more valuable to us, as you have no unconscious bias for creating cards you can answer easily.

Maybe we can take it even further and create a sharable database of cards where other people can add on the cards they created.

Previous Card functionality

This project is awesome. Could you please add a "Previous Card" button functionality, so that we can go back on the cards learnt.

SyntaxError in anki_data_builder.py?

First of all, you're an inspiration! Thanks for telling your story and for putting all your materials out there to help others.

Maybe you can help me with the data builder script. I'm probably doing something wrong here but when I run the data converter script on Windows, I get a syntax error:

c:\computer-science-flash-cards-master>python anki_data_builder.py ./cards-jwasham.db ./cards-jwasham.csv
  File "anki_data_builder.py", line 5
	<!DOCTYPE html>
	^
SyntaxError: invalid syntax

Getting these to use on my phone will be a godsend. Thanks again!

OperationalError: no such table: cards

I am trying to run it on localhost on my ubuntu cosmic 18.10 cosmic, i've gone through each step but on runtime, here is the error i encounter

python flash_cards.py

  • Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
    127.0.0.1 - - [16/May/2019 14:47:16] "GET /login HTTP/1.1" 200 -
    127.0.0.1 - - [16/May/2019 14:47:29] "POST /login HTTP/1.1" 302 -
    [2019-05-16 14:47:29,148] ERROR in app: Exception on /cards [GET]
    Traceback (most recent call last):
    File "/home/asim/Desktop/cards/CS-flash-cards/local/lib/python2.7/site-packages/flask/app.py", line 1982, in wsgi_app
    response = self.full_dispatch_request()
    File "/home/asim/Desktop/cards/CS-flash-cards/local/lib/python2.7/site-packages/flask/app.py", line 1614, in full_dispatch_request
    rv = self.handle_user_exception(e)
    File "/home/asim/Desktop/cards/CS-flash-cards/local/lib/python2.7/site-packages/flask/app.py", line 1517, in handle_user_exception
    reraise(exc_type, exc_value, tb)
    File "/home/asim/Desktop/cards/CS-flash-cards/local/lib/python2.7/site-packages/flask/app.py", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
    File "/home/asim/Desktop/cards/CS-flash-cards/local/lib/python2.7/site-packages/flask/app.py", line 1598, in dispatch_request
    return self.view_functionsrule.endpoint
    File "flash_cards.py", line 76, in cards
    cur = db.execute(query)
    OperationalError: no such table: cards
    127.0.0.1 - - [16/May/2019 14:47:29] "GET /cards HTTP/1.1" 500 -
    127.0.0.1 - - [16/May/2019 14:47:29] "GET /favicon.ico HTTP/1.1" 404 -

Running in docker container with backup file typo

In the section How to run with Docker, there's a typo in second part.
It's written (note: there's : written after -v flag, it shouldn't be there)

docker run -d -p 8000:8000 --name cs-flash-cards -v :<path_to_folder_contains_cards_db>:/src/db cs-flash-cards

It should be
docker run -d -p 8000:8000 --name cs-flash-cards -v <path_to_folder_contains_cards_db>:/src/db cs-flash-cards

Add a LICENSE

I noticed your project lacks a license specification. Is this intentional? Without a license, others are disallowed from using or modifying your project (see https://choosealicense.com/no-permission/). That is a shame, because I am a fan of your work and would like to use and extend it for my own purposes. Any thoughts on adding one (say, the MIT license)?

Flash cards app with hints support using nodejs

Hi,
Thanks for this very helpful repo to support budding programmers. I have taken the db which you have provided and created a simple node js based application with hints. If possible please link to the repo.
The repo is available here. Please let me know if you need any other info.

Thanks,
Ashwani

500 Internal Server Error after Logging In

After following the steps in thoroughly to setup the app (working nginx and uwsgi configs), the site is able to load the login page.
However on logging through the username and password previously changed in config.txt, the site returns a 500 Internal Server Error. on route (/cards)

/general
image

Though I am able to go back to the login route and can see that my login state is indeed true as shown by the updated navbar.
image

Still, all the links (/cards, /general, /code) give a 500 Internal Server Error.
Interestingly, the logout route still works and I am able to log out successfully.

image

Is there any issue with the memory allocated to this app or have I done something wrong? Kindly tell.
Thank you

Could not find a version that satisfies the requirement duplicity==0.7.6

Hello,

I am having a quick question. I am following "How to run it on local host (Quick Guide)", but while I am running "Run pip install -r requirements.txt in terminal after going to correct folder", I faced the following issue.
Actually, I ran like this.
pip install --upgrade -r C:\Users\\Documents\GitHub\flash-cards\requirements.txt

Could not find a version that satisfies the requirement duplicity==0.7.6 (from -r C:\Users\\Documents\GitHub\flash-cards\requirements.txt (line 6)) (from versions: )
No matching distribution found for duplicity==0.7.6 (from -r C:\Users\\Documents\GitHub\flash-cards\requirements.txt (line 6))

BTW, I am using Vizard 5.6-32bit toolkit.
http://www.worldviz.com/virtual-reality-software-downloads/

  1. installed Vizard.
  2. installed Flask, but pip is already installed in Vizard.
  3. Used the pip command bar in the Cmd tab to manually execute pip commands.
    (http://docs.worldviz.com/vizard/Package_Manager.htm)
    In the Cmd tab, I ran "install --upgrade -r C:\Users\\Documents\GitHub\flash-cards\requirements.txt"

Any advice would be really appreciated.
Thanks.

How to backup cards db from Docker?

For @tinpee
For those who use the Docker method, how can people find and backup their card db after making edits?

Since Docker containers are meant to be somewhat disposable, I always try to find a way to backup databases resident in containers. For example, my blog runs in a container, but I can ssh tunnel to the host, connect to the database, and use a MySQL tool to do a SQL dump.

Multi-threading issue

If uwsgi is configured with multi-threading and there are multiple databases, the lack of communication between the global variable namedb in the Flask program may cause errors.

username / password not same as config.txt when using docker

issue: The login page would not take my password in the config.txt file.

found workaround - used the user / password in the flash_cards.py file:
USERNAME='admin',
PASSWORD='default'

is there a way to have the config file work, or does the readme just need to be updated?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.