├── Readme.md └── week-0 ├── day-1 ├── description.txt ├── photos │ ├── 2001-03-19.png │ ├── 2001-05-19.png │ ├── 2017-05-19.png │ ├── 2017-07-19.png │ ├── 2018-05-19.png │ ├── 2019-03-19.png │ └── 2019-05-19.png ├── segregate_photos.sh └── sleepy.sh └── day-3 ├── my_todo_app ├── .gitignore └── todo_app │ ├── __init__.py │ ├── __init__.pyc │ ├── __pycache__ │ └── __init__.cpython-36.pyc │ └── templates │ ├── 404.html │ └── todo_view.html └── setup.sh /Readme.md: -------------------------------------------------------------------------------- 1 | ## Welcome to InterviewBit Academy 2 | 3 | # Day 1 covers: (Find these inside week-0/day-1) 4 | * Bash 5 | * `segregate_photos.sh`: Segregate photos by years. Run this: `cd week-0/day-1/photos` and then run script like this: `bash ../segregate_photos.sh` 6 | * `sleepy.sh`: Play music for 15 mins and then turn off music. Run like this: `bash sleepy.sh` 7 | * Good resource for starting out with bash: https://linuxconfig.org/bash-scripting-tutorial-for-beginners 8 | * Git 9 | * `git init`: Initialize a git repository on local. 10 | * `git add filename`: Add a file to track it using git. 11 | * `git commit`: Create new version of your project. 12 | * `git push origin master`: Push your updated local code on remote git server, i.e Github in our case. 13 | * `git clone https://github.com/interviewbit-academy/academy-hackathon`: Clone a remote repository in your local machine. 14 | * Good resource to learn about git: https://www.atlassian.com/git/tutorials/what-is-version-control 15 | 16 | # Day 1 Assignment: 17 | Download Dark Knight HD wallpapers using bash script from this URL: https://wallpapercave.com/dark-knight-hd-wallpaper 18 | 19 | ### Steps: 20 | * Go to this URL: https://github.com/interviewbit-academy/academy-hackathon 21 | * Fork the repository. There is a fork button in top right 22 | * Clone the forked repo. Example: `git clone https://github.com/shivtej1505/academy-hackathon`. This will copy the codebase to your local filesystem 23 | * Add you script under day-1 in week-0. Do `git add your_script.sh` and `git commit -m "some commit message"` 24 | * Second last step is pushing it on remote git server i.e Github. Use this command: `git push origin master` 25 | * Final step is too make a Pull Request here: https://github.com/shivtej1505/academy-hackathon 26 | 27 | # Day 2 covers: (Find these inside week-0/day-2) 28 | * Git - few more important flows 29 | * Git recap: Checkout archived video for the example. 30 | * Branching and merging in git. How to make a pull request and review? 31 | * MVC using Flask as framework 32 | * What is virtual environment? 33 | * How data flows from server to client? 34 | * What is model, view & controller? 35 | 36 | # Day 3 covers: (Find these inside week-0/day-3) 37 | * MVC using Flask 38 | * CRUD 39 | * APIs 40 | 41 | # Day 3 Class Assignment: 42 | Implement a ToDo app in Flask. 43 | 44 | ### Steps: 45 | 1. Go to this URL: https://github.com/interviewbit-academy/academy-hackathon 46 | 2. Fork the repository. There is a fork button in top right 47 | 3. Clone the forked repo. Example: `git clone https://github.com/shivtej1505/academy-hackathon`. This will copy the codebase to your local filesystem. 48 | 4. Go to day-3 in week-0. Run this command: `source setup.sh`. This will setup virtual environment and install flask. 49 | 5. Create a new branch: `git checkout -b YOUR_BRANCH_NAME` 50 | 5. Implement the basic page. Add you files in git. Commit you code and push using this command: `git push origin YOUR_BRANCH_NAME` 51 | 6. Go to your forked repo. Make a pull request in master from the branch YOUR_BRANCH_NAME. 52 | 7. Review your pull request. Merge it if it looks good. Repeat from step 5 until your project is finished. 53 | 54 | 55 | # Day 3 Homework: 56 | * Again go through Flask Tutorial(http://flask.pocoo.org/docs/1.0/tutorial/) with the knowledge of MVC. 57 | * Complete the ToDo App: 58 | * Connect Model with the DB. 59 | * Write view in separate file. 60 | * Add another parameter in URL `num`, which indicate how many todos a user want to view. 61 | * Make a pull request in original repository with screenshots. 62 | -------------------------------------------------------------------------------- /week-0/day-1/description.txt: -------------------------------------------------------------------------------- 1 | Day 1 of Hackathon. 2 | We will cover: 3 | 1. Git 4 | 2. Bash 5 | -------------------------------------------------------------------------------- /week-0/day-1/photos/2001-03-19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/interviewbit-academy/academy-hackathon/5fdd85a487950187e1344f9d1c15c7117c45a612/week-0/day-1/photos/2001-03-19.png -------------------------------------------------------------------------------- /week-0/day-1/photos/2001-05-19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/interviewbit-academy/academy-hackathon/5fdd85a487950187e1344f9d1c15c7117c45a612/week-0/day-1/photos/2001-05-19.png -------------------------------------------------------------------------------- /week-0/day-1/photos/2017-05-19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/interviewbit-academy/academy-hackathon/5fdd85a487950187e1344f9d1c15c7117c45a612/week-0/day-1/photos/2017-05-19.png -------------------------------------------------------------------------------- /week-0/day-1/photos/2017-07-19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/interviewbit-academy/academy-hackathon/5fdd85a487950187e1344f9d1c15c7117c45a612/week-0/day-1/photos/2017-07-19.png -------------------------------------------------------------------------------- /week-0/day-1/photos/2018-05-19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/interviewbit-academy/academy-hackathon/5fdd85a487950187e1344f9d1c15c7117c45a612/week-0/day-1/photos/2018-05-19.png -------------------------------------------------------------------------------- /week-0/day-1/photos/2019-03-19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/interviewbit-academy/academy-hackathon/5fdd85a487950187e1344f9d1c15c7117c45a612/week-0/day-1/photos/2019-03-19.png -------------------------------------------------------------------------------- /week-0/day-1/photos/2019-05-19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/interviewbit-academy/academy-hackathon/5fdd85a487950187e1344f9d1c15c7117c45a612/week-0/day-1/photos/2019-05-19.png -------------------------------------------------------------------------------- /week-0/day-1/segregate_photos.sh: -------------------------------------------------------------------------------- 1 | # parse all the years in which I have taken photos 2 | years=$(for i in `ls`; do echo "$i" | cut -d '-' -f 1; done) 3 | echo $years 4 | 5 | # loop through all years and make respective directories 6 | for year in `echo $years`; 7 | do 8 | mkdir $year; 9 | done 10 | 11 | # loop through all png images and moving them in respective directory 12 | for img in `ls *.png`; 13 | do 14 | # figure out target directory from filename 15 | year=`echo $img | cut -d '-' -f 1` 16 | mv $img $year/ 17 | done 18 | 19 | # double check if everything works 20 | for year in `echo $years | uniq`; 21 | do 22 | echo "Photos I took in $year:" 23 | ls -l $year 24 | done 25 | -------------------------------------------------------------------------------- /week-0/day-1/sleepy.sh: -------------------------------------------------------------------------------- 1 | open -a "Google Chrome" https://www.youtube.com/watch?v=nkqVm5aiC28&list=RDnkqVm5aiC28 2 | sleep 15 3 | echo "I will now shut down" 4 | # command to shut down laptop 5 | -------------------------------------------------------------------------------- /week-0/day-3/my_todo_app/.gitignore: -------------------------------------------------------------------------------- 1 | venv 2 | venv/* 3 | -------------------------------------------------------------------------------- /week-0/day-3/my_todo_app/todo_app/__init__.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | from flask import Flask 4 | from flask import request 5 | 6 | from flask import render_template 7 | 8 | # our fake db 9 | todo_store = {} 10 | todo_store['depo'] = ['Go for run', 'Listen Rock Music'] 11 | todo_store['shivang'] = ['Read book', 'Play Fifa', 'Drink Coffee'] 12 | todo_store['raj'] = ['Study', 'Brush'] 13 | todo_store['sanket'] = ['Sleep', 'Code'] 14 | todo_store['aagam'] = ['play cricket', 'have tea'] 15 | 16 | def create_app(test_config=None): 17 | # create and configure the app 18 | app = Flask(__name__, instance_relative_config=True) 19 | 20 | # ensure the instance folder exists 21 | try: 22 | os.makedirs(app.instance_path) 23 | except OSError: 24 | pass 25 | 26 | def select_todos(name): 27 | global todo_store 28 | return todo_store[name] 29 | 30 | def insert_todo(name, todo): 31 | global todo_store 32 | current_todos = todo_store[name] 33 | current_todos.append(todo) 34 | todo_store[name] = current_todos 35 | return 36 | 37 | def add_todo_by_name(name, todo): 38 | # call DB function 39 | insert_todo(name, todo) 40 | return 41 | 42 | def get_todos_by_name(name): 43 | try: 44 | return select_todos(name) 45 | except: 46 | return None 47 | 48 | 49 | # http://127.0.0.1:5000/todos?name=duster 50 | @app.route('/todos') 51 | def todos(): 52 | name = request.args.get('name') 53 | print('---------') 54 | print(name) 55 | print('---------') 56 | 57 | person_todo_list = get_todos_by_name(name) 58 | if person_todo_list == None: 59 | return render_template('404.html'), 404 60 | else: 61 | return render_template('todo_view.html',todos=person_todo_list) 62 | 63 | 64 | @app.route('/add_todos') 65 | def add_todos(): 66 | name = request.args.get('name') 67 | todo = request.args.get('todo') 68 | add_todo_by_name(name, todo) 69 | return 'Added Successfully' 70 | 71 | return app 72 | 73 | -------------------------------------------------------------------------------- /week-0/day-3/my_todo_app/todo_app/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/interviewbit-academy/academy-hackathon/5fdd85a487950187e1344f9d1c15c7117c45a612/week-0/day-3/my_todo_app/todo_app/__init__.pyc -------------------------------------------------------------------------------- /week-0/day-3/my_todo_app/todo_app/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/interviewbit-academy/academy-hackathon/5fdd85a487950187e1344f9d1c15c7117c45a612/week-0/day-3/my_todo_app/todo_app/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /week-0/day-3/my_todo_app/todo_app/templates/404.html: -------------------------------------------------------------------------------- 1 |

404

2 |

Record not found

3 | -------------------------------------------------------------------------------- /week-0/day-3/my_todo_app/todo_app/templates/todo_view.html: -------------------------------------------------------------------------------- 1 | List of my todos:
2 | 3 | {% for todo in todos %} 4 | {{todo}}
5 | {% endfor %} 6 | 7 | ---- LIST ENDS HERE --- 8 | -------------------------------------------------------------------------------- /week-0/day-3/setup.sh: -------------------------------------------------------------------------------- 1 | # create project directory 2 | echo "creating project directory" 3 | mkdir my_todo_app 4 | cd my_todo_app 5 | 6 | # we are using python 3 7 | # setup python virtual environment 8 | echo "setting up virtual environment" 9 | python3 -m venv venv 10 | 11 | 12 | # activate virtual environment 13 | echo "activating virtual environment" 14 | . venv/bin/activate 15 | 16 | echo "virtual environment created successfully" 17 | 18 | # install Flask 19 | echo "install flask" 20 | pip install Flask 21 | 22 | echo "--- Flask Installed Successfully ---" 23 | 24 | echo "create a flask app" 25 | # make an flask app 26 | mkdir todo_app 27 | 28 | cd todo_app 29 | 30 | touch __init__.py # __init__.py is just like main function in c/c++ program 31 | 32 | # adding file content 33 | echo "adding minimal code to run flask app" 34 | cat > __init__.py << SERVER_SCRIPT 35 | import os 36 | 37 | from flask import Flask 38 | 39 | 40 | def create_app(test_config=None): 41 | # create and configure the app 42 | app = Flask(__name__, instance_relative_config=True) 43 | 44 | # ensure the instance folder exists 45 | try: 46 | os.makedirs(app.instance_path) 47 | except OSError: 48 | pass 49 | 50 | # a simple page that list my todos 51 | @app.route('/shivang') 52 | def shivang(): 53 | return ('Wake Up' + '
' + 54 | 'Drink Coffee' + '
' + 55 | 'Read Non-fiction Novel' + '
' 56 | ) 57 | 58 | return app 59 | 60 | SERVER_SCRIPT 61 | 62 | # going back to parent directory 63 | cd ../ 64 | 65 | # setting up some environment variables 66 | echo "setting up few environment variables" 67 | export FLASK_APP=todo_app 68 | export FLASK_ENV=development 69 | 70 | # command to deactivate virtual environment 71 | #deactivate 72 | --------------------------------------------------------------------------------