Skip to content

Instantly share code, notes, and snippets.

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 / 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 / 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()
@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) {
@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
@mazz
mazz / _user_menu.html.eex
Created January 28, 2021 00:15 — forked from andreaseriksson/_user_menu.html.eex
Use phoenix_live_session to communicate bewteen live views
<%= live_render @conn, EcommerceWeb.CartLive %>
@mazz
mazz / NYXAVCEncoder.swift
Created August 13, 2020 21:49 — forked from Nyx0uf/NYXAVCEncoder.swift
Hardware accelerated GIF to MP4 converter in Swift using VideoToolbox
import VideoToolbox
import AVFoundation
private var __canHWAVC: Bool = false
private var __tokenHWAVC: dispatch_once_t = 0
public protocol NYXAVCEncoderDelegate : class
{
func didEncodeFrame(frame: CMSampleBuffer)
func didFailToEncodeFrame()
@mazz
mazz / ecto_postgres_fulltext_search_querying_example.ex
Created April 16, 2019 01:31 — forked from pmarreck/ecto_postgres_fulltext_search_querying_example.ex
How to set up postgres fulltext search triggers, index, and tsvector column on Elixir/Phoenix, with Ecto querying, including ranking and sorting by rank
defmodule YourAppName.Search do
# ...
@doc """
Queries listings.
"""
def query_listings(query, current_user) do
default_scope = from l in Listing, where: l.draft == false or l.user_id == ^current_user.id, order_by: [desc: l.updated_at], limit: 50
id = _try_integer(query)
@mazz
mazz / README.md
Created September 21, 2018 13:04 — forked from Luzifer/README.md
Running docker-compose as a systemd service

Running docker-compose as a systemd service

Files

File Purpose
/etc/compose/docker-compose.yml Compose file describing what to deploy
/etc/systemd/system/docker-compose.service Service unit to start and manage docker compose
/etc/systemd/system/docker-compose-reload.service Executing unit to trigger reload on docker-compose.service
/etc/systemd/system/docker-compose-reload.timer Timer unit to plan the reloads