Skip to content

Instantly share code, notes, and snippets.

Rob Brown rob-brown

Block or report user

Report or block rob-brown

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
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 / 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 / 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
|> obfuscate
|> Stream.concat(Stream.repeatedly fn -> "" end)
|> 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>()
You can’t perform that action at this time.