Skip to content

Instantly share code, notes, and snippets.

@xnoreq
xnoreq / mergesort.awk
Last active May 13, 2022 23:25
Merge sort in AWK
function mergesort(a, len, mid, rlen, i, left, right, ia, il, ir) {
if (len < 2) return;
mid = int(len / 2);
rlen = len-mid;
for (i=0; i<mid; i++) {left[i] = a[i];}
for (i=0; i<rlen; i++) {right[i] = a[i+mid];}
mergesort(left, mid)
mergesort(right, rlen)
@xnoreq
xnoreq / quicksort.awk
Last active March 26, 2022 21:07
Quicksort in AWK
function quicksort(a, left, right, pivot, left_new, right_new) {
if (left >= right) return;
pivot = a[left + int((right - left) / 2)];
left_new = left;
right_new = right;
do {
while (a[left_new] < pivot) left_new += 1;
while (pivot < a[right_new]) right_new -= 1;
@xnoreq
xnoreq / CAS-scaled.glsl
Created March 21, 2022 17:55 — forked from agyild/CAS-scaled.glsl
AMD FidelityFX Contrast Adaptive Sharpening v1.0.2 for mpv
// LICENSE
// =======
// Copyright (c) 2017-2019 Advanced Micro Devices, Inc. All rights reserved.
// -------
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
// -------
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
@xnoreq
xnoreq / FSR.glsl
Created March 21, 2022 17:55 — forked from agyild/FSR.glsl
AMD FidelityFX Super Resolution v1.0.2 for mpv
// Copyright (c) 2021 Advanced Micro Devices, Inc. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
@xnoreq
xnoreq / NVScaler.glsl
Created March 21, 2022 17:54 — forked from agyild/NVScaler.glsl
NVIDIA Image Scaling v1.0.2 for mpv
// The MIT License(MIT)
//
// Copyright(c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files(the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions :
@echo off
setlocal enableextensions enabledelayedexpansion
path %SystemRoot%\System32;%SystemRoot%;%SystemRoot%\System32\Wbem
:: Unattended install flag. When set, the script will not require user input.
set unattended=no
if "%1"=="/u" set unattended=yes
:: Make sure this is Windows Vista or later
call :ensure_vista
@xnoreq
xnoreq / dev_signed_cert.sh
Created July 3, 2019 18:57 — forked from dobesv/dev_signed_cert.sh
Script to create (1) a local certificate authority, (2) a host certificate signed by that authority for the hostname of your choice
#!/usr/bin/env bash
#
# Usage: dev_signed_cert.sh HOSTNAME
#
# Creates a CA cert and then generates an SSL certificate signed by that CA for the
# given hostname.
#
# After running this, add the generated dev_cert_ca.cert.pem to the trusted root
# authorities in your browser / client system.
#
@xnoreq
xnoreq / unsharp.glsl
Last active October 17, 2021 09:31
Unsharp sharpen glsl shader
//!HOOK SCALED
//!BIND HOOKED
#define effect_width 1
#define coeff_blur 0.9
#define coeff_orig (1 + coeff_blur)
#define Src(a,b) HOOKED_texOff(vec2(a,b))
@xnoreq
xnoreq / saturate.glsl
Last active October 17, 2021 09:30
EQ glsl shader
//!HOOK MAINPRESUB
//!BIND HOOKED
// Brightness: -1.0 to 1.0, default 0.0
// Contrast: 0.0 to 10.0, default 1.0
// Hue: -180.0 to +180.0, default 0.0
// Saturation: 0.0 to 10.0, default 1.0
#define Brightness 0.0