Skip to content

Instantly share code, notes, and snippets.

🦋

Eric Scrivner etscrivner

🦋
Block or report user

Report or block etscrivner

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@etscrivner
etscrivner / audio_mixer.cc
Created Nov 15, 2019
Simple audio mixer in SDL2
View audio_mixer.cc
#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 Nov 7, 2019
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)
game: game.cc
$(CXX) $(CXXFLAGS) -o game game.cc $(LDFLAGS)
run: game
./game
@etscrivner
etscrivner / feature_package_relay.py
Last active Oct 2, 2019
Add test that three transaction package relay fails.
View feature_package_relay.py
#!/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
View plot.gnu
set title 'Change Frequency By File'
set ylabel '# Changes'
set xlabel 'File'
plot 'output.txt' using 0:1
@etscrivner
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
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
variables
View failure.rs
#[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
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 {
public:
RPCArgument(const std::string& name,
const std::string& type,
const std::string& description,
bool required=false,
View benchmark.sh
#!/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
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)
You can’t perform that action at this time.