Skip to content

Instantly share code, notes, and snippets.

View henkman's full-sized avatar
🌶️

henkman henkman

🌶️
View GitHub Profile
@henkman
henkman / pview.cc
Last active March 15, 2024 19:50
basic video viewer using fltk & embedded mpv. just drag&drop a folder and use left and right arrow. s to shuffle
// g++ -O2 -s -o pview main.cc -lfltk -lfltk_images -lmpv
#include <stdio.h>
#include <FL/Enumerations.H>
#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_PNG_Image.H>
#include <FL/x.H>
#include <stdint.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
int main(int argc, char **argv) {
if (argc != 2) {
printf("Usage: binc [input]\n");
@henkman
henkman / socket.h
Last active November 16, 2023 19:54
/**
// SAMPLE
int main(void) {
SocketInit();
struct sockaddr_in addr;
SocketResolve(&addr, "localhost", 5432);
Socket sock = SocketUDP(false);
// connected udp can use send/recv instead of sendto/recvfrom
connect(sock, (const struct sockaddr *) &addr, sizeof(addr));
const char *data = "hello world";
// g++ -s -O2 -o co2monitor main.cc -lfltk -lhidapi
#include <FL/Fl.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Tile.H>
#include <hidapi/hidapi.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
@henkman
henkman / imgslide.c
Last active July 23, 2023 17:00
img slide window with gif support made with raylib
// gcc -o imgslide.exe imgslide.c -lraylib -Lraylib -lgdi32 -lwinmm -lgif -Lgiflib
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "giflib/gif_lib.h"
#include "raylib/raylib.h"
static size_t nextPowerOfTwo(size_t v) {
@henkman
henkman / go.mod
Created July 17, 2023 19:39
go + fiber + jwt keycloak
module gojwtkeycloak
go 1.20
require (
github.com/coreos/go-oidc/v3 v3.6.0
github.com/gofiber/fiber/v2 v2.48.0
github.com/golang-jwt/jwt/v4 v4.5.0
)
typedef struct {
unsigned char *mem;
size_t bytes;
} BS;
static void BSInit(BS *bs, size_t bits) {
size_t bytes = bits / 8;
if (bits % 8)
bytes++;
bs->bytes = bytes;
@henkman
henkman / gif.go
Last active January 20, 2023 00:33
png, jpeg and gif: get image width and height
package main
import (
"bytes"
"encoding/binary"
"fmt"
"os"
)
func main() {
package main
import (
"bufio"
"fmt"
"image"
"image/draw"
"image/gif"
"image/png"
"io"
package main
import (
"sort"
"fmt"
"constraints"
)
type Vec2[T constraints.Ordered] struct {
X, Y T