Skip to content

Instantly share code, notes, and snippets.

View ludndev's full-sized avatar
💭
I may be slow to respond.

Judicaël AHYI ludndev

💭
I may be slow to respond.
View GitHub Profile
@ludndev
ludndev / translator-ollama.py
Created May 22, 2025 19:16
need to improve this as it's used in an automatic file translator
# Define the API endpoint for Ollama
api_url = f"{OLLAMA_API_URL}/v1/chat/completions"
# Construct the prompt with system and user messages
payload = {
"model": model_name,
"messages": [
{
"role": "system",
"content": "You are a translation engine. Respond ONLY with the direct translation of the input text. No quotes, no explanations, no additional text, no formatting, no line breaks. Return just the translated text string. Ensure the translation is accurate and matches the original text. Maintain the original formatting and structure of the input text. Handle unexpected API responses gracefully, returning only the desired translation."
@ludndev
ludndev / index.html
Created March 14, 2025 00:59
PHP SSE
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SSE Output</title>
</head>
<body>
<h1>Live Output:</h1>
<pre id="output"></pre>
@ludndev
ludndev / Dockerfile
Created March 7, 2025 13:40
J2EE Deploiement using Docker
FROM hotel-reservation-base:latest
# Set environment variables
ENV GLASSFISH_HOME=/opt/glassfish7
ENV DOMAIN_NAME=domain1
# Copy application WAR file
COPY target/hotel-reservation.war ${GLASSFISH_HOME}/glassfish/domains/${DOMAIN_NAME}/autodeploy/
# Copy GlassFish configuration files
await new Promise(function (resolve) {
setTimeout(function () {
resolve();
}, 1000);
});
// ... Can be shortened to:
await new Promise(function (resolve) {
setTimeout(resolve, 1000);
#include <stdio.h>
// fn to check if a number is a power of 2
int isPowerOfTwo(int n) {
return n > 0 && !(n & (n - 1));
}
int main() {
printf("How to find if a number is a power of 2\n");
#[allow(dead_code)]
fn fibonacci_recursive(n: u64) -> u64 {
if n == 0 {
return 0;
} else if n == 1 {
return 1;
}
return fibonacci_recursive(n - 1) + fibonacci_recursive(n - 2);
}
def int_to_roman(num: int) -> str:
ones = ["", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"]
tens = ["", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"]
hrns = ["", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"]
ths = ["", "M", "MM", "MMM"]
return ths[num // 1000] + hrns[(num % 1000) // 100] + tens[(num % 100) // 10] + ones[num % 10]
print(int_to_roman(3)) # Output: "III"
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JS Bin</title>
<script src="https://cdn.kkiapay.me/k.js"></script>
</head>
<body>

get cover from video

ffmpeg -i SampleVideo_1280x720_30mb.mp4 -ss 00:00:01.000 -vframes 1 exports/cover.png

each 10 seconds