Skip to content

Instantly share code, notes, and snippets.


Sam Warner sam-w

  • LoungeBuddy
  • Sydney, Australia
View GitHub Profile
View set-operations.ts
* Returns the union of the two sets (`a ∪ b`),
* i.e. all elements present in either set.
export const union = <T>(a: Set<T>, b: Set<T>) => new Set(
* Returns the intersection of the two sets (`a ∩ b`),
View Color+UIKit.swift
import SwiftUI
import UIKit
extension Color {
var uiColor: UIColor {
if #available(iOS 14, *) {
// iOS 14 introduces an API to convert SwiftUI.Color to UIKit.UIColor
// but it does not produce a color which reacts to changes in color scheme
// (light mode/dark mode). To make that work we need to extract the color
View ModalLink.swift
sam-w / asc-desc-text
Created Jan 9, 2020
Text sample likely to hit maximum ascenders and descenders for any font which supports the glyphs
sam-w / xcode-env
Created Dec 10, 2019
Xcode 11 New Build System Environment Variables
View xcode-env
View Promise.firstSuccess.ts
* Executes a list of Promises in parallel and resolves with the first successful resolution.
* Like `Promise.race` in that it takes a list of Promises and only waits for the first completion, but
* differs in that it requires a _successful_ resolution before it completes. Only rejects if _all_ children reject.
* Different
* @param promises a list of promises to resolve.
* @param where an optional predicate. Any Promise `p` which resolves but for which the predicate
* produces an error will behave as `p` instead rejected.
sam-w / SearchPattern2D.swift
Last active Jul 31, 2019
2D Search Pattern
View SearchPattern2D.swift
// SearchPattern2D.swift
// MapScan
// Created by Sam Warner on 31/7/19.
// Copyright © 2019 LoungeBuddy. All rights reserved.
import UIKit
sam-w / pretty-print-json
Created Jun 27, 2019
Convert directory of json to pretty-printed
View pretty-print-json
for file in output/**/*(.); do cat $file | jq . > /tmp/jq.json; cat /tmp/jq.json > $file; done
sam-w / keys-and-jwts.go
Last active Jun 13, 2019
Golang RSA Keys and JWTs
View keys-and-jwts.go
import (
View Import images to .xcassets
#delete the existing images
find '/Users/sam.warner/Domain/domain-ios-app/Resources/Images.xcassets/Loading Spinners/Gray' -name "*.png" -type f -delete
for i in `seq 0 9`; do
#edit Contents.json
sed -i '' "s/\"filename\" :.*@2x.*/\"filename\" : \"spinner-loop_0$i.png\",/g" "/Users/sam.warner/Domain/domain-ios-app/Resources/Images.xcassets/Loading Spinners/Gray/loading-spinner-frame0$i.imageset/Contents.json"
#rename the folder
mv "/Users/sam.warner/Domain/domain-ios-app/Resources/Images.xcassets/Loading Spinners/Gray/loading-spinner-frame0$i.imageset" "/Users/sam.warner/Domain/domain-ios-app/Resources/Images.xcassets/Loading Spinners/Gray/gray-spinner-frame0$i.imageset"
#copy the new images
cp ~/spinner-loop/spinner-loop_0$i.png "/Users/sam.warner/Domain/domain-ios-app/Resources/Images.xcassets/Loading Spinners/Gray/gray-spinner-frame0$i.imageset"