Skip to content

Instantly share code, notes, and snippets.

View ziplist.ex
defmodule ZipList do
defstruct previous: [], current: nil, remaining: []
def from_list(list, index \\ 0)
def from_list([], _), do: {:error, :empty_list}
def from_list(list, index) when length(list) < index, do: {:error, :index_out_of_bounds}
def from_list(list, index) when is_list(list) do
previous = list |> Enum.take(index) |> Enum.reverse
[current | remaining] = Enum.drop list, index
ziplist = %__MODULE__{previous: previous, current: current, remaining: remaining}
@rob-brown
rob-brown / Actor.swift
Last active Mar 8, 2018
Elixir-inspired concurrency primitives
View Actor.swift
//
// Actor.Swift
//
// Copyright (c) 2017 Robert Brown
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
@rob-brown
rob-brown / SecretMessage.exs
Last active Jan 14, 2018
Encode secret messages into text using zero-width spaces
View SecretMessage.exs
defmodule SecretMessage do
@zero "\u200C"
@one "\u200D"
def encode(text, secret) when byte_size(text) > byte_size(secret) do
secret
|> obfuscate
|> Stream.concat(Stream.repeatedly fn -> "" end)
|> Stream.zip(String.codepoints text)
View NewReactor.swift
import Foundation
import Actor
import MessageRouter
public final class Core<State, Event, Command> {
public typealias CommandProcessor = (Core<State, Event, Command>, Command) -> Void
public typealias EventHandler = (State, Event) -> CoreUpdate<State, Command>
public let stateChanged = MessageRouter<State>()
@rob-brown
rob-brown / derived-stats.csv
Last active Sep 14, 2020
Amiibo Personality Research
View derived-stats.csv
Personality Total Wins Total Loses Total KOs Total Falls Total Damage Given Total Damage Received Total Match Wins Total Games Win Rate KOs per Game Falls per Game Damage Given per Game Damage Received per Game Damage Given per KO KOs per Fall
Offensive 35 10 124 83 18,524 14,856 7 45 77.8% 2.756 1.844 411.64 330.13 149.39 1.49
Lightning Fast 31 12 116 81 17,116 14,349 6 43 72.1% 2.698 1.884 398.05 333.70 147.55 1.43
Technician 25 26 120 120 19,038 18,943 3 51 49.0% 2.353 2.353 373.29 371.43 158.65 1.00
Daredevil 27 26 125 124 20,083 20,122 3 53 50.9% 2.358 2.340 378.92 379.66 160.66 1.01
Lively 30 19 125 102 19,715 16,985 5 49 61.2% 2.551 2.082 402.35 346.63 157.72 1.23
Entertainer 20 26 103 112 16,931 17,670 3 46 43.5% 2.239 2.435 368.07 384.13 164.38 0.92
Unflappable 15 30 93 114 15,780 18,145 1 45 33.3% 2.067 2.533 350.67 403.22 169.68 0.82
Sly 1 35 37 107 7,516 15,793 0 36 2.8% 1.028 2.972 208.78 438.69 203.14 0.35
@rob-brown
rob-brown / amiibo_ssbu.tcl
Last active Oct 11, 2020
HexFiend Amiibo Binary Templates
View amiibo_ssbu.tcl
little_endian
proc parse_system {} {
goto 0
section "System" {
hex 1 "BCC1 (UID3 ^ UID4 ^ UID5 ^ UID6)"
hex 1 "Internal (Always 0x48)"
hex 2 "Static Lock (Always 0x0FE0)"
hex 4 "Capability Container (CC)"
You can’t perform that action at this time.