Skip to content

Instantly share code, notes, and snippets.

@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
@mazz
mazz / PinEntryView.swift
Created September 30, 2022 03:12 — forked from willbrandin/PinEntryView.swift
A SwiftUI View for entering login pins. Supports first responder and has no third parties.
import SwiftUI
struct PinEntryView: View {
var pinLimit: Int = 4
var isError: Bool = false
var canEdit: Bool = true
@Binding var pinCode: String
private var pins: [String] {
@mazz
mazz / app.js
Created July 23, 2022 14:30 — forked from goofansu/app.js
LiveView upload directly to AWS China S3
let Uploaders = {}
Uploaders.S3 = function (entries, onViewError) {
entries.forEach(entry => {
let xhr = new XMLHttpRequest()
onViewError(() => xhr.abort())
xhr.onload = () => (xhr.status === 200 ? entry.done() : entry.error())
xhr.onerror = () => entry.error()
xhr.upload.addEventListener("progress", event => {
if (event.lengthComputable) {
defmodule SimpleS3Upload do
@moduledoc """
Dependency-free S3 Form Upload using HTTP POST sigv4
https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-post-example.html
"""
@doc """
Signs a form upload.
The configuration is a map which must contain the following keys:
* `:region` - The AWS region, such as "us-east-1"
@mazz
mazz / remove-all-from-docker.sh
Created March 24, 2022 21:28 — forked from beeman/remove-all-from-docker.sh
Remove all from Docker
# Stop all containers
docker stop `docker ps -qa`
# Remove all containers
docker rm `docker ps -qa`
# Remove all images
docker rmi -f `docker images -qa `
# Remove all volumes