Skip to content

Instantly share code, notes, and snippets.

@mazz
mazz / vidstack-hook.js
Created June 8, 2023 05:29
vidstack-hook.js
/*
Docs: https://hexdocs.pm/phoenix_live_view/js-interop.html#client-hooks
Usage: when using phx-hook, a unique DOM ID must always be set.
<div phx-hook="ExampleHook" id="someUniqueId"></div>
*/
// import 'vidstack/styles/defaults.css'
// import 'vidstack/styles/community-skin/video.css'
@mazz
mazz / channel.ex
Created May 28, 2023 14:58
channel.ex
@required_fields [
:name,
:org_id,
:owner_id,
:channel_category_id,
:slug,
:item_ids
]
@optional_fields [:visibility, :ordinality, :slug, :poster_path, :description, :content_type]
import UIKit
import AVKit
import AVFoundation
import AssetsLibrary
func synchronized(_ object: AnyObject, block: () -> Void) {
objc_sync_enter(object)
block()
objc_sync_exit(object)
}
@mazz
mazz / change.ex
Created December 21, 2022 02:18
why :membership_type and :role are not added to the changeset
def update_changeset(membership, attrs) do
dbg(membership)
dbg(attrs)
# attrs #=> %{is_paid: false, membership_type: "personal", role: "admin"}
to_atom_attrs =
Enum.map(attrs, fn {k, v} ->
if is_atom(v) do
{k, v}
else
@mazz
mazz / RecordAudio.swift
Created December 20, 2022 04:14 — forked from leonid-s-usov/RecordAudio.swift
Swift Audio Recording class. Reads buffers of input samples from the microphone using the iOS RemoteIO Audio Unit API
//
// RecordAudio.swift
//
// This is a Swift class (updated for Swift 5)
// that uses the iOS RemoteIO Audio Unit
// to record audio input samples,
// (should be instantiated as a singleton object.)
//
// Created by Ronald Nicholson on 10/21/16.
// Copyright © 2017,2019 HotPaw Productions. All rights reserved.
@mazz
mazz / application.ex
Created December 13, 2022 16:39
** (ArgumentError) unknown registry: Registry.MongoConnectionRegistry
defmodule Wrangler.Application do
# See https://hexdocs.pm/elixir/Application.html
# for more information on OTP Applications
@moduledoc false
use Application
@registry Registry.MongoConnectionRegistry
@impl true
@mazz
mazz / mongo_open5gs_elixir.ex
Created December 9, 2022 18:47
mongo_open5gs_elixir.ex
%{
"__v" => 0,
"_id" => #BSON.ObjectId<63937fbee42d79b14046ad0f>,
"access_restriction_data" => 32,
"ambr" => %{
"downlink" => %{"unit" => 3, "value" => 1},
"uplink" => %{"unit" => 3, "value" => 1}
},
"imsi" => "001010000000004",
"network_access_mode" => 0,
@mazz
mazz / app.exs
Created December 5, 2022 18:55 — forked from alvises/app.exs
app.exs test script which connects two Elixir nodes running in two containers
IO.puts("I'm here! Sleeping for 2 seconds")
Process.sleep 2_000 # waiting for the other node
nodes = MapSet.new([:app@app1, :app@app2])
other_node =
nodes
|> MapSet.delete(Node.self())
|> MapSet.to_list()
|> List.first()
# Find eligible builder and runner images on Docker Hub. We use Ubuntu/Debian instead of
# Alpine to avoid DNS resolution issues in production.
#
# https://hub.docker.com/r/hexpm/elixir/tags?page=1&name=ubuntu
# https://hub.docker.com/_/ubuntu?tab=tags
#
#
# This file is based on these images:
#
# - https://hub.docker.com/r/hexpm/elixir/tags - for the build image
defmodule ChessPhxWeb.MatchMainLive do
@moduledoc """
List all orgs for the current_user.
"""
use ChessPhxWeb, :live_view
@impl true
def mount(_params, _session, socket) do
case Chex.new_game() do