Skip to content

Commit

Permalink
inital_commit
Browse files Browse the repository at this point in the history
  • Loading branch information
HasinZaman committed Feb 10, 2024
0 parents commit f3db2bb
Show file tree
Hide file tree
Showing 9 changed files with 217 additions and 0 deletions.
Binary file added algorithms/CS_Games_2024___Algorithms.pdf
Binary file not shown.
43 changes: 43 additions & 0 deletions low_level_api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Challenge 1: Low-Level API Development for Web Services

Task:
Create a TCP web server with extensive functionalities including cross-domain requests, web scraping, REST API integration, and multithreading for optimized performance.

**Restriction:**
All code must be written in C, C++, Rust, or Zig.

**Instructions:**

1. TCP Web Server:
- Implement a TCP-based web server using C, C++, Rust, or Zig, capable of handling HTTP requests.
- Ensure robustness and security measures to handle concurrent connections and mitigate common vulnerabilities.

2. Cross-Domain Requests:
- Enable cross-domain requests to facilitate seamless communication between client and server, adhering to CORS (Cross-Origin Resource Sharing) standards.

3. Web Scraping:
- Develop a web scraper to extract data from web pages, utilizing appropriate libraries or frameworks available in the chosen programming language.
- Design the scraper to handle dynamic content and follow robots.txt guidelines to respect website policies.

4. REST API Integration:
- Create a RESTful API with endpoints for starting and stopping the web scraping process, accepting input parameters such as the start URL.
- Implement error handling and validation to ensure data integrity and prevent misuse of API endpoints.

5. Scraping Statistics:
- Provide functionality to retrieve statistics on the scraping process, including the number of pages explored, queued, and a graphical representation of the page connections.
- Utilize data visualization techniques to present scraping statistics in an intuitive and informative manner.

6. Multithreading:
- Implement multithreading to parallelize the web scraping tasks, maximizing throughput and efficiency.
- Evaluate different multithreading architectures and choose the most suitable design for the given requirements, considering factors like resource utilization and scalability.

**Additional Considerations:**
- Prioritize code readability, maintainability, and adherence to best practices in software development.
- Document the implementation details, rationale behind design decisions, and usage instructions for future reference and collaboration.
- Conduct thorough testing to ensure the reliability and performance of the web server and associated functionalities across various scenarios and environments.

**Submission Guidelines:**
- Submit the source code along with any necessary instructions or documentation.

**Note:**
Ensure compliance with relevant legal and ethical considerations, including data privacy and intellectual property rights, when conducting web scraping activities.
Binary file added web_dev/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web_dev/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web_dev/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web_dev/4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions web_dev/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Problem 1: Centering a Div (Simple)

Task:
Achieve div centering using various techniques to demonstrate proficiency in layout methods.

**Instructions:**
Utilize CSS layout properties to center a div element through different methods. Avoid reliance on external resources. Consider employing techniques like flexbox, CSS Grid, or positioning. Provide comments within your code explaining the rationale behind each approach and any potential drawbacks.

# Problem 2: Website Development

Task:
Develop a website according to provided specifications to showcase your web development skills.

**Instructions:**

1. Homepage Creation:
- Design an appealing homepage displaying a list of books, adhering to responsive design principles for optimal viewing on diverse devices.
- Implement both dark mode and light mode themes, ensuring seamless transitions based on user browser preferences for enhanced user experience.
- Enhance user interaction with smooth page transitions using CSS animations or JavaScript libraries, considering loading times for a seamless browsing experience.
- Display a loading indicator until all data from the API is fetched.

![Desktop Homepage](1.png)
![Mobile Homepage](4.png)

2. Book Page:
- Develop a dedicated book page with advanced functionalities for improved user engagement.
- Enable users to highlight text passages within the book content, incorporating intuitive UI elements for easy text highlighting.
- Allow users to interact with highlighted text segments, including copying or modifying associated comments.
- Implement a filtering mechanism for users to search and display text passages containing specific keywords, optimizing for efficient performance.
- Ensure accessibility features such as keyboard navigation and screen reader compatibility are integrated.

**Additional Features:**
- Utilize responsive design principles to ensure dynamic adjustment across various screen sizes and orientations using media queries and fluid layout techniques.
- Improve website performance and user experience through resource optimization, minimizing HTTP requests, and leveraging caching mechanisms.
- Enhance visual effects and user interactions using advanced CSS techniques like transitions and transforms.
- Engage users with interactive elements such as animations or widgets for a more immersive browsing experience.
- Follow best practices for code organization, maintainability, and scalability, including modular CSS architecture and reusable JavaScript components. Ensure code readability and documentation for ease of maintenance and future updates.

![Desktop PDF](3.png)
![Mobile PDF](2.png)
2 changes: 2 additions & 0 deletions web_dev/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
flask
flask-cors
132 changes: 132 additions & 0 deletions web_dev/server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
from flask import Flask, jsonify, request
from flask_cors import CORS

app = Flask(__name__)
CORS(app)

books = [
{
'id': 1,
'publish': '2024-02-10',
'title': 'The Journey of Wisdom',
'author': 'John Doe',
'content': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed et suscipit nunc, eget consequat libero. Phasellus vel ullamcorper mauris, at gravida purus. Integer consequat, turpis nec accumsan ullamcorper, odio ante placerat elit, vitae consectetur justo neque a risus. Aliquam erat volutpat. Suspendisse potenti. Donec vel velit sem. Nulla facilisi.'
},
{
'id': 2,
'publish': '2021-12-12',
'title': 'Echoes of Eternity',
'author': 'Jane Smith',
'content': 'Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Fusce pretium pharetra libero eget viverra. Vivamus rhoncus, velit in fermentum faucibus, mi velit interdum enim, nec consequat ligula turpis id velit. Integer sed sapien erat. Nam aliquam efficitur magna, nec viverra est cursus ac.'
},
{
'id': 3,
'publish': '2023-05-20',
'title': 'Secrets Unveiled',
'author': 'Emily Johnson',
'content': 'Suspendisse potenti. In hac habitasse platea dictumst. Morbi congue auctor dui, sed tincidunt justo fringilla nec. Fusce sit amet odio id velit suscipit fermentum. Vestibulum eleifend, leo a convallis luctus, sapien lorem vestibulum quam, et rutrum lorem urna vel justo.'
},
{
'id': 4,
'publish': '2022-09-15',
'title': 'A Tale of Shadows',
'author': 'Michael Brown',
'content': 'Vestibulum sodales justo ligula, vel aliquet quam gravida a. Nulla facilisi. Integer elementum eros non nulla bibendum, ac vehicula odio efficitur. Quisque nec mauris eu nunc malesuada dapibus. In non nulla fermentum, vehicula nibh ut, bibendum dui. Mauris sagittis tincidunt arcu id euismod. In hac habitasse platea dictumst.'
},
{
'id': 5,
'publish': '2020-07-08',
'title': 'Whispers in the Wind',
'author': 'David Wilson',
'content': 'Cras ullamcorper eget nisi at consequat. Nullam vitae hendrerit ex. Sed vestibulum mauris ut dapibus ultricies. Mauris ut nulla et tortor fringilla interdum. Curabitur a risus non libero faucibus lacinia. Nullam quis efficitur mauris. Suspendisse potenti. Fusce ut est luctus, iaculis magna eu, lacinia elit.'
},
{
'id': 6,
'publish': '2023-10-25',
'title': 'Lost in Reflection',
'author': 'Sarah Taylor',
'content': 'Aliquam erat volutpat. Ut volutpat rutrum libero, vel aliquet arcu consequat nec. Vivamus id enim sit amet lacus posuere iaculis. Suspendisse vel odio et odio aliquam dapibus. Proin malesuada arcu eget fermentum vehicula. In nec odio nisi. Cras id nunc hendrerit, volutpat velit at, efficitur nisl.'
}
]

highlight_text = {
1: [{
"range": (10, 30),
"comment": "Captivating introduction"
}],
2: [{
"range": (50, 80),
"comment": "Intriguing plot twist"
}],
3: [{
"range": (20, 45),
"comment": "Emotional climax"
}],
4: [{
"range": (5, 25),
"comment": "Suspenseful build-up"
}],
5: [{
"range": (40, 60),
"comment": "Heartwarming resolution"
}],
6: [{
"range": (15, 35),
"comment": "Unexpected revelation"
}]
}

# Homepage route to get list of books
@app.route('/books', methods=['GET'])
def get_books():
return jsonify(books)

# Book page route to get details of a specific book
@app.route('/books/<int:book_id>', methods=['GET'])
def get_book(book_id):
for book in books:
if book['id'] == book_id:
return jsonify(book)
return jsonify({'message': 'Book not found'}), 404

# Route to handle text highlighting and editing comments
@app.route('/books/<int:book_id>/highlight', methods=['GET'])
def get_highlight_text(book_id):
if not int(book_id) in highlight_text:
return jsonify({'message': 'Book not found'}), 404

data = highlight_text[book_id]

return jsonify(data)

@app.route('/books/<int:book_id>/highlight/append', methods=['POST'])
def append_highlight_text(book_id):
if not book_id in highlight_text:
return jsonify({'message': 'Book not found'}), 404


data = highlight_text[book_id]

range = (int(request.args.get('range_start')), int(request.args.get('range_end')))
comment = request.args.get('comment')

data = highlight_text[book_id]

data.append({"range": range, "comment": comment})
return jsonify(data), 200

# Route to handle text filtering
@app.route('/books/filter', methods=['GET'])
def filter_books():
keyword = request.args.get('keyword')
keyword = keyword.lower()
filtered_books = [
book for book in books if
keyword in book['content'].lower() or
keyword in book['author'].lower() or
keyword in book['title'].lower()
]
return jsonify(filtered_books)

if __name__ == '__main__':
app.run(debug=True)

0 comments on commit f3db2bb

Please sign in to comment.