Skip to content

Instantly share code, notes, and snippets.

View etscrivner's full-sized avatar
🦋

Eric Scrivner etscrivner

🦋
View GitHub Profile
@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
@etscrivner
etscrivner / font_bake_sdf.cc
Created February 1, 2020 19:34
Bake SDF font bitmaps using stb libraries.
#include <SDL.h>
#include <GL/glew.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <scaffold/types.h>
#include <scaffold/vec.h>
#include <scaffold/matrix.h>
#include <scaffold/gl.h>
@etscrivner
etscrivner / render_hiero_font.cc
Last active December 1, 2019 20:55
Parse and render text from SDF font generated by Hiero.
#include <SDL.h>
#include <GL/glew.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <scaffold/types.h>
#include <scaffold/gl.h>
#include <scaffold/memory_arena.h>
#include <scaffold/matrix.h>
@etscrivner
etscrivner / bulk_list.c
Created November 23, 2019 20:57
Bulk list data structure.
#include "bulk_list.h"
#include <stdio.h>
#include <stdlib.h>
bulk_list_t bulk_list_create(int32_t initial_capacity, bulk_list_item_id_t item_size)
{
bulk_list_t result = { NULL, item_size, initial_capacity, 1, 0, 0, 1 };
result.items = (uint8_t*)realloc(result.items, result.capacity * result.item_size);
((bulk_list_item_t*)&result.items[0])->next = 0;
@etscrivner
etscrivner / audio_mixer.cc
Created November 15, 2019 16:38
Simple audio mixer in SDL2
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <SDL.h>
typedef uint32_t u32;
typedef int32_t i32;
typedef uint16_t u16;
@etscrivner
etscrivner / Makefile
Last active November 15, 2023 19:49
Pixel-perfect 2D collision detection in SDL.
.PHONY: run
CXXFLAGS=-Wall -g -fno-exceptions -fno-rtti $(shell pkg-config sdl2 --cflags)
LDFLAGS=-lm $(shell pkg-config sdl2 --libs)
game: game.cc
$(CXX) $(CXXFLAGS) -o game game.cc $(LDFLAGS)
run: game
./game
@etscrivner
etscrivner / feature_package_relay.py
Last active October 2, 2019 14:29
Add test that three transaction package relay fails.
#!/usr/bin/env python3
# Copyright (c) 2019 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test processing of two-transaction packages"""
from decimal import Decimal
from test_framework.messages import FromHex, CTransaction, msg_witness_tx
from test_framework.mininode import P2PInterface
from test_framework.test_framework import BitcoinTestFramework