Skip to content

Instantly share code, notes, and snippets.

View equalent's full-sized avatar
🍉

Andrei Tsurkan equalent

🍉
View GitHub Profile
@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:
@equalent
equalent / rd_vis_bc5nrm.hlsl
Last active June 12, 2021 18:24
Unpack a normal map. Use with BC5-encoded normal map to reconstruct Z and remap the values to [-1, 1] range
/*
A BC5 normal map texture visualization shader for RenderDoc.
Usage:
1. Save this to %APPDATA%/qrenderdoc/ on Windows or ~/.local/share/qrenderdoc elsewhere
2. Set Channels mode to Custom in RenderDoc Texture Viewer
3. Select the shader from the dropdown menu
*/
SamplerState pointSampler : register(s0);
Texture2DArray<float4> texDisplayTex2DArray : register(t2);
@equalent
equalent / mandelbrot.html
Created September 15, 2020 14:18
Simple JS + WebGL Mandelbrot set implementation
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MANDELBROT</title>
</head>
<body style="font-family: sans-serif;">
@equalent
equalent / Qt 5 Dark Fusion Palette
Created February 3, 2020 23:56 — forked from QuantumCD/Qt 5 Dark Fusion Palette
This is a complete (I think) dark color palette for the Qt 5 Fusion theme, as well as a nice style sheet for the tool tips that make them blend better with the rest of the theme. To have immediate effect, be sure to put this in your main function before showing the parent window. Child windows should automatically inherit the palette unless you …
qApp->setStyle(QStyleFactory::create("Fusion"));
QPalette darkPalette;
darkPalette.setColor(QPalette::Window, QColor(53,53,53));
darkPalette.setColor(QPalette::WindowText, Qt::white);
darkPalette.setColor(QPalette::Base, QColor(25,25,25));
darkPalette.setColor(QPalette::AlternateBase, QColor(53,53,53));
darkPalette.setColor(QPalette::ToolTipBase, Qt::white);
darkPalette.setColor(QPalette::ToolTipText, Qt::white);
darkPalette.setColor(QPalette::Text, Qt::white);
@equalent
equalent / ack_short.py
Created October 10, 2019 16:13 — forked from justjkk/ack_short.py
Ackermann Function in python
import sys
count=0
sys.setrecursionlimit(50000)
cache={}
def a(m,n):
global count
global cache
count=count+1
if cache.has_key(m) and cache[m].has_key(n):
return cache[m][n]
@equalent
equalent / aligned_malloc.cpp
Created October 1, 2019 15:52 — forked from ashwin/aligned_malloc.cpp
Aligned memory allocation
// Assume we need 32-byte alignment for AVX instructions
#define ALIGN 32
void *aligned_malloc(int size)
{
// We require whatever user asked for PLUS space for a pointer
// PLUS space to align pointer as per alignment requirement
void *mem = malloc(size + sizeof(void*) + (ALIGN - 1));
// Location that we will return to user