Skip to content

Instantly share code, notes, and snippets.

View dk949's full-sized avatar

David K dk949

View GitHub Profile
@dk949
dk949 / print.hpp
Last active February 25, 2025 10:50
C++20 sensible print macros. Uses std::format (including vector formatting). See "Usage" at the top of the file.
#ifndef UT_PRINT_HPP
#define UT_PRINT_HPP
/* Usage:
```
// std >= c++20
auto number = 42;
ut_print("the number is {}", number);
```
output to stdout: the number is 42
@dk949
dk949 / binfmt.h
Last active January 10, 2024 20:28
Binary number formater for C. See commend for usage.
/*
Format integers as binary numbers. Expects little endian numbers.
License: See end of file
*/
/* Usage:
* int i = 42;
* printf("i = 0b" BIT_FMT32 "\n", BIT_ARG32(i));
* // Output: i = 0b00000000000000000000000000101010
@dk949
dk949 / pseudocode.xml
Last active January 10, 2024 20:02
KDE synatx highlighting file for pseudocode. Supports some commonly used pseudocode keywords, as well as structured english descriptions surrounded by double chevrons.
<!--
KDE synatx highlighting file for pseudocode (https://github.com/KDE/syntax-highlighting)
Based on the Zig highlighting file (https://raw.githubusercontent.com/KDE/syntax-highlighting/master/data/syntax/zig.xml).
Intended for use with pandoc, but will probably work with kate too
-->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE language [
<!ENTITY bin_int "(?:[01]+(?:_[01]+)*)">
<!ENTITY oct_int "(?:[0-7]+(?:_[0-7]+)*)">
@dk949
dk949 / build_zls.sh
Last active August 11, 2023 12:21
Build zls for different versions of Zig
#!/bin/bash
set -e
# VERSION_LIST=("0.7.0" "0.7.1" "0.8.0" "0.8.1" "0.9.0" "0.9.1" "0.10.0" "0.10.1" "0.11.0" "master")
VERSION_LIST=("0.9.1" "0.10.1" "0.11.0" "master")
git clone https://github.com/zigtools/zls
cd zls
@dk949
dk949 / todonotes.lua
Last active May 15, 2023 22:27
Pandoc filter to insert todonotes todos without inline latex
--[[
See bottom of scrip for license
Usage:
---
header-includes: |
\usepackage{todonotes}
...
@dk949
dk949 / numbered-links.lua
Last active January 10, 2024 20:00
Pandoc numbered section links
@dk949
dk949 / .vimrc
Last active December 20, 2024 18:50
*Very* basic vimrc to use on remote computers
" Options
filetype plugin on
filetype plugin indent on
syntax on
set number relativenumber
au InsertLeave * set number relativenumber
au InsertEnter * set number norelativenumber
@dk949
dk949 / cstimer_dracula.md
Created January 11, 2023 19:26
Dracula theme for cstimer.net

Dracula theme for csTimer

How to apply

In options go to the Color tab, select manual color scheme and press export. Paste the following code into the dialog box.

Just Ui colors

N4Igxg9gNhBOIC4QFcQBpzQLQDMIDsAXREAYhwA5KcAmdTKLAIwEMwBrE0mimlgZgBs9SIyYQWsACZcALPIDsAVhYjsTZIUIEuTKQE5+OfWsZQAlvk5JSSgAw4WCpqawwA5hC44AjI4pgrh4QrBxcPHxCIAC+QA
@dk949
dk949 / Makefile
Last active April 1, 2024 20:56
A makefiel for compileing C and C++ projects with support for debug and release modes.
########################### High level configuration ###########################
# If building a library (see DO_BUILD_LIB below) do not add prefix and extension
# i.e. use myLibName instead of libmyLibName.a
OUT_NAME = myExeName
VERSION=0.1.0
# Compiler, linker, archiver, package config
CC ?= gcc
CXX ?= g++
/* License: MIT. See end of file.
Overview:
This implementation is heavily based on macros (it's nothing but
macros). In order to get actual functions and structs they need to be
instantiated. Two helpers are provided for this: DECLARATIONS_Queue(T)
and DEFINITIONS_Queue(T). Place DECLARATIONS_Queue(T) in one (1) header
file. Place DEFINITIONS_Queue(T) in one (1) source file which includes
that header file. Define GENERIC_QUEUE_IMPL before including. Replace T
with your desired type. See example below