Skip to content

Instantly share code, notes, and snippets.

View etscrivner's full-sized avatar
🦋

Eric Scrivner etscrivner

🦋
View GitHub Profile
@etscrivner
etscrivner / ast.c
Last active May 25, 2024 23:29
Simple math expression tokenizer and parser in C.
#include <assert.h>
#include <stdio.h>
#include <stdbool.h>
#include <stdarg.h>
typedef enum eToken_Type eToken_Type;
enum eToken_Type {
TOKENTYPE_number,
TOKENTYPE_operator,
TOKENTYPE_lparen,
@etscrivner
etscrivner / Bayer.c
Created October 12, 2023 19:38
Dithering on a grayscale bitmap with 2x2, 4x4, and 8x8 Bayer matrices.
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "ext/stb_image_write.h"
uint8_t* GenerateGrayGradientBitmap(int width, int height) {
uint8_t* result = (uint8_t*)malloc(width * height);
@etscrivner
etscrivner / japser.c
Created May 9, 2021 00:09
Jasper is a simple markdown parser that uses successive application of rewriting rules to apply markdown to a file.
// jasper.c - Processor for custom flavor of markdown called jasperstone
//
// Description:
//
// Jasperstone processes a markup file by applying a set of rewriting rules to
// the document. Each rewriting rule processes the entire document replacing a
// particular piece of syntax. The end result is a file that is completely
// marked up without the need for a complex parser.
#include <inttypes.h>
#include <stdarg.h>
@etscrivner
etscrivner / tea-timer.el
Created June 9, 2020 02:53
Tea steep timer. Blinks the modeline bar red when the tea is done steeping.
;;
;; Simple timer that will blink the mode-line bar.
;;
;; Example Usage:
;;
;; Set a timer for 5 secs from now:
;;
;; (blink-bar-after-timer "5 sec")
;;
;; Set a timer for when tea has steeped after 3 mins:
#if !defined(EMACS_COMMAND_MAP_H)
#define EMACS_COMMAND_MAP_H
// Create custom ID for our global emacs state data.
CUSTOM_ID(attachment, view_emacs_state_id);
CUSTOM_COMMAND_SIG(close_all_other_panels)
CUSTOM_DOC("Closes all other panels but the currently active one")
{
View_ID current_active_view_id = get_active_view(app, Access_Always);
@etscrivner
etscrivner / sha2.h
Created February 27, 2020 17:34
Single-header file SHA2 implementation from FreeBSD.
/* $FreeBSD: src/sys/crypto/sha2/sha2.h,v 1.1.2.1 2001/07/03 11:01:36 ume Exp $ */
/* $KAME: sha2.h,v 1.3 2001/03/12 08:27:48 itojun Exp $ */
/*
* sha2.h
*
* Version 1.0.0beta1
*
* Written by Aaron D. Gifford <me@aarongifford.com>
*
@etscrivner
etscrivner / init.el
Created February 20, 2020 05:54
Emacs dotfiles
;;; init.el --- The emacs configuration entry-point
;;;
;;; Commentary:
;;; This is the first file executed when emacs is initialized.
;;;
;;; Code:
;; Determine our dotfiles directory
(defun get-dotfiles-directory ()
"Returns the directory the Emacs dotfiles are in."
@etscrivner
etscrivner / markdown.cc
Created February 4, 2020 05:25
Very basic markdown parser in C
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
typedef uint32_t u32;
typedef int32_t i32;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;
@etscrivner
etscrivner / markdown.cc
Created February 4, 2020 05:25
Very basic markdown parser in C
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
typedef uint32_t u32;
typedef int32_t i32;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;
#include <SDL.h>
#include "language_layer.h"
#include "memory_arena.h"
#define STB_TRUETYPE_IMPLEMENTATION
#include "stb_truetype.h"
#define WINDOW_WIDTH 1920
#define WINDOW_HEIGHT 1080