Skip to content

Instantly share code, notes, and snippets.

View ikskuh's full-sized avatar
☺️
Hacking on Dunstwolke

Felix Queißner ikskuh

☺️
Hacking on Dunstwolke
View GitHub Profile
@ikskuh
ikskuh / regenerate.sh
Created June 18, 2020 22:38
Mini Gemini Server
#!/bin/bash
encodings="UTF-8 UTF-16LE UTF-16BE UTF-32LE UTF-32BE WINDOWS-1252 TCVN-5712 CP437 EBCDICATDE"
for enc in ${encodings,,}; do
echo -ne "20 text/plain charset=${enc}\r\n" > ${enc,,}.txt
echo -e "Serving content as ${enc}\n" | iconv -f "UTF-8" -t "${enc}" >> ${enc,,}.txt
iconv -f "UTF-8" -t "${enc}//TRANSLIT" ground-truth.txt >> ${enc,,}.txt
done
@ikskuh
ikskuh / container.css
Created March 28, 2020 10:19
Dunstblick (behind the scenes)
/* Resource ID = 1 */
TabLayout
{
margins: 0;
DockLayout
{
tab-title: "Menu";
Button
{
dock-site: bottom;
@ikskuh
ikskuh / zig-up.sh
Created March 27, 2020 12:24
zigup
#!/bin/bash
ROOT=$HOME/software
REPO_URL=https://ziglang.org/download/index.json
TMPDIR=/tmp/zig-update
REPO_ENTRY=x86_64-linux
function die()
{
@ikskuh
ikskuh / Generator.cs
Created January 28, 2020 22:25
HDRP Mask Map Generator
/**
* Licence: MIT
* Author: Felix Queißner, 2020
*
* Compile with:
* csc /out:Generator.cs /r:System.Drawing.dll Generator.cs
*
* Usage:
* Execute with a single file argument, this tool will generate a mask map for
* the Unity HDRP shader set. It assumes that the required files exist with
const fixed_22_10 = arithmetic(i32) {
const Self = @This();
fn add(lhs: Self, rhs: Self) Self {
return @as(Self, @value(lhs) + @value(rhs));
}
fn mul(lhs: Self, rhs: Self) Self {
return @as(Self, (@as(i64, @value(lhs)) * @as(i64, @value(rhs))) / 1024);
}
@ikskuh
ikskuh / closures.zig
Created December 8, 2019 13:19
How to emulate "downward" closures with Zig
const std = @import("std");
fn printSliceWithFilter(comptime T: type, values: []const T, context: var, filter: fn (T, @typeOf(context)) bool) void {
for (values) |val, i| {
if (!filter(val, context))
continue;
std.debug.warn("[{}] = {}\n", i, val);
}
}
@ikskuh
ikskuh / main.zig
Created December 2, 2019 07:39
Zig SDL2 Template
const std = @import("std");
// import the C headers here:
const c = @cImport({
@cInclude("SDL.h");
@cInclude("SDL_image.h");
});
/// game entry point which may return an error.
/// if the error is error.SdlError, SDL_GetError() will be called
@ikskuh
ikskuh / zig-update.sh
Last active October 17, 2019 07:36
Zig updater script
#!/bin/bash
#
# allows installing and/or updating your local
# zig installation.
#
# adjust INSTALLDIR, ZIG_OS, ZIG_TARGET to
# configure your installation.
#
# prerequisites:
# - jq (https://stedolan.github.io/jq/)
@ikskuh
ikskuh / coroutine.zig
Last active October 1, 2019 10:34
Abusing async/await to create fake threads
const std = @import("std");
/// stores some state for each coroutine
/// as well as a pointer to the frame to be resumed
const CoroutineState = struct {
pub const Self = @This();
frame: anyframe = undefined,
quit: bool = false,
active: bool = false,
@ikskuh
ikskuh / allocator.cpp
Last active September 18, 2019 13:06
C++ simple block allocator
#include <cstdint>
#include <cstddef>
#include <bitset>
// WARNING: Code untested!
/// @tparam LowAddress Inclusive lower address of allocation size
/// @tparam HighAddress Inclusive upper bound of allocation size
/// @tparam BlockSize Size of minimal allocation size
template<uintptr_t LowAddress, uintptr_t HighAddress, size_t BlockSize>