Skip to content

Instantly share code, notes, and snippets.

View atomkirk's full-sized avatar

Adam Kirk atomkirk

View GitHub Profile
@atomkirk
atomkirk / download-zoom-recording.md
Last active March 18, 2024 14:50
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:
<body>
  <a href="url-you-copied">download</a>
  ...
@atomkirk
atomkirk / ios-camera.html
Created March 13, 2020 04:49
iOS Safari Camera API
<video id="player" autoplay muted playsinline> </video>
<button id="capture">Capture</button>
<canvas id="canvas" width=320 height=240></canvas>
<script>
const player = document.getElementById('player');
const canvas = document.getElementById('canvas');
const context = canvas.getContext('2d');
const captureButton = document.getElementById('capture');
const constraints = {
@atomkirk
atomkirk / ecto-url-validation.md
Last active February 14, 2024 07:20
validate url in elixir

Here's an ecto changeset validation for urls:

  @doc """
  validates field is a valid url

  ## Examples
    iex> Ecto.Changeset.cast(%ZB.Account{}, %{"website" => "https://www.zipbooks.com"}, [:website])
    ...> |> Utils.Changeset.validate_url(:website)
    ...> |> Map.get(:valid?)
@atomkirk
atomkirk / stop-all-docker.md
Created February 9, 2021 14:25
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
atomkirk / custom_segue.swift
Last active February 26, 2023 15:50
Custom Fade In/Out Segue
import UIKit
// All you do is assign this class to a segue in your storyboard and you're done
class BottomCardSegue: UIStoryboardSegue {
private var selfRetainer: BottomCardSegue? = nil
override func perform() {
destination.transitioningDelegate = self
@atomkirk
atomkirk / parsce-csv-test.js
Last active February 13, 2023 09:19
parse csv with javascript
import parseCsv from 'zipbooks/utils/parse-csv'
import { module, test } from 'qunit'
module('Unit | Utility | parse-csv', function(_hooks) {
test('parses csv successfully', function(assert) {
let result = parseCsv('name,age\nadam,31\ntim,32\n"St, clair",26')
assert.equal(JSON.stringify(result), '[["name","age"],["adam","31"],["tim","32"],["St, clair","26"]]')
})
@atomkirk
atomkirk / cloud-files.md
Last active January 18, 2023 17:23
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
@atomkirk
atomkirk / hungarian.ex
Last active January 8, 2023 20:25
Hungarian/Munkres algorithm in Elixir
defmodule Hungarian do
@moduledoc """
Written by Adam Kirk – Jan 18, 2020
Most helpful resources used:
https://www.youtube.com/watch?v=dQDZNHwuuOY
https://www.youtube.com/watch?v=cQ5MsiGaDY8
https://www.geeksforgeeks.org/hungarian-algorithm-assignment-problem-set-1-introduction/
@atomkirk
atomkirk / udot_regions.sql
Created March 8, 2022 19:59
UDOT Regions 1 & 2 GIS
This file has been truncated, but you can view the full file.
INSERT INTO "public"."gis__objects"("id","layer","geometry","properties","inserted_at")
VALUES
@atomkirk
atomkirk / factory.ex
Last active March 2, 2022 17:50
Generating Example Data in Elixir
defmodule App.Factory do
alias App.Repo
def create(module, overrides \\ %{})
def create(module, overrides) when is_list(overrides), do: create(module, Map.new(overrides))
def create(module, overrides) do
attributes = module.example() |> Map.merge(overrides)
struct(module)