Skip to content

Instantly share code, notes, and snippets.

View Adzz's full-sized avatar

Adam Lancaster Adzz

View GitHub Profile
map_1 = %{first: 1, second: 2}
map_2 = %{first: 3, second: 4}
# These just work! 🤩
Zip.apply(map_1, map_2, Add) #=> %{first: 4, second: 6}
Zip.apply(map_1, map_2, Subtract) #=> %{first: 4, second: 6}
// As you might expect
func add(x int, y int) int {
return x + y
}
// Go functions can return multiple values though, so you
// Can type each of the return values
func swap(x, y string) (string, string) {
return y, x
}
@Adzz
Adzz / koppel_to_do.ex
Last active September 15, 2019 12:18
Your task is to design the data layer for a to-do list app. Create the core data structures that track state, along with an API that can be connected to any frontend
# Third round of feature requests
# Extend your design to support one of the following two features:
# Ability to look up, for all users, how many have a todo item with the same name as one of yours.
# Also, explain how to extend your user interface to display the total number of todo items in the
# list currently being viewed. This feature is simple, but there are some easy ways to get it wrong.
# Ability to go back into the past, and see what a user's todo list looked like at any point in time.
# Explain how this would work for todo lists that already exist.
# =================================================================================================
@Adzz
Adzz / bad_behaviours.ex
Created November 15, 2021 15:45
This is a gist that demos what behaviours and protocols look like in Elixir. Used as part of onboarding
defmodule Shape do
@callback area(map()) :: integer()
@callback perimeter(map()) :: integer()
end
defmodule Square do
defstruct [:side]
@behaviour Shape
@Adzz
Adzz / elexer.ex
Last active November 4, 2022 13:20
A lisp lexer / parser for a pairing exercise, written in Elixir. I chose to make this event based for some reason.
# A simple Lisp parser. You could copy paste this into iex (the elixir repl)
# or use a livebook, and you can run the parser like this:
#
# Elexer.parse("(+ 1 -2)")
# A more fully featured prject can be found here: https://github.com/Adzz/elexer
defmodule Elexer do
@moduledoc """
A simple lisp parser.
@Adzz
Adzz / git_wrapped.sh
Created December 19, 2024 19:05
Your Year In Git
#!/bin/bash
RED="\033[31m"
GREEN="\033[32m"
RESET="\033[0m"
MAGENTA="\033[35m"
CYAN="\033[36m"
YELLOW="\033[33m"
BLUE="\033[34m"