File size: 17,108 Bytes
a1983fb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
{
    "simple.py": "import sys\n\n# This is a sample Python file\n\ndef main():\n    print('Hello, world!')\n\nif __name__ == '__main__':\n    main()",
    "text_only.py": "# This file is empty and should test the chunker's ability to handle empty files\n",
    "routes.py": "from flask import Flask, jsonify, request, redirect, url_for\napp = Flask(__name__)\n\n@app.route('/', methods=['GET'])\ndef home():\n    return '<h1>Welcome to the Home Page</h1>', 200\n\n@authenticate  # Hypothetical decorator for authentication\n@log_access  # Hypothetical decorator for logging access\n@app.route('/api/data', methods=['GET'])\ndef get_data():\n    # Simulate fetching data from a database or external service\n    data = {'key': 'This is some data'}\n    return jsonify(data), 200\n\n@app.route('/api/data/<int:data_id>', methods=['GET'])\ndef get_data_by_id(data_id):\n    # Simulate fetching specific data by ID\n    data = {'id': data_id, 'value': 'Specific data based on ID'}\n    return jsonify(data), 200\n\n@app.route('/api/data', methods=['POST'])\ndef post_data():\n    data = request.json\n    # Simulate saving data to a database\n    return jsonify({'message': 'Data saved successfully', 'data': data}), 201\n\n@app.route('/api/data/<int:data_id>', methods=['PUT'])\ndef update_data(data_id):\n    data = request.json\n    # Simulate updating data in a database\n    return jsonify({'message': 'Data updated successfully', 'id': data_id, 'data': data}), 200\n\n@app.route('/api/data/<int:data_id>', methods=['DELETE'])\ndef delete_data(data_id):\n    # Simulate deleting data by ID\n    return jsonify({'message': 'Data deleted successfully', 'id': data_id}), 200\n\n@app.route('/redirect', methods=['GET'])\ndef example_redirect():\n    return redirect(url_for('home'))\n\nif __name__ == '__main__':\n    app.run(debug=True)",
    "models.py": "from sqlalchemy import Column, Integer, String, ForeignKey\nfrom sqlalchemy.ext.declarative import declarative_base\nfrom sqlalchemy.orm import relationship\n\nBase = declarative_base()\n\nclass User(Base):\n    __tablename__ = 'users'\n    id = Column(Integer, primary_key=True)\n    username = Column(String, unique=True, nullable=False)\n    email = Column(String, unique=True, nullable=False)\n\n    posts = relationship('Post', backref='author')\n\nclass Post(Base):\n    __tablename__ = 'posts'\n    id = Column(Integer, primary_key=True)\n    title = Column(String, nullable=False)\n    content = Column(String, nullable=False)\n    user_id = Column(Integer, ForeignKey('users.id'))",
    "big_class.py": "class BigClass:\n    def __init__(self, name, age):\n        self.name = name\n        self.age = age\n\n    def get_name(self):\n        return self.name\n\n    def get_age(self):\n        return self.age\n\n    def set_name(self, name):\n        self.name = name\n\n    def set_age(self, age):\n        self.age = age\n\n    def __str__(self):\n        return f'Name: {self.name}, Age: {self.age}'",
    "main.py": "from flask import Flask\nfrom routes import app as routes_app\n\n# Create the Flask application\napp = Flask(__name__)\n\n# Register the routes from the routes.py file\napp.register_blueprint(routes_app)\n\n# Configuration settings for the app can go here\napp.config['DEBUG'] = True\napp.config['SECRET_KEY'] = 'your_secret_key'\n\n# More complex app initialization steps can be added here\n# For example, database initialization, login manager setups, etc.\n\n# This function can be used to create a database schema\n def create_database(app):\n    if not path.exists('yourdatabase.db'):\n         db.create_all(app=app)\n         print('Created Database!')\n\nif __name__ == '__main__':\n    # Optionally, call database creation or other setup functions here\n    create_database(app)\n    app.run()",
    "utilities.py": "import hashlib\nimport uuid\nimport re\nfrom datetime import datetime, timedelta\n\n# Function to hash a password\ndef hash_password(password):\n    salt = uuid.uuid4().hex\n    return hashlib.sha256(salt.encode() + password.encode()).hexdigest() + ':' + salt\n\n# Function to check a hashed password\ndef check_password(hashed_password, user_password):\n    password, salt = hashed_password.split(':')\n    return password == hashlib.sha256(salt.encode() + user_password.encode()).hexdigest()\n\n# Function to validate an email address\ndef validate_email(email):\n    pattern = r\"^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+$\"\n    return re.match(pattern, email) is not None\n\n# Function to generate a token expiration date\ndef generate_expiration_date(days=1):\n    return datetime.now() + timedelta(days=days)\n\n# Function to convert a string to datetime\ndef string_to_datetime(date_string, format='%Y-%m-%d %H:%M:%S'):\n    return datetime.strptime(date_string, format)\n\n# Function to convert datetime to string\ndef datetime_to_string(date, format='%Y-%m-%d %H:%M:%S'):\n    return date.strftime(format)",
    "services.py": "import requests\nfrom flask_sqlalchemy import SQLAlchemy\n\n# Assuming an initialized Flask app with SQLAlchemy\ndb = SQLAlchemy()\n\n# Example of a model for database operations\nclass UserData(db.Model):\n    id = db.Column(db.Integer, primary_key=True)\n    name = db.Column(db.String(100), nullable=False)\n    email = db.Column(db.String(100), unique=True, nullable=False)\n\n    def __repr__(self):\n        return f'<User {self.name}>'\n\n# Function to fetch data from an external API\ndef fetch_external_data(api_url):\n    response = requests.get(api_url)\n    if response.status_code == 200:\n        return response.json()\n    else:\n        return {'error': 'Failed to fetch data'}\n\n# Function to save user data to the database\ndef save_user_data(name, email):\n    new_user = UserData(name=name, email=email)\n    db.session.add(new_user)\n    try:\n        db.session.commit()\n        return {'message': 'User saved successfully'}\n    except Exception as e:\n        db.session.rollback()\n        return {'error': str(e)}\n\n# Function to update user data in the database\ndef update_user_data(user_id, name=None, email=None):\n    user = UserData.query.get(user_id)\n    if not user:\n        return {'error': 'User not found'}\n    if name:\n        user.name = name\n    if email:\n        user.email = email\n    try:\n        db.session.commit()\n        return {'message': 'User updated successfully'}\n    except Exception as e:\n        db.session.rollback()\n        return {'error': str(e)}\n\n# Function to delete user data from the database\ndef delete_user_data(user_id):\n    user = UserData.query.get(user_id)\n    if not user:\n        return {'error': 'User not found'}\n    try:\n        db.session.delete(user)\n        db.session.commit()\n        return {'message': 'User deleted successfully'}\n    except Exception as e:\n        db.session.rollback()\n        return {'error': str(e)}",
    "simple.js": "// This is a sample JavaScript file\n\nfunction main() {\n  console.log('Hello, world!');\n}\n\nmain();",
    "text_only.js": "// This file is empty and should test the chunker's ability to handle empty files\n",
    "routes.js": "const express = require('express');\nconst router = express.Router();\n\n// Example of a simple route\nrouter.get('/', (req, res) => {\n  res.send('Welcome to the Home Page');\n});\n\n// Example of a route with a parameter\nrouter.get('/api/data/:data_id', (req, res) => {\n  const dataId = req.params.data_id;\n  res.json({ id: dataId, value: 'Specific data based on ID' });\n});\n\n// Example of a route that handles POST requests\nrouter.post('/api/data', (req, res) => {\n  const data = req.body;\n  res.status(201).json({ message: 'Data saved successfully', data: data });\n});\n\n// Example of a route that handles PUT requests\nrouter.put('/api/data/:data_id', (req, res) => {\n  const dataId = req.params.data_id;\n  const data = req.body;\n  res.json({ message: 'Data updated successfully', id: dataId, data: data });\n});\n\n// Example of a route that handles DELETE requests\nrouter.delete('/api/data/:data_id', (req, res) => {\n  const dataId = req.params.data_id;\n  res.json({ message: 'Data deleted successfully', id: dataId });\n});\n\nmodule.exports = router;",
    "models.js": "const mongoose = require('mongoose');\n\n// Example of a simple Mongoose model\nconst userSchema = new mongoose.Schema({\n  username: { type: String, required: true, unique: true },\n  email: { type: String, required: true, unique: true }\n});\n\nconst User = mongoose.model('User', userSchema);\n\nmodule.exports = User;",
    "big_class.js": "// This is a sample JavaScript class with a large number of methods\n\nclass BigClass {\n  constructor(name, age) {\n    this.name = name;\n    this.age = age;\n  }\n\n  getName() {\n    return this.name;\n  }\n\n  getAge() {\n    return this.age;\n  }\n\n  setName(name) {\n    this.name = name;\n  }\n\n  setAge(age) {\n    this.age = age;\n  }\n\n  toString() {\n    return `Name: ${this.name}, Age: ${this.age}`;\n  }\n}\n\nmodule.exports = BigClass;",
    "main.js": "const express = require('express');\nconst routes = require('./routes');\n\n// Create the Express application\nconst app = express();\n\n// Register the routes from the routes.js file\napp.use('/', routes);\n\n// Configuration settings for the app can go here\napp.set('port', process.env.PORT || 3000);\n\n// More complex app initialization steps can be added here\n// For example, database initialization, middleware setups, etc.\n\n// This function can be used to create a database schema\nfunction createDatabase() {\n  // Code to create database schema\n  console.log('Created Database!');\n}\n\n// Optionally, call database creation or other setup functions here\ncreateDatabase();\n\n// Start the server\napp.listen(app.get('port'), () => {\n  console.log(`Server running on port ${app.get('port')}`);\n});",
    "utilities.js": "// Example of utility functions for common tasks\n\n// Function to hash a password\nfunction hashPassword(password) {\n  const salt = uuidv4();\n  return sha256(salt + password) + ':' + salt;\n}\n\n// Function to check a hashed password\nfunction checkPassword(hashedPassword, userPassword) {\n  const [password, salt] = hashedPassword.split(':');\n  return sha256(salt + userPassword) === password;\n}\n\n// Function to validate an email address\nfunction validateEmail(email) {\n  const pattern = /^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+$/;\n  return pattern.test(email);\n}\n\n// Function to generate a token expiration date\nfunction generateExpirationDate(days = 1) {\n  const expirationDate = new Date();\n  expirationDate.setDate(expirationDate.getDate() + days);\n  return expirationDate;\n}\n\n// Function to convert a string to a Date object\nfunction stringToDate(dateString, format = 'YYYY-MM-DD HH:mm:ss') {\n  return new Date(dateString);\n}\n\n// Function to convert a Date object to a string\nfunction dateToString(date, format = 'YYYY-MM-DD HH:mm:ss') {\n  return date.toISOString();\n}",
    "services.js": "// Example of service functions for handling data operations\n\n// Function to fetch data from an external API\nasync function fetchExternalData(apiUrl) {\n  try {\n    const response = await fetch(apiUrl);\n    if (response.ok) {\n      return await response.json();\n    } else {\n      return { error: 'Failed to fetch data' };\n    }\n  } catch (error) {\n    return { error: error.message };\n  }\n}\n\n// Function to save user data to the database\nasync function saveUserData(name, email) {\n  try {\n    const newUser = new UserData({ name, email });\n    await newUser.save();\n    return { message: 'User saved successfully' };\n  } catch (error) {\n    return { error: error.message };\n  }\n}\n\n// Function to update user data in the database\nasync function updateUserData(userId, name, email) {\n  try {\n    const user = await UserData.findById(userId);\n    if (!user) {\n      return { error: 'User not found' };\n    }\n    if (name) {\n      user.name = name;\n    }\n    if (email) {\n      user.email = email;\n    }\n    await user.save();\n    return { message: 'User updated successfully' };\n  } catch (error) {\n    return { error: error.message };\n  }\n}\n\n// Function to delete user data from the database\nasync function deleteUserData(userId) {\n  try {\n    const user = await UserData.findById(userId);\n    if (!user) {\n      return { error: 'User not found' };\n    }\n    await user.remove();\n    return { message: 'User deleted successfully' };\n  } catch (error) {\n    return { error: error.message };\n  }\n}",
    "react_component.js": "import React from 'react';\n\nimport './SearchResults.css';\n\nimport TrackList from '../TrackList/TrackList.js';\n\n constructor(props) {\n        super(props);\n        this.addTopFive = this.addTopFive.bind(this);\n        this.addTopTen = this.addTopTen.bind(this);\n        this.addAll = this.addAll.bind(this);\n    }\n\n    //add the top five tracks to the playlist\n    addTopFive() {\n        this.props.onAdd(this.props.searchResults.slice(0, 5));\n    }\n\n    //add top 10 tracks to the playlist\n    addTopTen() {\n        this.props.onAdd(this.props.searchResults.slice(0, 10));\n    }\n\n    addAll() {\n        this.props.onAdd(this.props.searchResults);\n    }\n    render() {\n    return (\n      <div className=\"SearchResults\">\n        <h2>Results</h2>\n        <TrackList tracks={this.props.searchResults} onAdd={this.props.onAdd} onToggle={this.props.onToggle}  currentTrack={this.props.currentTrack}/>\n      </div>\n    );\n  }\n}\n\nexport default SearchResults;'",
    "simple_styles.css": "/* Example of CSS styles for a web page */\n\nbody {\n  font-family: Arial, sans-serif;\n  background-color: #f4f4f4;\n  margin: 0;\n  padding: 0;\n}\n\nh1 {\n  color: #333;\n  text-align: center;\n}\n\nbutton {\n  padding: 10px 20px;\n  font-size: 16px;\n  background-color: #007bff;\n  color: #fff;\n  border: none;\n  cursor: pointer;\n}\n\nbutton:hover {\n  background-color: #0056b3;\n}",
    "media_queries.css": "/* Example of CSS styles with media queries for responsive design */\n\nbody {\n  font-family: Arial, sans-serif;\n  background-color: #f4f4f4;\n  margin: 0;\n  padding: 0;\n}\n\nh1 {\n  color: #333;\n  text-align: center;\n}\n\nbutton {\n  padding: 10px 20px;\n  font-size: 16px;\n  background-color: #007bff;\n  color: #fff;\n  border: none;\n  cursor: pointer;\n}\n\nbutton:hover {\n  background-color: #0056b3;\n}\n\n/* Media query for smaller screens */\n@media (max-width: 768px) {\n  button {\n    padding: 8px 16px;\n    font-size: 14px;\n  }\n}",
    "single_syntax_error_example.py": "# This is a sample Python file\n\nprint('Hello, world!'\n\n",
    "multiple_syntax_errors.py": "def calculate_sum(lst):\n    total = 0\n    for num in lst\n        total += num\n    return total\n\nprint(calculate_sum([1, 2, 3, 4])\n\ndef string_manipulator(s):\n    new_string = ''\n    for char in s:\n        if char == 'a':\n        new_string += 'z'\n    else:\n        new_string += char\n    return new_string\n\nprint(string_manipulate('banana'))\n\ndef find_max(numbers):\n    max_num = numbers[0]\n    for num in numbers\n        if num > max_num\n            max_num = num\n    return max_num\n\nprint(find_max([1, 2, 3, 4, 5])",
    "single_syntax_error_example.js": "//This is a sample JavaScript file\n\nfunction main() {\n  console.log('Hello, world!');\n  if (true) {\n    console.log('hi');\n  \n}\n\nmain();",
    "multiple_syntax_errors.js": "function calculateSum(arr) {\n  let total = 0;\n  for (let i = 0; i < arr.length; i++ {\n    total += arr[i];\n  }\n  return total;\n}\n\nconsole.log(calculateSum([1, 2, 3, 4);\n\nfunction stringManipulator(str) {\n  let newString = '';\n  for (let i = 0; i < str.length; i++) {\n    if (str.charAt(i) === 'a')\n      newString += 'z';\n    } else {\n      newString += str.charAt(i);\n    }\n  }\n  return newString;\n}\n\nconsole.log(stringManipulator('banana'));\n\nfunction findMax(numbers) {\n  let maxNum = numbers[0];\n  for (let i = 1; i < numbers.length; i++) {\n    if (numbers[i] > maxNum) {\n      maxNum = numbers[i];\n    }\n  }\n  return maxNum;\n}\n\nconsole.log(findMax([1, 2, 3, 4, 5]);",
    "single_syntax_error_example.css": "\n\nbody {\n  font-family: Arial, sans-serif;\n  background-color: #f4f4f4;\n  margin: 0;\n  padding: 0;\n}\n\nh1 {\n  color: #333;\n  text-align: center;\n}\n\nbutton {\n  padding: 10px 20px;\n  font-size: 16px;\n  background-color: #007bff;\n  color: #fff;\n  border: none;\n  cursor: pointer;\n  :hover {\n  background-color: #0056b3;\n}\n",
    "multiple_syntax_errors.css": "body {\n  font-family: Arial, sans-serif;\n  background-color: #f4f4f4;\n  margin: 0;\n  padding: 0;\n}\n\nh1 {\n  color: #333;\n  text-align: center;\n}\n\nbutton {\n  padding: 10px 20px;\n  font-size: 16px;\n  background-color: #007bff;\n  color: #fff;\n  border: none;\n  cursor: pointer;\n  :hover {\n  background-color: #0056b3;\n}\n\n/* Media query for smaller screens */\n@media (max-width: 768px) {\n  button {\n    padding: 8px 16px;\n    font-size: 14px;\n  }\n}"
  }