Skip to content

Instantly share code, notes, and snippets.

View KillerGoldFisch's full-sized avatar

Kevin Gliewe KillerGoldFisch

View GitHub Profile
@KillerGoldFisch
KillerGoldFisch / conditional_template.cpp
Last active September 29, 2023 16:06
Example for a conditional template definition, where the compiler distinguishes between types that define a static method or not.
#include <iostream>
#include <type_traits>
// Helper Struct for checking the existence of the static method.
// This struct defaults to std::false_type (indicating the method does not exist)
template <typename T, typename = void>
struct has_static_method : std::false_type {};
// Specialization of has_static_method for types T that do have a static_method.
// The std::void_t<decltype(T::static_method())> is a void type if T::static_method() is a valid expression,
@KillerGoldFisch
KillerGoldFisch / stacktrace.cxx
Created January 24, 2023 21:52 — forked from fmela/stacktrace.cxx
A C++ function that produces a stack backtrace with demangled function & method names.
/*
* Copyright (c) 2009-2017, Farooq Mela
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
@KillerGoldFisch
KillerGoldFisch / docker-dive-alias.sh
Created October 26, 2022 09:20
Create alias for wagoodman/dive image
alias dive="docker run --rm -it -v /var/run/docker.sock:/var/run/docker.sock wagoodman/dive:latest"
@KillerGoldFisch
KillerGoldFisch / gist:cfbc765fc5bfbf70e653fdfbae3f7de2
Created July 19, 2022 08:16 — forked from lontivero/gist:593fc51f1208555112e0
Generates Markdown from VS XML documentation file
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Xml;
using System.Xml.Linq;
namespace GithubWikiDoc
{
@KillerGoldFisch
KillerGoldFisch / main.c
Created May 13, 2022 22:52 — forked from Mashpoe/main.c
ASCII Tesseract Rotation C Program
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <windows.h>
// width and height of screen
#define ww 100
#define wh 50
void clr(CHAR_INFO* d)
@KillerGoldFisch
KillerGoldFisch / main.rs
Last active February 8, 2022 15:00
Working with references in Rust
use std::cell::RefCell;
use std::rc::Rc;
struct InternalWriter {
indent_count: u32,
stringwriter: String
}
impl InternalWriter {
fn new() -> InternalWriter {
@ECHO OFF
CLS
ECHO.
ECHO.
ECHO NOTE: This must be run with administrative privileges!
ECHO If you did not right-click on this .bat and select
ECHO "Run as administrator" then exit now and run again
ECHO.
ECHO.
PAUSE
@KillerGoldFisch
KillerGoldFisch / cmake-vcpkg.bat
Created September 1, 2021 15:16
cmake batch with MAKE_TOOLCHAIN_FILE for vcpkg
@echo off
cmake -DCMAKE_TOOLCHAIN_FILE="%~dp0\vcpkg\scripts\buildsystems\vcpkg.cmake" %*
exit /b
/******************************************************************************
Shader Fast Math Lib (v0.41)
A shader math library for optimized approximate transcendental functions.
Optimized and tested on AMD GCN architecture.
Release notes:
v0.41 minor bug fixes, missing references
v0.4 new constants calculated for new ranges, minor optimization and precision improvements
@KillerGoldFisch
KillerGoldFisch / r42.rs
Last active August 14, 2021 15:25
Rust R42 template generator.
enum TemplateContext {
Template,
Code,
Expression,
}
pub fn transform(input: &str) -> String {
let mut code_buffer = String::with_capacity((input.len() as f32 * 1.2f32) as usize);
let mut expression_buffer = String::with_capacity(128);