Skip to content

Instantly share code, notes, and snippets.

@abdusco
abdusco / chat.html
Last active March 25, 2025 15:25
LLM chat interface
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Cet ci pi ti</title>
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<style>
:root {
/* Light theme variables */
@abdusco
abdusco / HTMLPopup.swift
Last active March 25, 2025 15:05
Show HTML as popup on Mac
import Cocoa
import WebKit
struct Options {
var html: String = ""
var url: URL? = nil
var title: String = "HTML Viewer"
var width: CGFloat = 800
var height: CGFloat = 600
var env: String = "{}" // Default empty JSON object
@abdusco
abdusco / CursorSpace.swift
Created December 25, 2024 03:50
Which space is my cursor in
import Cocoa
import CoreGraphics
@_silgen_name("CGSMainConnectionID")
func CGSMainConnectionID() -> CGSConnection
@_silgen_name("CGSCopyManagedDisplaySpaces")
func CGSCopyManagedDisplaySpaces(_ connection: CGSConnection) -> CFArray
typealias CGSConnection = UInt32
@abdusco
abdusco / htmlpopup.go
Last active December 24, 2024 19:35
Open up HTML from stdin in a browser tab
package main
import (
"context"
"fmt"
"io"
"log"
"net"
"net/http"
"os"
@abdusco
abdusco / server.py
Created March 2, 2024 04:51
Python mini HTTP server to serve a single request and shutdown
import http.server
import socketserver
import threading
import urllib.parse
def wait_for_oauth_callback(port: int = 9090) -> str:
code: str | None = None
class CallbackHandler(http.server.SimpleHTTPRequestHandler):
@abdusco
abdusco / hub.go
Created January 23, 2022 14:43
Hub implementation in Go
type Subscriber struct {
send chan string
}
type Hub struct {
clients map[*Subscriber]bool
broadcast chan string
register chan *Subscriber
unregister chan *Subscriber
}
@abdusco
abdusco / JwtCache.cs
Last active June 19, 2021 12:55
JWT Cache
using System;
using System.IdentityModel.Tokens.Jwt;
using System.Threading.Tasks;
using Microsoft.Extensions.Caching.Memory;
namespace JwtUtils
{
public interface IJwtCache
{
void Set(string key, JwtSecurityToken token);
@abdusco
abdusco / realdebrid.py
Created May 22, 2021 10:02
RealDebrid + aria2 downloader script
#!/usr/bin/env python3
import httpx
import subprocess
import logging
import typer
from pathlib import Path
logging.basicConfig(
level=logging.DEBUG,
format="%(levelname)s %(asctime)s: %(message)s",
@abdusco
abdusco / Startup.cs
Created May 4, 2021 08:40
SwashBuckle configuration for bearer tokens
services.AddSwaggerGen(c =>
{
// ...
c.AddSecurityDefinition("bearer", new OpenApiSecurityScheme
{
Description =
"Authenticate with an existing JWT token. **Prefix the token with `Bearer`, i.e. `Bearer eyJ...`**",
In = ParameterLocation.Header,
Name = HeaderNames.Authorization,
import dataclasses
import functools
import io
import pathlib
from datetime import timedelta, datetime
from io import FileIO
from typing import Callable
import httpx