Skip to content

Instantly share code, notes, and snippets.

@nidefawl
nidefawl / count_distinct_color_values.py
Created July 3, 2023 10:04
reads a image file and returns a list of tuples with the rgb values and the number of pixels with that color, sorted by the number of pixels
#v reads a image file and returns a list of tuples with the rgb values and the number of pixels with that color, sorted by the number of pixels
import sys
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import pprint
def quantize(val):
return val
def count_distinct_color_values(filepath):
img = mpimg.imread(filepath)
@nidefawl
nidefawl / pw-easylink
Last active May 27, 2023 06:01 — forked from fxthomas/pw-easylink
Small tool to configure and maintain PipeWire links between sets of input/output port querie
@nidefawl
nidefawl / build-llvm.sh
Last active May 15, 2022 14:01
Build llvm with libcxx libcxxabi llvm-libgcc compiler-rt libunwind clang lld lldb clang-tools-extra on linux. The toolchain can build itself (which apparently is not possible with certain build configurations)
#!/bin/bash
set -e
LLVM_SRC_PATH=./llvm-project
CLEAN=
CXX_FLAGS+="-march=native "
CXX_FLAGS+="-mtune=native "
C_FLAGS=$CXX_FLAGS
EXTRA_ARGS=""
@nidefawl
nidefawl / output.log
Last active March 11, 2022 22:51
Works with -O0, breaks on -O1
C:\dev\20_CPP\test-seh-exceptions>clang++.exe -O0 -g test_seh_exceptions.cpp -o test_seh_exceptions_O0.exe
C:\dev\20_CPP\test-seh-exceptions>test_seh_exceptions_O0.exe
in __try
in __finally
ret 2, i 5
in __try
in __catch
in __finally
ret -2
@nidefawl
nidefawl / win32shell_menu_add_vscode.py
Created February 13, 2022 10:51
VSCode Insiders Shell handlers
#!/usr/bin/env python3
# Register the shell handlers (open folder/file with) for a vscode insiders installation
import winreg as reg
installLocation = 'C:\\dev\\vscode-insiders'
vscodeExe = f'{installLocation}\\Code - Insiders.exe'
vscodeIcon = f'{installLocation}\\resources\\app\\resources\\win32\\default.ico'
@nidefawl
nidefawl / CMakeLists.txt
Last active December 25, 2021 13:04
Minimal CMake example. Compile all files in ./src/** to a binary in ./run/. Provides custom output names per built-type. Adds source-group and sets correct debugger settings for Visual Studio debugging.
cmake_minimum_required(VERSION 3.8)
# project name
set(BUILD_NAME "minimal-cmake-cpp")
# set VS_STARTUP_PROJECT for convenience. set before defining project. Fixes an issue I had in the past
set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT ${BUILD_NAME})
# define a C + CXX project
project(${BUILD_NAME} C CXX)
/* This crashes for me (line 19) */
#include <iostream>
#include <vector>
#include <thread>
#include <memory>
#include <chrono>
#include <mutex>
#include <assert.h>
struct mystruct_t {
@nidefawl
nidefawl / CMakeCache.txt
Created May 8, 2019 18:30
build-ca329c1c/llvm-mingw/llvm/build-x86_64-w64-mingw32/CMakeCache.txt
# This is the CMakeCache file.
# For build in directory: /opt/build2/llvm-mingw/llvm/build-x86_64-w64-mingw32
# It was generated by CMake: /usr/bin/cmake
# You can edit this file to change values found and used by cmake.
# If you do not want to change any of the values, simply exit the editor.
# If you do want to change a value, simply edit, save, and exit the editor.
# The syntax for the file is as follows:
# KEY:TYPE=VALUE
# KEY is the name of a variable in the cache.
# TYPE is a hint to GUIs for the type of VALUE, DO NOT EDIT TYPE!.
@nidefawl
nidefawl / CircuitsPlugin.java
Created May 1, 2019 20:38
CircuitsPlugin.java Craftland.org
// $Id$
/*
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
@nidefawl
nidefawl / output.txt
Created March 29, 2017 03:02
glslangvalidator compilation fail
E:\>glslangvalidator -v
Glslang Version: Overload400-PrecQual.1721 21-Dec-2016
ESSL Version: OpenGL ES GLSL 3.00 glslang LunarG Khronos.Overload400-PrecQual.1721 21-Dec-2016
GLSL Version: 4.20 glslang LunarG Khronos.Overload400-PrecQual.1721 21-Dec-2016
SPIR-V Version 0x00010000, Revision 8
GLSL.std.450 Version 100, Revision 1
Khronos Tool ID 8
GL_KHR_vulkan_glsl version 100
ARB_GL_gl_spirv version 100