Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add samples for several languages #518

Merged
merged 20 commits into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions samples-test/samples/Batch File/calculator.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
@echo off
:start
cls
echo Simple Calculator
echo ================
echo 1. Addition
echo 2. Subtraction
echo 3. Multiplication
echo 4. Division
echo 5. Exit
echo.

set /p choice="Enter your choice (1-5): "
if %choice%==5 goto end

set /p num1="Enter first number: "
set /p num2="Enter second number: "

if %choice%==1 set /a result=%num1%+%num2%
if %choice%==2 set /a result=%num1%-%num2%
if %choice%==3 set /a result=%num1%*%num2%
if %choice%==4 set /a result=%num1%/%num2%

echo.
echo Result: %result%
echo.
pause
goto start

:end
echo Thanks for using the calculator!
pause
12 changes: 12 additions & 0 deletions samples-test/samples/Batch File/sysinfo.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@echo off
echo ================ Some System Information ================

echo.
echo Windows Version:
ver

echo.
echo System Architecture:
wmic os get osarchitecture

pause
51 changes: 51 additions & 0 deletions samples-test/samples/CSS/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/* Basic reset */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}

/* Body styles */
body {
font-family: Arial, sans-serif;
line-height: 1.6;
background-color: #f4f4f4;
}

/* Header styles */
.header {
background-color: #333;
color: white;
padding: 1rem;
text-align: center;
}

/* Container */
.container {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
}

/* Button styles */
.button {
display: inline-block;
padding: 10px 20px;
background-color: #007bff;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.3s;
}

.button:hover {
background-color: #0056b3;
}

/* Responsive design */
@media screen and (max-width: 768px) {
.container {
padding: 10px;
}
}
74 changes: 74 additions & 0 deletions samples-test/samples/HTML/site.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Centered Button and Label</title>
<style>
.container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
gap: 10px;
}
.label {
font-family: Arial, sans-serif;
font-size: 18px;
}
.button {
padding: 10px 20px;
border-radius: 25px;
border: none;
background-color: #4CAF50;
color: white;
font-size: 16px;
cursor: pointer;
}
.button:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<div class="container">
<span class="label">Hello World!</span>
<button class="button">Click Me</button>
<span class="label">Welcome to our site!</span>
<button class="button">Learn More</button>
<span class="label">Contact Us</span>
<button class="button">Send Message</button>
<span class="label">Newsletter</span>
<button class="button">Subscribe</button>
<span class="label">Our Products</span>
<button class="button">Shop Now</button>
<span class="label">Special Offers</span>
<button class="button">View Deals</button>
<span class="label">Customer Support</span>
<button class="button">Get Help</button>
<span class="label">About Us</span>
<button class="button">Read More</button>
<span class="label">Careers</span>
<button class="button">Join Us</button>
<span class="label">Blog Posts</span>
<button class="button">Read Blog</button>
<span class="label">FAQ Section</span>
<button class="button">View FAQ</button>
<span class="label">Privacy Policy</span>
<button class="button">Read Policy</button>
<span class="label">Terms of Service</span>
<button class="button">View Terms</button>
<span class="label">Social Media</span>
<button class="button">Follow Us</button>
<span class="label">Testimonials</span>
<button class="button">Read Reviews</button>
<span class="label">Events</span>
<button class="button">See Calendar</button>
<span class="label">Downloads</span>
<button class="button">Get Files</button>
<span class="label">Partners</span>
<button class="button">View Partners</button>
</div>
</body>
</html>
13 changes: 13 additions & 0 deletions samples-test/samples/Ignore List/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
node_modules
npm-debug.log
dist
build
*.exe
*.dll
*.so
*.dylib
.idea/
.vscode/
*.log
*.sql
*.sqlite
3 changes: 3 additions & 0 deletions samples-test/samples/Ignore List/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
debug/
target/
*.pdb
5 changes: 5 additions & 0 deletions samples-test/samples/Ignore List/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
LICENSE
README.md
docs
*.html
*.test.js
13 changes: 13 additions & 0 deletions samples-test/samples/Ignore List/.vercelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.env
.env.local
node_modules
README.md
.gitignore
.vscode
.idea
tests
*.test.js
*.spec.js
coverage
dist
build
14 changes: 14 additions & 0 deletions samples-test/samples/JSON with Comments/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "Development Container",
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {},
"customizations": {
"vscode": {
"extensions": []
}
},
"forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created
"postCreateCommand": "echo 'Container is ready!'",
"remoteUser": "vscode"
}
15 changes: 15 additions & 0 deletions samples-test/samples/JSON with Comments/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"compilerOptions": {
"target": "es2020",
"module": "commonjs",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"outDir": "./dist",
"rootDir": "./src",
"sourceMap": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]
}
16 changes: 16 additions & 0 deletions samples-test/samples/JSON/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"type": "user",
"name": "John Doe",
"age": 25,
"job": "Software Developer",
"projects": [
{
"name": "Project 1",
"description": "This is project 1"
},
{
"name": "Project 2",
"description": "This is project 2"
}
]
}
15 changes: 15 additions & 0 deletions samples-test/samples/JavaScript/button.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';

const Button = ({ onClick, children, disabled = false, className = '' }) => {
return (
<button
onClick={onClick}
disabled={disabled}
className={`button ${className}`}
>
{children}
</button>
);
};

export default Button;
24 changes: 24 additions & 0 deletions samples-test/samples/JavaScript/count_expression.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Parses and evaluates a mathematical expression string
* @param {string} expression - The mathematical expression to evaluate
* @returns {number} The result of the expression
*/
function parseExpression(expression) {
try {
// Remove whitespace and validate input
const cleanExpression = expression.replace(/\s+/g, '');

// Check for invalid characters
if (/[^0-9+\-*/().]/.test(cleanExpression)) {
throw new Error('Invalid characters in expression');
}

// Use Function constructor to safely evaluate the expression
// This handles basic arithmetic operations: +, -, *, /
return Function(`return ${cleanExpression}`)();
} catch (error) {
throw new Error('Invalid expression: ' + error.message);
}
}

module.exports = parseExpression;
34 changes: 34 additions & 0 deletions samples-test/samples/Jupyter Notebook/simple.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Simple factorial function"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def factorial(n):\n",
" if n == 0:\n",
" return 1\n",
" else:\n",
" return n * factorial(n-1)\n",
"\n",
"# Example usage\n",
"print(factorial(5)) # Output: 120"
]
}
],
"metadata": {
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
30 changes: 30 additions & 0 deletions samples-test/samples/Makefile/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Compiler settings
CC = gcc
CFLAGS = -Wall -Wextra -std=c11

# Directories
SRC_DIR = src
OBJ_DIR = obj
BIN_DIR = bin

# Files
SRCS = $(wildcard $(SRC_DIR)/*.c)
OBJS = $(SRCS:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.o)
TARGET = $(BIN_DIR)/program

# Main targets
all: $(TARGET)

$(TARGET): $(OBJS)
@mkdir -p $(BIN_DIR)
$(CC) $(OBJS) -o $(TARGET)

$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
@mkdir -p $(OBJ_DIR)
$(CC) $(CFLAGS) -c $< -o $@

# Cleaning
clean:
rm -rf $(OBJ_DIR) $(BIN_DIR)

.PHONY: all clean
Loading