Skip to content

Instantly share code, notes, and snippets.

@mrallen1
mrallen1 / thai_tofu.md
Last active Apr 27, 2021
thai peanut crispy fried tofu on zoodles
View thai_tofu.md

Thai peanut sauce crispy tofu over zucchini noodles

  • 1 pkg extra firm tofu
  • 1 T olive oil
  • 1/4 c peanut butter
  • 2 T tamari
  • 1 1/2 T rice wine vinegar
  • 1 t minced garlic
  • 1 t minced ginger
@mrallen1
mrallen1 / ss.erl
Created Aug 21, 2019
Self Stabilizing Systems in Spite of Distributed Control
View ss.erl
%% @doc
%% This Erlang module implements the ideas illustrated in Edsger Dijkstra's
%% famous paper "Self Stabilizing Systems in Spite of Distributed Control"
%% http://courses.csail.mit.edu/6.852/05/papers/p643-Dijkstra.pdf
%% @end
-module(ss).
-export([stop/1, show/1, start/1]).
-define(DELAY, 1000).
-define(THRESHOLD, 0.90).
@mrallen1
mrallen1 / pro.pl
Created Aug 1, 2018
Russian personal pronouns
View pro.pl
#!/usr/bin/env perl
use 5.014;
use utf8;
use Text::CSV qw(csv);
use List::Util qw(shuffle pairs);
use List::MoreUtils qw(zip);
my $pn = {
@mrallen1
mrallen1 / refs.md
Last active Jan 4, 2018
Using references in jesse for JSON schema validation
View refs.md

If you use the [jesse][1] application for JSON schema validation, you will no doubt be mystified by the byzantine way that references are handled in the application. I spent well over 30 hours trying to figure it out, since it is totally undocumented what the format should be.

I tried to make things as simple as possible. I had a file with the "base" schema for an item. I called it record.json It looked something like this:

{
   "id": "record",
   "description": "Base schema for a valid record",
   "type": "object",
   
@mrallen1
mrallen1 / surface2.md
Created Dec 12, 2017
Developing on SurfaceBook 2
View surface2.md

I recently made the switch back to Windows 10 after spending 15 years using a Mac as my personal laptop. I won't go into all of the rationale behind that decision but the most succinct answer is that I have felt like Apple's doing me a favor by buying their products, not the other way around for the past three releases of macOS. As a rather committed vi partisan, removing the ESC key from the high end Mac Book Pros was kind of the final straw.

In any case, I bought my Surface Book 2 about two weeks ago. This past weekend, I took part in [Spawnfest][1], a 48 hour programming contest aimed at Erlang/Elixir. I wrote all of the code on the Surface Book 2 and I know some people are interested in my experience.

So keeping with the usual trite cliches, I'll use the "Good", "Bad" and "Ugly."

Good

  • Windows Subsystem for Linux was flawless during my work. I used it exclusively to develop code. Git and Erlang and every other tool I needed Just Worked, and worked well.
@mrallen1
mrallen1 / rebar3_hex_v2_resources.erl
Last active Mar 17, 2018
Using hex v2 resources in Erlang
View rebar3_hex_v2_resources.erl
%% A strawman implementation to kick around
-module(rebar3_hex_v2_resources).
-export([
start/0,
decode_resource_from_disk/2,
download_resource/1
]).
%% needs application:ensure_all_started(public_key).
@mrallen1
mrallen1 / expedition.md
Last active Aug 21, 2017
Playing Expedition RPG card game with my kids
View expedition.md

Playing Expedition RPG card game with my kids

I spent a few hours playing [Expedition RPG card game][1] with my kids today and I wanted to write up something longer than a tweet to share our experience. If you haven't heard of Expedition, it's along the lines of a more-or-less standard "fantasy" world with fantastic creatures and hardy adventurers, but without so many rules in in it. The mechanics for combat are very lightweight -- more like a LARP type system, but even more streamlined. The pretty cool "twist" to this is the use of a phone app (the app is available for both iOS and Android) to help mediate some of the storytelling and combat.

Players each get an adventurer card which lays out a very barebones personality ("hungry chef", "dutiful soldier", "fretful bard", etc) and six abilities in Magic, Music, Melee or Ranged. Each adventurer has 12 health points. These abilites are part of four decks of cards which are shuffled and dealt out. Depending on t

@mrallen1
mrallen1 / ringbuffer.erl
Last active Aug 2, 2017
ringbuffer interface using a normal Erlang list
View ringbuffer.erl
-module(ringbuffer).
-ifdef(TEST).
-include_lib("eunit/include/eunit.hrl").
-compile([export_all]).
-else.
-export([
new/0,
new/1,
get_head/1,
@mrallen1
mrallen1 / ngram.erl
Created Jun 26, 2017
ngram builder for Erlang
View ngram.erl
-module(ngram).
-compile([export_all]).
ngram(N, Str) ->
make_ngram(N, Str, 1, orddict:new()).
make_ngram(_N, Str, Pos, Acc) when Pos >= length(Str) -> Acc;
make_ngram(N, Str, Pos, Acc) ->
make_ngram(N, Str, Pos+1, orddict:update_counter(lists:sublist(Str, Pos, N), 1, Acc)).
@mrallen1
mrallen1 / build.md
Last active Jun 10, 2021
Building Erlang on WSL/Ubuntu 16.04(LTS)
View build.md

Building Erlang on Windows Subsystem for Linux (WSL)

WSL Overview

WSL is a driver shim for Windows 10 that enables you to run native Linux code on Windows without recompiling or running a Docker/VM. It currently supports Ubuntu 16.04 LTS - but more distribution support has been announced.

Building Erlang

From a "clean" install of Ubuntu such as the kind you would get from a fresh install of WSL, you need to preinstall these debs to enable kerl to compile a working Erlang: