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 / 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 / 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 / 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 / 4k.c
Created July 3, 2020 13:34
Horrible X11 setup
#include <GL/glx.h>
#include <unistd.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <X11/X.h>
#include <X11/Xlib.h>
#include <dlfcn.h>
#include <signal.h>
@ikskuh
ikskuh / build.zig
Created September 21, 2020 07:59
build.zig example
const std = @import("std");
const pkgs = struct {
const sdl2 = std.build.Pkg{
.name = "sdl2",
.path = "./lib/SDL.zig/src/lib.zig",
};
const zlm = std.build.Pkg{
.name = "zlm",
@ikskuh
ikskuh / event_loop.zig
Created October 25, 2020 19:39
Embedded Device Event Loop
pub fn main() !void {
SysTick.init(1_000);
EventLoop.init();
var serial_frame = async doSerialLoop();
var blinky_frame = async doBlinkyLoop();
EventLoop.run();
const std = @import("std");
// debug switch to print all found anagrams
const print_all_results = false;
pub fn main() !void {
// arena for fast allocations
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
defer arena.deinit();
@ikskuh
ikskuh / async_await.zig
Last active July 11, 2022 08:41
Async Await in 60 LOC
const std = @import("std");
// usage:
fn asyncMain() !void {
// Start two interleaving tasks
var task_a = async waitUntilAndPrint(start + 1000, start + 1200, "task a");
var task_b = async waitUntilAndPrint(start + 500, start + 1300, "task b");
var task_c = async waitUntilAndPrint(start + 800, start + 1100, "task c");
await task_a;
@ikskuh
ikskuh / closure.zig
Last active November 2, 2023 22:19
Zig Closure Implementation
const std = @import("std");
pub fn main() void {
std.log.info("mutable closure:",.{});
runMutDemo();
std.log.info("const closure:",.{});
runConstDemo();
}
@ikskuh
ikskuh / interface.zig
Last active December 12, 2022 07:29
Zig Interface Implementation
const std = @import("std");
const WriterSpec = struct {
pub const write = fn(self: *@This(), msg: []const u8) error{IoError}!void;
pub const flush = fn(self: @This()) void;
};
const Writer = Interface(WriterSpec);