Skip to content

Instantly share code, notes, and snippets.

View tomas's full-sized avatar

Tomás Pollak tomas

View GitHub Profile
@bddicken
bddicken / index.html
Last active March 21, 2024 13:43
Image Binning
<html>
<head>
<script is:inline defer src="https://cdn.jsdelivr.net/npm/img-comparison-slider@8/dist/index.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/img-comparison-slider@8/dist/styles.css" />
<script is:inline src="/assets/code/ImageManipulator.js"></script>
<style>
@cellularmitosis
cellularmitosis / README.md
Last active March 14, 2023 21:58
Timeline of random tech
@kajott
kajott / vaapi_egl_interop_example.c
Last active February 27, 2024 06:43
example code for minimal-overhead hardware-accelerated video decoding and display on Linux using VA-API/EGL interoperability
#if 0 // self-compiling code: chmod +x this file and run it like a script
BINARY=vaapi_egl_interop_example
gcc -std=c99 -Wall -Wextra -pedantic -Werror -g -fsanitize=address -o $BINARY $0 \
`pkg-config libavcodec libavformat libavutil libva gl egl libdrm --cflags --libs` \
-lX11 -lva-x11 -lva-drm || exit 1
test "$1" = "--compile-only" && exit 0
exec env ASAN_OPTIONS=fast_unwind_on_malloc=0 ./$BINARY $*
#endif /*
Minimal example application for hardware video decoding on Linux and display
@dixyes
dixyes / extinst.lua
Last active June 27, 2022 19:29
use luajit, ncurses(w) to create a command line ui
#!/home/dixyes/awsl/pl/luajit
--[[
gist: https://gist.github.com/dixyes/cd945d8a195889de32cb524254d90d33
First to say : ffi niubi!
This file is ncursesw command line ui written in lua, using luajit and some C things.
Note: pits here:
1. variables created by ffi.new("sometype") may be gced at anytime (maybe use ffi.typeof() to create type can resolve this.);
workaround: use ffi.C.malloc instead
2. struct index may be not reliable: for example a structure struct sStruct{u32 lFirst; u64 llSecond;}; when use instSStruct[0].llSecond, it will use area from llSecond's half to out of bound 4 bytes as llSecond.
@nicebyte
nicebyte / dyn_arr.h
Last active January 23, 2024 00:10
dyn_arr
#pragma once
#define DYN_ARR_OF(type) struct { \
type *data; \
type *endptr; \
uint32_t capacity; \
}
#if !defined(__cplusplus)
#define decltype(x) void*
@ddevault
ddevault / Makefile
Last active February 20, 2024 14:17
Tiny Wayland compositor
WAYLAND_PROTOCOLS=/usr/share/wayland-protocols
# wayland-scanner is a tool which generates C headers and rigging for Wayland
# protocols, which are specified in XML. wlroots requires you to rig these up
# to your build system yourself and provide them in the include path.
xdg-shell-protocol.h:
wayland-scanner server-header \
$(WAYLAND_PROTOCOLS)/stable/xdg-shell/xdg-shell.xml $@
xdg-shell-protocol.c: xdg-shell-protocol.h
@baines
baines / freetype-atlas.c
Created July 15, 2016 13:32
minimal freetype texture atlas example
#include <stdio.h>
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "stb_image_write.h"
#include <ft2build.h>
#include FT_FREETYPE_H
#define NUM_GLYPHS 128
struct glyph_info {
int x0, y0, x1, y1; // coords of glyph in the texture atlas
# GIT heart FZF
# -------------
is_in_git_repo() {
git rev-parse HEAD > /dev/null 2>&1
}
fzf-down() {
fzf --height 50% --min-height 20 --border --bind ctrl-/:toggle-preview "$@"
}
@zhangyuchi
zhangyuchi / thread_libev.cc
Created December 24, 2014 07:31
multithread libev exsample, cross thread notify
//This program is demo for using pthreads with libev.
//Try using Timeout values as large as 1.0 and as small as 0.000001
//and notice the difference in the output
//(c) 2009 debuguo
//(c) 2013 enthusiasticgeek for stack overflow
//Free to distribute and improve the code. Leave credits intact
#include <ev.h>
#include <stdio.h> // for puts
@roxlu
roxlu / H264_Decoder.cpp
Created March 3, 2014 16:57
LibAV parser and decoder example with openGL (YUV420 -> RGB shader).
#include "H264_Decoder.h"
H264_Decoder::H264_Decoder(h264_decoder_callback frameCallback, void* user)
:codec(NULL)
,codec_context(NULL)
,parser(NULL)
,fp(NULL)
,frame(0)
,cb_frame(frameCallback)
,cb_user(user)