Skip to content

Instantly share code, notes, and snippets.

@avelican
avelican / index.html
Created October 14, 2024 21:20
get youtube thumbnail
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>title</title>
</head>
<body>
<input type="text" />
<br>
<img/>
// edit: only convert if not already txt...
if (filepath.Ext(inputPath)) != ".txt" {
// Create a temporary file for the intermediate output
tmpFile, err := os.CreateTemp("", "ebook-convert-*.txt")
if err != nil {
return nil, fmt.Errorf("failed to create temporary file: %v", err)
}
defer tmpFile.Close()
@avelican
avelican / sethbling_mario.lua
Created October 12, 2024 10:06
SethBling's Mari/o (Backup)
-- MarI/O by SethBling
-- Feel free to use this code, but please do not redistribute it.
-- Intended for use with the BizHawk emulator and Super Mario World or Super Mario Bros. ROM.
-- For SMW, make sure you have a save state named "DP1.state" at the beginning of a level,
-- and put a copy in both the Lua folder and the root directory of BizHawk.
if gameinfo.getromname() == "Super Mario World (USA)" then
Filename = "DP1.state"
ButtonNames = {
"A",
@avelican
avelican / main.rs
Created June 14, 2024 00:45
rust runtime overflow
use macroquad::prelude::*;
#[macroquad::main("BasicShapes")]
async fn main() {
rand::srand(macroquad::miniquad::date::now() as _);
let w = 400;
let h = 400;
@avelican
avelican / pi.cpp
Created June 13, 2024 23:51
pi fraction finder
#include <stdio.h>
#include <math.h>
#include <float.h>
int main() {
const double PI = 3.141592653589793;
double m = 1;
double n = 1;
// double max_m = 10000;
// double max_n = 10000;
const w4 = @import("wasm4.zig");
// actual render resolution
const SCREEN_SIZE = w4.SCREEN_SIZE;
// game resolution (everything is rendered 2x)
// const SCREEN_WIDTH = 48*2;
const SCREEN_WIDTH = 96;
const SCREEN_HEIGHT = SCREEN_SIZE;
@avelican
avelican / index-variable-width.html
Last active February 2, 2024 01:32
sprite font renderer
<!doctype html>
<html lang="en">
<head>
<title>sprite font</title>
<style>
body{
background-color: gray;
margin: 0;
padding: 0;
}
@avelican
avelican / udpClient.c
Created January 29, 2024 17:10
Noob's attempt: Cross Platform UDP (Linux + Windows)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN // prevent import of WinSock ? (conflict with WinSock2)
#include <windows.h> // sleep()
#define sleep(n) Sleep((n) * 1000)
#include <winsock2.h>
import json
import os
import openai
import tiktoken
import gradio as gr
openai.api_key = os.getenv("OPENAI_API_KEY")
USE_GPT4 = False
OPENAI_MODEL = "gpt-4" if USE_GPT4 else "gpt-3.5-turbo"
@avelican
avelican / stereo.py
Created May 7, 2023 18:28
autostereogram generator
# credit goes to https://github.com/synesthesiam/magicpy
# Instructions: Texture image MUST be as tall as depth map (taller should work too),
# and 1/8th of its width (or thereabouts -- any width will work but might not look too good).
from PIL import Image
if __name__ == '__main__':
depth_file = "depth.jpg"