Skip to content

Instantly share code, notes, and snippets.

@mdavis199
mdavis199 / custom_iterator.cpp
Created July 5, 2022 09:34 — forked from jeetsukumaran/custom_iterator.cpp
Sample C++/STL custom iterator
// Sample custom iterator.
// By perfectly.insane (http://www.dreamincode.net/forums/index.php?showuser=76558)
// From: http://www.dreamincode.net/forums/index.php?showtopic=58468
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <cassert>
@mdavis199
mdavis199 / imguiverticaltext.h
Created June 30, 2022 05:43 — forked from Flix01/imguiverticaltext.h
ImDrawList methods to display vertical text in ImGui
#pragma once
#include <imgui.h>
#include <imgui_internal.h>
// ImDrawList methods to display vertical text
/*
// TEST: inside a window:
ImGuiWindow* window = ImGui::GetCurrentWindow();
ImDrawList* dl = window->DrawList;
@mdavis199
mdavis199 / edtaa3func.h
Created June 30, 2022 05:43 — forked from Flix01/edtaa3func.h
A Signed Distance Font Builder for Dear ImGui
/*
* edtaa3()
*
* Sweep-and-update Euclidean distance transform of an
* image. Positive pixels are treated as object pixels,
* zero or negative pixels are treated as background.
* An attempt is made to treat antialiased edges correctly.
* The input image must have pixels in the range [0,1],
* and the antialiased image should be a box-filter
* sampling of the ideal, crisp edge.
// On Ubuntu, I can compile it with the following command line (provided that imgui.h is two folders up, and that I want to use glfw):
// gcc -o basicExample mainBasic.cpp -I"../../" ../../imgui.cpp ../../imgui_draw.cpp -D"IMGUI_INCLUDE_IMGUI_USER_H" -D"IMGUI_INCLUDE_IMGUI_USER_INL" -I"/usr/include/GLFW" -D"IMGUI_USE_GLFW_BINDING" -L"/usr/lib/x86_64-linux-gnu" -lglfw -lX11 -lm -lGL -lstdc++ -s
// This file is intended to test/answer to https://github.com/Flix01/imgui/issues/15
// RESULT:
// Dynamic enum works!
// And if you can use dynamic_cast<>() making new Node types that use it is easier (non-intrusive)
// Otherwise you must modify the code of CustomEnumEditorNode::render(...) for every new user class you add.
//
// Added also some code to serialize/deserialize the enum names ("TestEnumNames") together
@mdavis199
mdavis199 / mini_mp3_radio_decoder.c
Created June 30, 2022 05:40 — forked from Flix01/mini_mp3_radio_decoder.c
Very basic single-file, plain C, openAL mp3 radio decoder
// gist made after this issue: https://github.com/mackron/dr_libs/issues/142
/*
The license refers to this single file.
Every included or linked library comes with its own license
===============================================================================
Public Domain (www.unlicense.org)
===============================================================================
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
software, either in source code form or as a compiled binary, for any purpose,
@mdavis199
mdavis199 / imgui_virtual_keyboard.cpp
Created June 30, 2022 05:39 — forked from Flix01/imgui_virtual_keyboard.cpp
Complete keyboard prototype for Dear ImGui version 1.87.
/* This code is an extension of the 'keyboard section' present in 'imgui_demo.cpp'.
License is the same (MIT License AFAIK)
*/
#include <imgui_virtual_keyboard.h>
namespace ImGui {
// VirtualKeyboard Implementation
const char** GetKeyboardLogicalLayoutNames() {
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
@mdavis199
mdavis199 / fix-powershell-context-menu.reg
Created June 25, 2022 11:03 — forked from SCP002/configure-ps1-context-menu.reg
Windows Registry: Run PowerShell scripts with double click. Various tweaks of context menu for .ps1 and .psm1 files. See coments for description.
Windows Registry Editor Version 5.00
; WARNING:
; Uses Visual Studio Code as a standard editor.
; You might change it to your own with default file path, like:
;
; [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit\Command]
; @="\"C:\\Windows\\System32\\notepad.exe\" \"%1\""
;
@mdavis199
mdavis199 / popen.py
Created June 25, 2022 11:00 — forked from SCP002/popen.py
Python: Start process. Keep StdOut and StdErr in the original order. Display output real time character by character. Capture output on exit.
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# Requirements:
# Python 3.7+ (uses data classes, lines 16 and 25).
import dataclasses as dc
import os
import subprocess
import sys
@mdavis199
mdavis199 / init_console_handlers_windows.go
Created June 25, 2022 10:57 — forked from SCP002/init_console_handlers_windows.go
Golang: Initialize console handlers after AttachConsole or AllocConsole on Windows.
// Used in https://github.com/SCP002/terminator.
package main
import (
"errors"
"os"
"golang.org/x/sys/windows"
)