mirror of
https://github.com/AmanTahiliani/PeerNotes.git
synced 2026-08-07 11:55:12 -04:00
Added Migration for Topics and Some dummy notes files
This commit is contained in:
BIN
DummyFiles/CN-SDN.pdf
Normal file
BIN
DummyFiles/CN-SDN.pdf
Normal file
Binary file not shown.
BIN
DummyFiles/GradAlgoNotes.pdf
Normal file
BIN
DummyFiles/GradAlgoNotes.pdf
Normal file
Binary file not shown.
BIN
DummyFiles/IntroToMachineLearning.pdf
Normal file
BIN
DummyFiles/IntroToMachineLearning.pdf
Normal file
Binary file not shown.
156
backend/api/migrations/0012_auto_20240422_1349.py
Normal file
156
backend/api/migrations/0012_auto_20240422_1349.py
Normal file
@@ -0,0 +1,156 @@
|
||||
# Generated by Django 4.2.11 on 2024-04-22 13:49
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def load_data_from_json(apps, schema_editor):
|
||||
topics = [
|
||||
"Introduction to Computer Science",
|
||||
"Programming Fundamentals",
|
||||
"Data Structures",
|
||||
"Algorithms",
|
||||
"Computer Architecture",
|
||||
"Operating Systems",
|
||||
"Database Systems",
|
||||
"Networking",
|
||||
"Software Engineering",
|
||||
"Artificial Intelligence",
|
||||
"Theory of Computation",
|
||||
"Compiler Design",
|
||||
"Distributed Systems",
|
||||
"Computer Graphics",
|
||||
"Cryptography",
|
||||
"Parallel and Concurrent Programming",
|
||||
"Human-Computer Interaction",
|
||||
"Computer Vision",
|
||||
"Web Technologies",
|
||||
"Embedded Systems",
|
||||
"Data Mining and Analytics",
|
||||
"Software Quality Assurance",
|
||||
"Ethical and Social Implications of Computing",
|
||||
"Advanced Topics",
|
||||
"Automata Theory",
|
||||
"Formal Languages and Automata",
|
||||
"Computational Complexity",
|
||||
"Graph Theory",
|
||||
"Computational Geometry",
|
||||
"Numerical Analysis",
|
||||
"Machine Learning",
|
||||
"Deep Learning",
|
||||
"Natural Language Processing",
|
||||
"Reinforcement Learning",
|
||||
"Computer Security",
|
||||
"Network Security",
|
||||
"Information Retrieval",
|
||||
"Cloud Computing",
|
||||
"IoT (Internet of Things)",
|
||||
"Virtual Reality",
|
||||
"Augmented Reality",
|
||||
"Mobile Application Development",
|
||||
"Game Development",
|
||||
"Computer Animation",
|
||||
"Operating System Design",
|
||||
"Real-Time Systems",
|
||||
"Concurrency Control",
|
||||
"Transaction Processing",
|
||||
"Data Warehousing",
|
||||
"Big Data Technologies",
|
||||
"Data Science",
|
||||
"Business Intelligence",
|
||||
"Quantum Computing",
|
||||
"Bioinformatics",
|
||||
"Computational Biology",
|
||||
"Robotics",
|
||||
"Computer Ethics",
|
||||
"Privacy and Security in Computing",
|
||||
"Digital Forensics",
|
||||
"Cryptocurrency and Blockchain",
|
||||
"Social Network Analysis",
|
||||
"Cloud Security",
|
||||
"Edge Computing",
|
||||
"Compiler Optimization",
|
||||
"High-Performance Computing",
|
||||
"Grid Computing",
|
||||
"Fuzzy Logic and Systems",
|
||||
"Expert Systems",
|
||||
"Pattern Recognition",
|
||||
"Knowledge Representation and Reasoning",
|
||||
"Semantic Web",
|
||||
"Computer Algebra Systems",
|
||||
"Geographic Information Systems",
|
||||
"Wireless Sensor Networks",
|
||||
"Biometric Authentication",
|
||||
"Internet Security Protocols",
|
||||
"Software Testing and Debugging",
|
||||
"Agile Methodologies",
|
||||
"DevOps",
|
||||
"Continuous Integration and Continuous Deployment (CI/CD)",
|
||||
"Model-Driven Engineering",
|
||||
"User Interface Design",
|
||||
"Accessibility in Computing",
|
||||
"User Experience (UX) Design",
|
||||
"Game Theory",
|
||||
"Social Computing",
|
||||
"Computational Sociology",
|
||||
"Computational Linguistics",
|
||||
"Music Information Retrieval",
|
||||
"Ethics in Artificial Intelligence",
|
||||
"Algorithmic Game Theory",
|
||||
"Behavioral Economics and Computing",
|
||||
"Neuroinformatics",
|
||||
"Health Informatics",
|
||||
"Geometric Modeling",
|
||||
"Scientific Computing",
|
||||
"Information Theory",
|
||||
"System Modeling and Simulation",
|
||||
"Decision Support Systems",
|
||||
"Database Security and Privacy",
|
||||
"Knowledge Management Systems",
|
||||
"Information Visualization",
|
||||
"Geospatial Data Analysis",
|
||||
"Enterprise Architecture",
|
||||
"Supply Chain Management Systems",
|
||||
"Data Integration and Interoperability",
|
||||
"Software Reuse and Component-Based Development",
|
||||
"Legal and Regulatory Issues in Computing",
|
||||
"Information Assurance",
|
||||
"Systems Analysis and Design",
|
||||
"E-commerce Systems",
|
||||
"E-learning Systems",
|
||||
"Human-Robot Interaction",
|
||||
"Biologically Inspired Computing",
|
||||
"Social Robotics",
|
||||
"Humanoid Robotics",
|
||||
"Computational Neuroscience",
|
||||
"Affective Computing",
|
||||
"Explainable AI",
|
||||
"Robot Ethics",
|
||||
"Cyber-Physical Systems",
|
||||
"Internet of Medical Things (IoMT)",
|
||||
"Quantum Information Science",
|
||||
"Quantum Cryptography",
|
||||
"Quantum Algorithms",
|
||||
"Quantum Machine Learning",
|
||||
"Quantum Error Correction",
|
||||
"Quantum Networking"
|
||||
]
|
||||
|
||||
Topic = apps.get_model("api", "Topic")
|
||||
Topic.objects.all().delete()
|
||||
for topic in topics:
|
||||
try:
|
||||
Topic.objects.create(
|
||||
name=topic,
|
||||
)
|
||||
except Exception as e:
|
||||
print("Error:", str(e))
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("api", "0011_auto_20240421_0406"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(load_data_from_json),
|
||||
]
|
||||
@@ -1 +0,0 @@
|
||||
Hello Hi Test
|
||||
@@ -1,45 +0,0 @@
|
||||
|
||||
const SimplePeer = require('simple-peer');
|
||||
|
||||
// Function to act as the file host
|
||||
function hostFile() {
|
||||
const peer = new SimplePeer({ initiator: true });
|
||||
|
||||
peer.on('signal', data => {
|
||||
console.log('Share this data with the peer who wants to download the file:');
|
||||
console.log(JSON.stringify(data));
|
||||
});
|
||||
|
||||
peer.on('connect', () => {
|
||||
console.log('Peer connected. Sending file...');
|
||||
const fileContent = 'This is the content of the file.';
|
||||
peer.send(fileContent);
|
||||
});
|
||||
}
|
||||
|
||||
// Function to act as the file requester
|
||||
function requestFile() {
|
||||
const peer = new SimplePeer();
|
||||
|
||||
peer.on('signal', data => {
|
||||
console.log('Share this data with the file host:');
|
||||
console.log(JSON.stringify(data));
|
||||
});
|
||||
|
||||
peer.on('connect', () => {
|
||||
console.log('Peer connected. Waiting for file...');
|
||||
});
|
||||
|
||||
peer.on('data', data => {
|
||||
console.log(`File received: ${data}`);
|
||||
});
|
||||
}
|
||||
|
||||
// Decide whether to host the file or request it
|
||||
const isHost = process.argv[2] === 'host';
|
||||
|
||||
if (isHost) {
|
||||
hostFile();
|
||||
} else {
|
||||
requestFile();
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
// // Requester Peer
|
||||
|
||||
// const net = require('net');
|
||||
|
||||
// // IP address and port of the other peer
|
||||
// const otherPeerIP = 'other_peer_ip_address';
|
||||
// const otherPeerPort = 12345; // Assuming this is the port the other peer is listening on
|
||||
|
||||
// // File ID to request
|
||||
// const fileId = 'file123';
|
||||
|
||||
// // Create a TCP socket to connect to the other peer
|
||||
// const client = new net.Socket();
|
||||
|
||||
// client.connect(otherPeerPort, otherPeerIP, () => {
|
||||
// console.log('Connected to peer');
|
||||
|
||||
// // Send the file ID as a request
|
||||
// client.write(fileId);
|
||||
// });
|
||||
|
||||
// // Listen for data (the requested file) from the other peer
|
||||
// client.on('data', (data) => {
|
||||
// console.log('Received file:', data.toString());
|
||||
|
||||
// // Close the connection after receiving the file
|
||||
// client.end();
|
||||
// });
|
||||
|
||||
// // Handle connection errors
|
||||
// client.on('error', (err) => {
|
||||
// console.error('Connection error:', err);
|
||||
// });
|
||||
|
||||
|
||||
// Requester Peer
|
||||
|
||||
// const net = require('net');
|
||||
|
||||
// // IP address and port of the other peer
|
||||
// const otherPeerIP = '127.0.0.1'; // Assuming both peers are running on the same machine
|
||||
// const otherPeerPort = 12345;
|
||||
|
||||
// File ID to request
|
||||
const fileId = 'abcd.txt';
|
||||
|
||||
// Create a TCP server to handle incoming requests from the other peer
|
||||
|
||||
|
||||
// Requester Peer
|
||||
|
||||
const net = require('net');
|
||||
|
||||
// IP address and port of the receiving peer
|
||||
const receiverIP = '127.0.0.1'; // Assuming both peers are running on the same machine
|
||||
const receiverPort = 12345;
|
||||
|
||||
// File ID to request
|
||||
// const fileId = 'file123';
|
||||
|
||||
// Create a TCP client to connect to the receiving peer server
|
||||
const client = new net.Socket();
|
||||
|
||||
// Handle connection to the receiving peer
|
||||
client.connect(receiverPort, receiverIP, () => {
|
||||
console.log('Connected to receiving peer server');
|
||||
|
||||
// Send the file ID as a request to the receiving peer
|
||||
client.write(fileId);
|
||||
});
|
||||
|
||||
// Listen for data (the requested file) from the receiving peer
|
||||
client.on('data', (data) => {
|
||||
console.log('Received file:', data.toString());
|
||||
|
||||
// Close the connection after receiving the file
|
||||
client.end();
|
||||
});
|
||||
|
||||
// Handle connection errors
|
||||
client.on('error', (err) => {
|
||||
console.error('Connection error:', err);
|
||||
});
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
// // Receiving Peer
|
||||
|
||||
// const net = require('net');
|
||||
// const fs = require('fs');
|
||||
|
||||
// // Port on which this peer will listen for requests
|
||||
// const listenPort = 12345;
|
||||
|
||||
// // Mapping of file IDs to file paths
|
||||
// const filesMap = {
|
||||
// 'file123': '/path/to/file.txt',
|
||||
// // Add more file IDs and corresponding file paths as needed
|
||||
// };
|
||||
|
||||
// // Create a server to listen for incoming requests
|
||||
// const server = net.createServer((socket) => {
|
||||
// console.log('Peer connected');
|
||||
|
||||
// // Handle data (file ID) received from the requester peer
|
||||
// socket.on('data', (data) => {
|
||||
// const fileId = data.toString();
|
||||
// console.log('Received request for file ID:', fileId);
|
||||
|
||||
// // Look up the file path based on the file ID
|
||||
// const filePath = filesMap[fileId];
|
||||
|
||||
// if (filePath) {
|
||||
// // Read the file and send its contents back to the requester
|
||||
// fs.readFile(filePath, (err, fileData) => {
|
||||
// if (err) {
|
||||
// console.error('Error reading file:', err);
|
||||
// socket.end();
|
||||
// return;
|
||||
// }
|
||||
|
||||
// // Send the file data to the requester
|
||||
// socket.write(fileData);
|
||||
|
||||
// // Close the connection after sending the file
|
||||
// socket.end();
|
||||
// });
|
||||
// } else {
|
||||
// console.log('File ID not found');
|
||||
// socket.end();
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
|
||||
// // Start listening for incoming connections
|
||||
// server.listen(listenPort, () => {
|
||||
// console.log('Peer server listening on port', listenPort);
|
||||
// });
|
||||
|
||||
// // Handle server errors
|
||||
// server.on('error', (err) => {
|
||||
// console.error('Server error:', err);
|
||||
// });
|
||||
|
||||
|
||||
// Receiving Peer
|
||||
|
||||
const net = require('net');
|
||||
const fs = require('fs');
|
||||
|
||||
// Port on which this peer will listen for requests
|
||||
const listenPort = 12345;
|
||||
|
||||
// Mapping of file IDs to file paths
|
||||
const filesMap = {
|
||||
'abcd.txt': './abcd.txt',
|
||||
// Add more file IDs and corresponding file paths as needed
|
||||
};
|
||||
|
||||
// Create a TCP server to listen for incoming requests from other peers
|
||||
const server = net.createServer((socket) => {
|
||||
console.log('Receiving peer server connected');
|
||||
|
||||
// Handle data (file ID) received from the requester peer
|
||||
socket.on('data', (data) => {
|
||||
const fileId = data.toString();
|
||||
console.log('Received request for file ID:', fileId);
|
||||
|
||||
// Look up the file path based on the file ID
|
||||
const filePath = filesMap[fileId];
|
||||
|
||||
if (filePath) {
|
||||
// Read the file and send its contents back to the requester
|
||||
fs.readFile(filePath, (err, fileData) => {
|
||||
if (err) {
|
||||
console.error('Error reading file:', err);
|
||||
socket.end();
|
||||
return;
|
||||
}
|
||||
|
||||
// Send the file data to the requester
|
||||
socket.write(fileData);
|
||||
|
||||
// Close the connection after sending the file
|
||||
socket.end();
|
||||
});
|
||||
} else {
|
||||
console.log('File ID not found');
|
||||
socket.end();
|
||||
}
|
||||
});
|
||||
|
||||
// Handle connection errors
|
||||
socket.on('error', (err) => {
|
||||
console.error('Connection error:', err);
|
||||
});
|
||||
});
|
||||
|
||||
// Start the server
|
||||
server.listen(listenPort, () => {
|
||||
console.log('Receiving peer server listening for incoming connections');
|
||||
});
|
||||
|
||||
// Handle server errors
|
||||
server.on('error', (err) => {
|
||||
console.error('Server error:', err);
|
||||
});
|
||||
Reference in New Issue
Block a user