Skip to content

Instantly share code, notes, and snippets.


Eric Scrivner etscrivner

View GitHub Profile
etscrivner /
Created Nov 15, 2019
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 / Makefile
Last active Feb 15, 2020
Pixel-perfect 2D collision detection in SDL.
View Makefile
.PHONY: run
CXXFLAGS=-Wall -g -fno-exceptions -fno-rtti $(shell pkg-config sdl2 --cflags)
LDFLAGS=-lm $(shell pkg-config sdl2 --libs)
$(CXX) $(CXXFLAGS) -o game $(LDFLAGS)
run: game
etscrivner /
Last active Oct 2, 2019
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
"""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
View plot.gnu
set title 'Change Frequency By File'
set ylabel '# Changes'
set xlabel 'File'
plot 'output.txt' using 0:1
etscrivner / cartographer_data_model.als
Created Apr 17, 2019
Alloy model of PSP data model
View cartographer_data_model.als
sig Defect {
phase : one Phase,
performance : one Performance,
type : one DefectType,
sig DefectType {}
fact DefectsBelongToAPhaseOfTheSameProcessAsItsPerformance {
all d : Defect | d.phase.process = d.performance.process
etscrivner / peterson_multi.tla
Last active Jan 26, 2019
TLA+ implementation of Peterson's mutual exclusion algorithm. Demonstrates absence of deadlock and liveness given fair processes.
View peterson_multi.tla
--------------------------- MODULE peterson_multi ---------------------------
EXTENDS TLC, Integers, Sequences
CONSTANT ThreadCount
Threads == 1..ThreadCount
AllOtherFlagsLessThan(item, flags) ==
\A q \in Threads \ {item}: flags[q] < item
(*--algorithm peterson_multi
#[derive(Debug, Copy, Clone, PartialEq)]
pub struct Point<T> {
pub a : T,
pub b : T,
pub x : Option<T>,
pub y : Option<T>
impl<T> Point<T> {
pub fn infinity(a: T, b: T) -> Self {
etscrivner / rpc_doctest.cpp
Last active Oct 5, 2018
Bitcoin RPC API documentation helper object prototype.
View rpc_doctest.cpp
#include <iostream>
#include <string>
#include <vector>
class RPCArgument {
RPCArgument(const std::string& name,
const std::string& type,
const std::string& description,
bool required=false,
#!/usr/bin/env ksh
# Benchmark Project Euler 1 programs by running them through same datsets
# several times and computing the average.
Values=(1000 10000 100000 1000000 10000000)
echo "${Values[@]}"
Programs=("./c_euler_1" "./haskell_euler_1")
etscrivner / main.c
Created Apr 5, 2018
Exercise 1A. Write a program to estimate the mean and standard deviation of a sample of n real numbers. Use a linked list to hold the n numbers for the calculation.
View main.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "result.h"
#include "number_list.h"
#include "population_statistics.h"
eResult read_numbers(NumberList *number_list)