Skip to content

Instantly share code, notes, and snippets.

@rob-brown
rob-brown / pokemon-trainer-ratings.csv
Last active Apr 14, 2021
Pokémon Trainer SSBU Stats
View pokemon-trainer-ratings.csv
Placement Figure Win Rate Rating
1 Ivysaur 73.0% 29.06
2 PT Ivysaur 72.0% 28.89
3 Charizard 69.0% 27.67
4 Squirtle 69.0% 26.81
5 PT Squirtle 58.0% 26.59
6 PT Charizard 61.0% 26.38
@rob-brown
rob-brown / amiibo_ssbu.tcl
Last active Jan 5, 2021
HexFiend Amiibo Binary Templates
View amiibo_ssbu.tcl
little_endian
# HexFiend Reference: https://github.com/HexFiend/HexFiend/blob/master/templates/Reference.md
proc parse_system {} {
goto 0
section "System" {
hex 1 "BCC1 (UID3 ^ UID4 ^ UID5 ^ UID6)"
hex 1 "Internal (Always 0x48)"
@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
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 / SecretMessage.exs
Last active Jun 7, 2021
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)
@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
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 / stage_inspector.ex
Last active Aug 18, 2016
Inspect the data passed between GenStages.
View stage_inspector.ex
defmodule StageInspector do
alias Experimental.{GenStage}
use GenStage
def init(type) when type in [:consumer, :producer_consumer] do
{type, type}
end
def handle_events(events, _from, state = :consumer) do
Enum.each events, &inspect_event/1
@rob-brown
rob-brown / ObjectsFromFunctions.swift
Last active Jun 8, 2017
Use Church Encoding to create objects using only functions
View ObjectsFromFunctions.swift
//: Playground - noun: a place where people can play
import UIKit
// ----------------------------
// Create the "object".
// Basically it's a dispatch table.
typealias Person = (String) -> Any
var PersonInit: ((String, String) -> Person)!
@rob-brown
rob-brown / life.ex
Last active Aug 29, 2015
Conway's Game of Life
View life.ex
defmodule Life do
# Defaults to B3/S23
defstruct cells: [[]], born: [3], stays: [2, 3], width: 10, height: 10, step: 0
def run(file) do
file |> read_file |> loop
end
def loop(life) do