Skip to content

Instantly share code, notes, and snippets.


Adam Kirk atomkirk

View GitHub Profile
atomkirk / udot_regions.sql
Created Mar 8, 2022
UDOT Regions 1 & 2 GIS
View udot_regions.sql
This file has been truncated, but you can view the full file.
INSERT INTO "public"."gis__objects"("id","layer","geometry","properties","inserted_at")
atomkirk /
Last active Apr 14, 2021
Force download a zoom recording
  1. Open dev tools
  2. Search for the <video… tag.
  3. Copy the source URL
  4. Right click on the body tag and click Edit as HTML
  5. Add an a link with the src right inside the body tag like:
  <a href="url-you-copied">download</a>
atomkirk /
Created Feb 9, 2021
Stop all Docker containers

I will often run this command to make sure all my docker containers are stopped and removed before running docker-compose up. Sometimes when you restart your system, old containers will start back up automatically in the background.

docker stop $(docker ps -aq) && docker rm $(docker ps -aq)
atomkirk / postgres_enum_add.sql
Created Feb 9, 2021
Add postgres enum values in order (for sort)
View postgres_enum_add.sql
ALTER TYPE enum_type ADD VALUE 'new_value'; -- appends to list
ALTER TYPE enum_type ADD VALUE 'new_value' BEFORE 'old_value';
ALTER TYPE enum_type ADD VALUE 'new_value' AFTER 'old_value';
atomkirk /
Last active Jul 1, 2020
Run Elixir tests on VSCode save

A really great workflow is to write your test first (TDD anyone?), run the test to verify it fails (eliminate false positive) and then write the implementation. I've included a runOnSave setting to run a test file anytime it is saved and, second, to run any failed tests as soon as any other elixir file is saved.

So, you write the test, save, it fails. You write Elixir code, save, it still fails. You keep writing Elixir code and saving until it passes.

This is obviously cool. But one thing that is particularly cool is that while you are writing the implementation, you often want to peek at values and experiment with code. Well, thats easy! Just write the code, IO.inspect it and then save! You'll instantly

atomkirk / factory.ex
Last active Mar 2, 2022
Generating Example Data in Elixir
View factory.ex
defmodule App.Factory do
alias App.Repo
def create(module, overrides \\ %{})
def create(module, overrides) when is_list(overrides), do: create(module,
def create(module, overrides) do
attributes = module.example() |> Map.merge(overrides)
atomkirk /
Last active Apr 15, 2020
elixir tuple constant time

Whats the fastest way to look up an index in Elixir?

Lets create a long list of a million items and look up the 500,000th item

iex(54)> range = 1..1_000_000

iex(55)> index = 500_000
atomkirk / ios-camera.html
Created Mar 13, 2020
iOS Safari Camera API
View ios-camera.html
<video id="player" autoplay muted playsinline> </video>
<button id="capture">Capture</button>
<canvas id="canvas" width=320 height=240></canvas>
const player = document.getElementById('player');
const canvas = document.getElementById('canvas');
const context = canvas.getContext('2d');
const captureButton = document.getElementById('capture');
const constraints = {
atomkirk / hungarian.ex
Last active Nov 24, 2021
Hungarian/Munkres algorithm in Elixir
View hungarian.ex
defmodule Hungarian do
@moduledoc """
Written by Adam Kirk – Jan 18, 2020
Most helpful resources used:
atomkirk /
Last active Jul 21, 2021
Storing files on S3 with Elixir

I have this abstraction in my application code called a "CloudFile". This is where I store in the database information about files on S3 and it gives me a resource for other resources to own. For example, a user would have an avatar_cloud_file_id. On the front-end, I would load this relationship and display the avatar with user.avatar_cloud_file.download_url

defmodule RL.CloudFile do
  use Ecto.Schema
  import Ecto.Changeset

  @timestamps_opts type: :utc_datetime_usec