Skip to content

Instantly share code, notes, and snippets.

Avatar
📆
Building calendars is hard

Bradley Mackey bradleymackey

📆
Building calendars is hard
View GitHub Profile
@bradleymackey
bradleymackey / vs-code-settings.json
Last active Mar 11, 2019
Fix RLS Error on VS Code
View vs-code-settings.json
// add this line to the user settings to fix the RLS (Rust Language Server) unable to start error
{
"rust-client.channel": "stable"
}
View keybase.md

Keybase proof

I hereby claim:

  • I am bradleymackey on github.
  • I am bradleymackey (https://keybase.io/bradleymackey) on keybase.
  • I have a public key ASDQ12_qS4snqloFk1BH5ZXZKIRPlWFMq7EhJfIEXNWxGAo

To claim this, I am signing this object:

@bradleymackey
bradleymackey / autolayout.swift
Last active Oct 14, 2019
Helpers for Autolayout I use in basically every project -- make Autolayout more bearable for you!
View autolayout.swift
//
// UIView+Constraints.swift
//
// Created by Bradley Mackey on 30/06/2019.
// Copyright © 2019 Bradley Mackey. All rights reserved.
//
/*
* Abstract: AutoLayout helpers when programmatically defining views
*/
View resize.swift
#!/usr/bin/swift sh
/*
Abstract:
Given an image, resize it, creating 1x, 2x and 3x versions for iOS
Internally, we use the `sips` tool to perform this resizing, this is just a nice wrapper.
*/
import Foundation
View firestore-clone.ts
/**
* Abstract:
* cloning with additional special-hanling logic for Firestore native objects
* adapted from klona
*/
import * as firebaseAdmin from "firebase-admin";
import * as firebaseTest from "@firebase/rules-unit-testing";
export enum Direction {
@bradleymackey
bradleymackey / Atomic.swift
Last active Jan 8, 2022
Locking abstraction over any type.
View Atomic.swift
import os
/// An efficient lock to prevent contesting access to a resource across threads
///
/// This is a very thin wrapper around `os_unfair_lock` with a better Swift interface.
/// It also has a similar interface to `NSLock`
public final class Lock: @unchecked Sendable {
@usableFromInline
var _mutex = os_unfair_lock()
View Lock.swift
/// An efficient lock to prevent contesting access to a resource across threads
///
/// This is a very thin wrapper around `os_unfair_lock` with a better Swift interface.
/// It also has a similar interface to `NSLock`
public final class Lock: @unchecked Sendable {
@usableFromInline
var _mutex = os_unfair_lock()
public init() { }
View Eventual.swift
import Foundation
/// Asynchrously supply and then remember a result.
public final class Eventual<T>: Sendable where T: Sendable {
/// Mediated access to the supplying function.
private let supplierInternal: Atomic<@Sendable () async -> T>
/// The closure that provides the value.
///
/// This will be called implictly when you `get()` the value.
View Task+Race.swift
public extension Task where Success == Never, Failure == Never {
/// Blueprint for a task that should be run, but not yet.
struct Blueprint<Output> {
public var priority: TaskPriority
public var operation: @Sendable () async throws -> Output
public init(
priority: TaskPriority = .medium,
operation: @escaping @Sendable () async throws -> Output
) {