Skip to content

Commit

Permalink
purged commits
Browse files Browse the repository at this point in the history
  • Loading branch information
1ikeadragon committed Jul 21, 2024
0 parents commit 8fb3e9b
Show file tree
Hide file tree
Showing 49 changed files with 2,182 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.idea/
.mvn/
.vscode/
src/frontend/editor/node_modules
target/
.DS_Store
src/frontend/editor/package-lock.json
15 changes: 15 additions & 0 deletions CollabCode.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4">
<component name="FacetManager">
<facet type="jpa" name="JPA">
<configuration>
<setting name="validation-enabled" value="true" />
<setting name="provider-name" value="Hibernate" />
<datasource-mapping>
<factory-entry name="entityManagerFactory" value="e29b2c2f-7428-4b5e-b5f7-3370efb51bb6" />
</datasource-mapping>
<naming-strategy-map />
</configuration>
</facet>
</component>
</module>
2 changes: 2 additions & 0 deletions Dockerfiles/backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM openjdk:latest

7 changes: 7 additions & 0 deletions Dockerfiles/db/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM mysql:latest


ENV MYSQL_ROOT_PASSWORD=root
ENV MYSQL_DATABASE=collabcode

EXPOSE 3306
Empty file added Dockerfiles/docker-compose.yml
Empty file.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Collaborative coding platform. Supports real-time collaboration, on multple programming languages, temporary code storage, and more.

### Landing page:
---
<img width="1398" alt="image" src="https://github.com/debxrshi/CollabCode/assets/40909973/91561995-df38-451f-bd50-d5a065cfaa90">

### Create a new room:
---
<img width="1393" alt="image" src="https://github.com/debxrshi/CollabCode/assets/40909973/eaba76ff-90d6-4f37-bdba-3a81cd109da5">

### Code in any language:
---
<img width="1378" alt="image" src="https://github.com/debxrshi/CollabCode/assets/40909973/ae567d68-9955-40d7-9338-0a233e8f2d46">

### Save your code:
---
<img width="1389" alt="image" src="https://github.com/debxrshi/CollabCode/assets/40909973/fdb3ae6f-b291-4b36-aeb1-4b09d9bddb37">
223 changes: 223 additions & 0 deletions api_tests/samples.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
## Sample programs to test execution

```java
import java.util.Arrays;

public class Main {
public static void main(String[] args) {
int n = 1000; // Find all primes less than 1000
boolean[] isPrime = new boolean[n];
Arrays.fill(isPrime, true);
isPrime[0] = isPrime[1] = false;

for (int i = 2; i * i < n; i++) {
if (isPrime[i]) {
for (int j = i * i; j < n; j += i) {
isPrime[j] = false;
}
}
}

for (int i = 2; i < n; i++) {
if (isPrime[i]) {
System.out.println(i + " ");
}
}
}
}


```
---
```cpp
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

const int INF = 1e9;

vector<vector<pair<int, int>>> adj;

void dijkstra(int start, vector<int>& dist) {
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
dist[start] = 0;
pq.push({0, start});

while (!pq.empty()) {
int d = pq.top().first;
int u = pq.top().second;
pq.pop();

if (d != dist[u])
continue;

for (auto edge : adj[u]) {
int v = edge.first;
int len = edge.second;

if (dist[u] + len < dist[v]) {
dist[v] = dist[u] + len;
pq.push({dist[v], v});
}
}
}
}

int main() {
int n = 5;
adj.resize(n);

// Example graph
adj[0].push_back({1, 10});
adj[0].push_back({4, 5});
adj[1].push_back({2, 1});
adj[2].push_back({3, 4});
adj[3].push_back({0, 7});
adj[4].push_back({1, 3});
adj[4].push_back({2, 9});
adj[4].push_back({3, 2});

vector<int> dist(n, INF);
dijkstra(0, dist);

for (int i = 0; i < n; i++) {
cout << "Distance to node " << i << " is " << dist[i] << endl;
}

return 0;
}


```
---
```golang
package main
import (
"fmt"
"time"
)
func task(name string, ch chan string) {
time.Sleep(time.Second * 2)
ch <- fmt.Sprintf("Task %s completed", name)
}
func main() {
ch := make(chan string)
go task("A", ch)
go task("B", ch)
fmt.Println(<-ch) // Receive message from any goroutine
fmt.Println(<-ch) // Receive message from any goroutine (may print in different order)
}
```
---
```python
import cmath

def fft(x):
N = len(x)
if N <= 1:
return x
even = fft(x[0::2])
odd = fft(x[1::2])
T = [cmath.exp(-2j * cmath.pi * k / N) * odd[k] for k in range(N // 2)]
return [even[k] + T[k] for k in range(N // 2)] + [even[k] - T[k] for k in range(N // 2)]

# Test the FFT function
x = [cmath.exp(2j * cmath.pi * i / 8) for i in range(8)]
fft_result = fft(x)

# Print the results
for value in fft_result:
print(value)


```
---
```c
#include <stdio.h>
#include <stdlib.h>

#define N 4

void multiply(int a[N][N], int b[N][N], int result[N][N]) {
int i, j, k;
for (i = 0; i < N; i++) {
for (j = 0; j < N; j++) {
result[i][j] = 0;
for (k = 0; k < N; k++) {
result[i][j] += a[i][k] * b[j][k];
}
}
}
}

int main() {
int a[N][N] = {
{1, 2, 3, 4},
{5, 6, 7, 8},
{9, 10, 11, 12},
{13, 14, 15, 16}
};
int b[N][N] = {
{16, 15, 14, 13},
{12, 11, 10, 9},
{8, 7, 6, 5},
{4, 3, 2, 1}
};
int result[N][N];

multiply(a, b, result);

for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
printf("%d ", result[i][j]);
}
printf("\n");
}

return 0;
}

```
---
```rust
fn quicksort(arr: &mut [i32]) {
if arr.len() <= 1 {
return;
}
let pivot_index = partition(arr);
quicksort(&mut arr[0..pivot_index]);
quicksort(&mut arr[pivot_index + 1..arr.len()]);
}
fn partition(arr: &mut [i32]) -> usize {
let pivot_index = arr.len() / 2;
arr.swap(pivot_index, arr.len() - 1);
let mut store_index = 0;
for i in 0..arr.len() - 1 {
if arr[i] < arr[arr.len() - 1] {
arr.swap(i, store_index);
store_index += 1;
}
}
arr.swap(store_index, arr.len() - 1);
store_index
}
fn main() {
let mut arr = [3, 6, 8, 10, 1, 2, 1];
quicksort(&mut arr);
println!("{:?}", arr);
}
```
28 changes: 28 additions & 0 deletions api_tests/thread.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import requests
import threading

url = "http://127.1:8080/exec"
headers = {'Content-Type': 'application/json'}

data1 = {
"lang": "python",
"code": "def bubbleSort(arr):\n n = len(arr)\n # optimize code, so if the array is already sorted, it doesn't need\n # to go through the entire process\n # Traverse through all array elements\n for i in range(n-1):\n\n # range(n) also work but outer loop will\n # repeat one time more than needed.\n # Last i elements are already in place\n swapped = False\n for j in range(0, n-i-1):\n\n # traverse the array from 0 to n-i-1\n # Swap if the element found is greater\n # than the next element\n if arr[j] > arr[j + 1]:\n swapped = True\n arr[j], arr[j + 1] = arr[j + 1], arr[j]\n\n if not swapped:\n # if we haven't needed to make a single swap, we\n # can just exit the main loop.\n return\n\n\n# Driver code to test above\narr = [64, 34, 25, 12, 22, 11, 90]\n\nbubbleSort(arr)\n\nprint(\"Sorted array is:\")\nfor i in range(len(arr)):\n print(\"% d\" % arr[i], end=\" \")"
}

data2 = {
"lang": "python",
"code": "def insertionSort(arr):\n n = len(arr) # Get the length of the array\n \n if n <= 1:\n return # If the array has 0 or 1 element, it is already sorted, so return\n \n for i in range(1, n): # Iterate over the array starting from the second element\n key = arr[i] # Store the current element as the key to be inserted in the right position\n j = i-1\n while j >= 0 and key < arr[j]: # Move elements greater than key one position ahead\n arr[j+1] = arr[j] # Shift elements to the right\n j -= 1\n arr[j+1] = key # Insert the key in the correct position\n \n# Sorting the array [12, 11, 13, 5, 6] using insertionSort\narr = [12, 11, 13, 5, 6]\ninsertionSort(arr)\nprint(arr)"
}

def send_post(data):
response = requests.post(url, headers=headers, json=data)
print(response.json())

thread1 = threading.Thread(target=send_post, args=(data1,))
thread2 = threading.Thread(target=send_post, args=(data2,))

thread1.start()
thread2.start()

thread1.join()
thread2.join()
Loading

0 comments on commit 8fb3e9b

Please sign in to comment.