Skip to content

Instantly share code, notes, and snippets.

View LAK132's full-sized avatar
😭

LAK132

😭
View GitHub Profile
@LAK132
LAK132 / results.c
Last active December 5, 2023 12:57
Result types in C
#ifndef __cplusplus
# define decltype typeof
# include <stdbool.h>
#endif
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#define TOKEN_CONCAT_EX(x, y) x##y
#define TOKEN_CONCAT(x, y) TOKEN_CONCAT_EX(x, y)
@LAK132
LAK132 / Makefile
Last active January 7, 2021 14:35
Makefile but it uses Tiny C Compiler to open an Xlib/GLX window
#if 0
ifneq ($(shell grep -a -h -i microsoft /proc/version),)
# // For use on Windows (WSL) with cygwinX
# // Requires xinit, xauth and xhost probably
# // Start the X11 server with `path\to\cygwin64\bin\run.exe --quote /usr/bin/bash.exe -l -c "cd; exec /usr/bin/startxwin -- +iglx -listen tcp"`
# // If you get "Authorization required, but no authorization protocol specified"
# // then try running `DISPLAY=:0.0 xhost +` in the cygwin terminal after
# // starting the X11 server.
DISPLAY = "`cat /etc/resolv.conf | grep nameserver | awk '{ print $$2 }'`:0.0"
LIBGLARGS = LIBGL_ALWAYS_INDIRECT=1 LIBGL_ALWAYS_SOFTWARE=1
@LAK132
LAK132 / Makefile
Last active March 8, 2023 14:00
C++ embedded in a Makefile
#if 0
.PHONY: run
run: out.elf
./out.elf
out.elf: Makefile
g++ -o $@ -x c++ $^
ifeq (0, 1)
#endif
#include <stdio.h>
int main()
@LAK132
LAK132 / Makefile
Last active January 6, 2021 02:08
Makefile DISPLAY example for when getting the IP address of the X11 server is required under WSL/cygwinX
ifneq ($(shell grep -a -h -i microsoft /proc/version),)
# // For use on Windows (WSL) with cygwinX
# // Requires xinit, xauth and xhost probably
# // Start the X11 server with `path\to\cygwin64\bin\run.exe --quote /usr/bin/bash.exe -l -c "cd; exec /usr/bin/startxwin -- +iglx -listen tcp"`
# // If you get "Authorization required, but no authorization protocol specified"
# // then try running `DISPLAY=:0.0 xhost +` in the cygwin terminal after
# // starting the X11 server.
DISPLAY = "`cat /etc/resolv.conf | grep nameserver | awk '{ print $$2 }'`:0.0"
LIBGLARGS = LIBGL_ALWAYS_INDIRECT=1 LIBGL_ALWAYS_SOFTWARE=1
endif
@LAK132
LAK132 / flibitPackaging.md
Created September 10, 2019 10:30 — forked from flibitijibibo/flibitPackaging.md
Hope you like reading ldd output!

A week ago I was CC'd in on a thread about Linux packaging, and how to avoid doing it the wrong way (i.e. RPM, Deb, etc.). I've always used MojoSetup and I've never forced distributions to do any additional work, but this is still a new concept to a lot of people. Additionally, Amos suggested that I expand on Itch's FNA appendix, so here's a guide on how I package my games.

This is a bit of an expansion on my MAGFest 2016 presentation, which you can find here:

http://www.flibitijibibo.com/magfest2016/

https://www.youtube.com/watch?v=B83CWUh0Log

I would recommend looking at that first! After that, read on...

@if (@a==@b) @end /*
@echo off
SetLocal EnableDelayedExpansion
for /f "delims=" %%A in ('cscript /nologo /e:jscript "%~f0" %*') do ( call %%A )
goto :eof
*/
var print = function(str) { if (str) WSH.Echo("echo " + str); }
var system = function(str) { WSH.Echo(str); }
var argc = WSH.Arguments.Length;
var argv = function(ind) { return WSH.Arguments(ind); }
#!/bin/bash
# Copyright (C) InnoviData GmbH <http://www.innovidata.com>, 2011.
# Author: Holger Widmann <holger.widmann@innovidata.com>
# Version: 1.2.20110610
#
# License:
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License (LGPL) as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
@LAK132
LAK132 / constexpr_hash.hpp
Created August 6, 2018 05:11
Compile time constexpr string hashing
/*
This implementation is taken from Stack Overflow
Question: https://stackoverflow.com/questions/2111667/compile-time-string-hashing
Answer: https://stackoverflow.com/a/23683218/1924457
Authors: https://stackoverflow.com/users/1559666/tower120 https://stackoverflow.com/users/1904419/redwizard792
This code is licensed under CC-BY-SA as required by SO https://creativecommons.org/licenses/by-sa/3.0/
Slight modification has been made (name changes + namespace)
*/
#include <cstddef>
@LAK132
LAK132 / filebrowser.cpp
Last active March 23, 2022 07:25
Cross platform file system browser using Dear ImGui and std::filesystem
template<typename T> struct complete
{
bool good = true, done = false;
T value;
complete() {}
complete(const T& t, bool g = true, bool d = false) : value(t), good(g), done(d) {}
complete(T&& t, bool g = true, bool d = false) : value(t), good(g), done(d) {}
};
void windowOpenPath(complete<fs::path>& dir, bool file = true)
{
@LAK132
LAK132 / epoch.bat
Created August 3, 2018 07:57
Get a file's last modified epoch in batch
@if (@a==@b) @end /*
@echo off
SetLocal EnableDelayedExpansion
set EPOCH=0
FOR /F "delims=" %%D in ('cscript /nologo /e:jscript "%~f0" "%1"') do (
set EPOCH=%%D
)
echo Last modified (epoch-seconds): !EPOCH!