Skip to content

Instantly share code, notes, and snippets.

View mmozeiko's full-sized avatar

Mārtiņš Možeiko mmozeiko

View GitHub Profile
@mmozeiko
mmozeiko / meow_hash_armv8.h
Last active December 22, 2023 17:02
Meow v0.5 in C and ARMv8
#pragma once
#define MEOW_HASH_VERSION 5
#define MEOW_HASH_VERSION_NAME "0.5/calico"
// Meow hash v0.5 with ARMv8 Crypto Extension instructions
// Ported from https://github.com/cmuratori/meow_hash
// Performance on Pine A64 (Cortex-A53, 1.2GHz)
// (compiled with clang v10.0 with -O3 -mcpu=cortex-a53)
@mmozeiko
mmozeiko / meow_hash_c.h
Created June 29, 2020 00:19
Meow v0.5 in C
#pragma once
#define MEOW_HASH_VERSION 5
#define MEOW_HASH_VERSION_NAME "0.5/calico"
// Meow hash v0.5 in C without dependency on special CPU instructions
// Ported from https://github.com/cmuratori/meow_hash
// Performance on Ryzen 9 3950X
// AESNI code = ~16 bytes/cycle
@mmozeiko
mmozeiko / zipit.py
Last active June 25, 2020 00:17
Create zip file with explicitly setting +x permissions
#!/usr/bin/env python3
import os
import os.path
import sys
from datetime import datetime
from zipfile import ZipFile, ZipInfo, ZIP_DEFLATED
# which files to make executable
EXECUTABLE = [
@mmozeiko
mmozeiko / info.txt
Created June 7, 2020 06:35
OpenGL info with mesa v3d on RaspberryPi 4+ with 64-bit ArchLinuxArm (aarch64)
$ cat /etc/issue
Arch Linux \r (\l)
$ uname -a
Linux archlinux 5.4.38-1-ARCH #1 SMP PREEMPT Wed May 6 11:05:57 MDT 2020 aarch64 GNU/Linux
##### EGL info
EGL client extensions = EGL_EXT_client_extensions EGL_EXT_device_base EGL_EXT_device_enumeration EGL_EXT_device_query EGL_EXT_platform_base EGL_KHR_client_get_all_proc_addresses EGL_KHR_debug EGL_EXT_platform_device EGL_MESA_platform_gbm EGL_KHR_platform_gbm
@mmozeiko
mmozeiko / xbox_test.c
Last active October 13, 2024 00:45
Getting xbox controller input without xinput
// cl.exe xbox_test.c /link setupapi.lib user32.lib
#include <windows.h>
#include <setupapi.h>
#include <dbt.h>
#include <stdio.h>
/// interface
#define XBOX_MAX_CONTROLLERS 16
@mmozeiko
mmozeiko / demo.c
Last active June 2, 2023 08:39
linux call stack
// gcc -g demo.c -ldl
#define _GNU_SOURCE
#include <stdio.h>
#include <dlfcn.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <unistd.h>
@mmozeiko
mmozeiko / capture_desktop_dxgi_gl.c
Last active October 13, 2024 00:45
Capture desktop with IDXGIOutputDuplication and use as OpenGL texture
//
// First download glcorearb.h, wglext.h and platform.h files
// Then compile: cl.exe capture_desktop_dxgi_gl.c /I. d3d11.lib dxgi.lib dxguid.lib gdi32.lib opengl32.lib user32.lib dwmapi.lib
//
#define COBJMACROS
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <d3d11.h>
@mmozeiko
mmozeiko / webcam_capture.c
Created August 28, 2019 20:25
Capture webcam device with Media Foundation API
#define COBJMACROS
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <mfapi.h>
#include <mfidl.h>
#include <mfreadwrite.h>
#include <stdio.h>
#include <intrin.h>
@mmozeiko
mmozeiko / raspbian_buster.txt
Last active July 20, 2019 09:24
OpenGL info on Raspberry Pi 4
EGL_VENDOR = Mesa Project
EGL_VERSION = 1.4
EGL_CLIENT_APIS = OpenGL OpenGL_ES
EGL_EXTENSIONS = EGL_EXT_buffer_age EGL_EXT_image_dma_buf_import EGL_EXT_image_dma_buf_import_modifiers EGL_KHR_cl_event2 EGL_KHR_config_attribs EGL_KHR_create_context EGL_KHR_create_context_no_error EGL_KHR_fence_sync EGL_KHR_get_all_proc_addresses EGL_KHR_gl_colorspace EGL_KHR_gl_renderbuffer_image EGL_KHR_gl_texture_2D_image EGL_KHR_gl_texture_3D_image EGL_KHR_gl_texture_cubemap_image EGL_KHR_image EGL_KHR_image_base EGL_KHR_image_pixmap EGL_KHR_no_config_context EGL_KHR_reusable_sync EGL_KHR_surfaceless_context EGL_EXT_pixel_format_float EGL_KHR_wait_sync EGL_MESA_configless_context EGL_MESA_drm_image EGL_MESA_image_dma_buf_export
// GLES API
GL_VENDOR = Broadcom
GL_RENDERER = V3D 4.2
GL_VERSION = OpenGL ES 3.0 Mesa 19.1.2
@mmozeiko
mmozeiko / ods.c
Created April 16, 2019 19:20
Example how to capture OutputDebugString on Windows
#include <windows.h>
#include <intrin.h>
#define Assert(x) do { if (!(x)) __debugbreak(); } while (0)
static struct
{
DWORD process_id;
char data[4096 - sizeof(DWORD)];
}* ods_buffer;