Skip to content

Instantly share code, notes, and snippets.

View equalent's full-sized avatar
🇵🇸

Andrei Tsurkan equalent

🇵🇸
View GitHub Profile
@equalent
equalent / HDR_Output.md
Last active February 16, 2024 13:03
HDR Output

HDR Output

This is an overview of HDR output support on different platforms.

DXGI

Windows 10 Creators Update added native HDR support to DXGI:

  • must be enabled for display in Settings
  • requires flip-mode swap chain
@equalent
equalent / .clang-format
Created January 19, 2024 01:33
clang-format config for RHandy's C++ style
BasedOnStyle: LLVM
IndentWidth: 8
TabWidth: 8
UseTab: Never
BreakBeforeBraces: Attach
SpaceAfterCStyleCast: true
SpacesInParentheses: false
PointerAlignment: Right
ReferenceAlignment: Right
SpacesInAngles: false
@equalent
equalent / rsqrt.h
Last active January 10, 2024 05:35
Inverse square root implementation in plain C (q_rsqrt) and using SSE / NEON intrinsics
#pragma once
#if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) \
|| defined(__x86_64) || defined(_M_AMD64)
#define RSQRT_ARCH_AMD64
#define RSQRT_ARCH_X86
#endif
#if defined(i386) || defined(__i386) || defined(__i386__) \
|| defined(__i386__) || defined(__IA32__) || defined(_M_IX86)
@equalent
equalent / KA_HY_FONTS.md
Last active November 7, 2023 22:45
Georgian/Armenian fonts for code

To read and write code that contains Georgian and/or Armenian characters, a combination of any preferred typeface with fallback DejaVu Sans Mono can be used.

For example, in VS Code settings.json:

{
    "editor.fontFamily": "'JetBrains Mono', 'DejaVu Sans Mono'"
}
@equalent
equalent / MakeID.h
Created November 6, 2022 14:20
MakeID.h
#ifndef MAKEID_H
#define MAKEID_H
/*
Author:
Emil Persson, A.K.A. Humus.
http://www.humus.name
Version history:
@equalent
equalent / lj_win64.ninja
Created August 24, 2022 11:12
Ninja makefile for LuaJIT
script =
tflags =
rule cc
command = cl /nologo /c /O2 /Ob3 /W3 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_STDIO_INLINE=__forceinline -DLUAJIT_DISABLE_JIT -DLUAJIT_NO_UNWIND /showIncludes $tflags $in
deps = msvc
rule link
command = link /nologo /out:$out $in
@equalent
equalent / numeric_to_bit.pgsql
Created February 18, 2022 17:06
PostgreSQL PL/pgSQL NUMERIC to BIT VARYING
-- source: https://stackoverflow.com/a/50119025
create function numeric_to_bit(numeric) returns bit varying
language plpgsql
as
$$
DECLARE
num ALIAS FOR $1;
-- 1 + largest positive BIGINT --
max_bigint NUMERIC := '9223372036854775808' :: NUMERIC(19, 0);
@equalent
equalent / crt.glsl
Created October 23, 2021 19:29
CRT shader by Timothy Lottes
//
// PUBLIC DOMAIN CRT STYLED SCAN-LINE SHADER
//
// by Timothy Lottes
//
// This is more along the style of a really good CGA arcade monitor.
// With RGB inputs instead of NTSC.
// The shadow mask example has the mask rotated 90 degrees for less chromatic aberration.
//
// Left it unoptimized to show the theory behind the algorithm.
@equalent
equalent / bot.js
Last active September 23, 2021 14:49
Discord TTS Bot (CLI)
const { Client, Intents } = require('discord.js');
const { joinVoiceChannel, createAudioResource, createAudioPlayer, VoiceConnectionStatus, entersState, AudioPlayerStatus } = require("@discordjs/voice");
const { token } = require('./config.json');
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
prompt: 'TTS> '
});
const util = require('util');
@equalent
equalent / dxgi_format.h
Last active June 15, 2021 15:29
DXGI format utils
#pragma once
constexpr size_t DxgiFormatRowSize(DXGI_FORMAT format, uint width)
{
switch (format)
{
case DXGI_FORMAT_R32G32B32A32_TYPELESS:
case DXGI_FORMAT_R32G32B32A32_FLOAT:
case DXGI_FORMAT_R32G32B32A32_UINT:
case DXGI_FORMAT_R32G32B32A32_SINT: