Skip to content

Instantly share code, notes, and snippets.

View emctague's full-sized avatar
🖥️
Probably Coding

Ethan McTague emctague

🖥️
Probably Coding
View GitHub Profile
@emctague
emctague / payload.c
Created April 11, 2023 00:08
The Payload Server: A Fast Single-File HTTP Server
// THE PAYLOAD SERVER
// by Ethan McTague
// Apr 10, 2023
//
// This is a single-file HTTP Server. It serves a single file, compressed,
// as quickly as it possibly can, to every single client that connects.
// The entire HTTP response is pre-buffered once at server startup.
//
// Free to use and modify, released as public-domain software. Enjoy!
//
@emctague
emctague / template.go
Created April 16, 2022 03:47
Golang Template Abstraction for Debugging
type TplRunner interface {
Execute(w io.Writer, data any) error
}
type DebugTplRunner string
func (r DebugTplRunner) Execute(w io.Writer, data any) error {
t, err := template.ParseFiles(string(r))
if err != nil {
return err
@emctague
emctague / lhtml.lisp
Created September 16, 2021 17:25
LHTML - Convert S-Expressions to HTML
; LHTML
; -----
;
; Generate HTML code from a sequence of lisp s-expressions.
; This operates on stdin and prints to stdout.
;
; (For clisp.)
;
; Please for the love of all that is good do not use this in production.
; The code is barely readable!
@emctague
emctague / GLSLPreproCMakeUtil.cmake
Last active April 9, 2021 23:42
GLSL Preprocessor
function(add_shader TARGET SHADER)
set(ShaderPath ${CMAKE_CURRENT_SOURCE_DIR}/${SHADER})
set(OutPath ${CMAKE_CURRENT_BINARY_DIR}/${SHADER})
add_custom_command(
OUTPUT ${OutPath}
COMMAND python3 ${CMAKE_SOURCE_DIR}/glslprepro.py ${ShaderPath} ${OutPath}
DEPENDS ${ShaderPath} ${ARGN} ${CMAKE_SOURCE_DIR}/glslprepro.py
VERBATIM)
@emctague
emctague / README.md
Last active February 3, 2021 14:50
JavaScript Generator Utility Functions

This source file modifies the prototype of Generator Function objects to provide the following functions already available to arrays, allowing them to operate on demand on generators:

  • map

  • reduce

  • join

  • forEach

@emctague
emctague / README.md
Last active August 21, 2020 15:47
Mini C Argument Parser

margp

margp is a miniature argument parsing library for standard C.

It parses simple POSIX-style short and long flags.

It is licensed under the MIT license.

Supported flag formats

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main() {
srand(time(NULL));
int allTries = 1000;
int switchWins = 0;
@emctague
emctague / TupleToArray.swift
Created January 29, 2020 00:24
Tuple to Array Conversion for Swift
/**
# Tuple-to-array for Swift
By Ethan McTague - January 28, 2020
This source code is in the public domain.
## Example
To convert a tuple of Ints into an array of ints:
@emctague
emctague / bd-gruvbox.css
Last active February 8, 2024 18:52
Gruvbox Hard Dark - BetterDiscord Theme
//META{"name":"Gruvbox Hard Dark","description":"Themes your Discord using Gruvbox colors.","author":"Ethan McTague","version":"1.0"}*//
/* BetterDiscord Gruvbox Theme - By Ethan McTague
Compatible with the latest version of Discord (as of Jan 23, 2020.)
Copyright 2020 Ethan McTague <ethan@tague.me>
Licensed under the BSD 3-clause license.
@emctague
emctague / When.cs
Created January 14, 2020 17:18
When - Conditional EntityFramework Validation using Attributes
//
// When
//
// Allows for vertain validation rules to only apply under certain conditions, using only an Attribute.
// e.g., if a certain string should match the regex `^.+@.+$` when another property, "WantsEmail", is equal to `true`:
//
// [When("WantsEmail", true, typeof(DoesRegexMatch), "^.+@.+$", Error = "Wants email, but none provided!"]
// public string AProperty { get; set; }
//