Skip to content

Instantly share code, notes, and snippets.

View mmozeiko's full-sized avatar

Mārtiņš Možeiko mmozeiko

View GitHub Profile
@rygorous
rygorous / stb_dxt.h
Created October 3, 2012 17:12
YannC's modified rygdxt code review
// stb_dxt.h - Real-Time DXT1/DXT5 compressor
// Based on original by fabian "ryg" giesen v1.04
// Custom version, modified by Yann Collet
//
/*
BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
#!/bin/bash
# If we get interrupted, make sure to kill the whole process tree
trap 'trap - SIGTERM && kill 0' SIGINT SIGTERM
# Issue command to all devices in parallel
for DEVICE in `adb devices | awk '/\tdevice$/ { print $1 }'`; do
ANY_DEVICES=1
# Look up pretty name from serial number
#pragma comment(lib, "Xinput.lib")
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <Xinput.h>
@pervognsen
pervognsen / zzz.cpp
Last active January 22, 2019 17:08
/// zzz - very sleepy replacement, based on etw
#define INITGUID
#include <windows.h>
#include <psapi.h>
#include <tdh.h>
#include <evntrace.h>
#include <guiddef.h>
#pragma warning(disable: 4091)
#include <dbghelp.h>
@rygorous
rygorous / fp16_to_32.asm
Created March 21, 2012 04:37
half->float using SSE2
; input: 4x F16 in XMM0 (low words of each DWord)
; original idea+implementation by Dean Macri
; WARNING: copy & pasted together from other code, this ver is untested!!
; though the original version was definitely correct.
bits 32
section .data
@paniq
paniq / minmaxabssign.txt
Last active January 30, 2023 14:31
useful min/max/abs/sign identities
max(-x,-y) = -min(x,y)
min(-x,-y) = -max(x,y)
abs(x) = abs(-x)
abs(x) = max(x,-x) = -min(x,-x)
abs(x*a) = if (a >= 0) abs(x)*a
(a < 0) -abs(x)*a
// basically any commutative operation
min(x,y) + max(x,y) = x + y
@JarkkoPFC
JarkkoPFC / sphere_screen_extents.h
Last active June 13, 2023 21:27
Calculates view space 3D sphere extents on the screen
struct vec3f {float x, y, z;};
struct vec4f {float x, y, z, w;};
struct mat44f {vec4f x, y, z, w;};
//============================================================================
// sphere_screen_extents
//============================================================================
// Calculates the exact screen extents xyzw=[left, bottom, right, top] in
// normalized screen coordinates [-1, 1] for a sphere in view space. For
// performance, the projection matrix (v2p) is assumed to be setup so that
@vurtun
vurtun / x11_clipboard.c
Last active June 13, 2023 21:28
X11 clipboard
static char*
sys_clip_get(struct sys *s, Atom selection, Atom target)
{
assert(s);
struct sys_x11 *x11 = s->platform;
/* blocking wait for clipboard data */
XEvent notify;
XConvertSelection(x11->dpy, selection, target, selection, x11->helper, CurrentTime);
while (!XCheckTypedWindowEvent(x11->dpy, x11->helper, SelectionNotify, &notify)) {
#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
#include <unistd.h>
#include <string.h>
#include <assert.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <sys/ioctl.h>
@vurtun
vurtun / defl.c
Last active June 13, 2023 21:30
Full deflate/inflate implementation in ~300 LoC
/* ===============================================================
* SDEFL
* ===============================================================
* public domain - no warranty implied; use at your own risk
* References:
https://bitbucket.org/rmitton/tigr/src/be3832bee7fb2f274fe5823e38f8ec7fa94e0ce9/src/tigr_inflate.c?at=default&fileviewer=file-view-default
https://github.com/github/putty/blob/49fb598b0e78d09d6a2a42679ee0649df482090e/sshzlib.c
https://www.ietf.org/rfc/rfc1951.txt
*/
#include <stdlib.h>