This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env swift | |
import Foundation | |
let toolchainsDir = URL(fileURLWithPath: "/Library/Developer/Toolchains") | |
struct ToolchainInfoPlist: Codable { | |
var bundleIdentifier: String | |
var createdDate: Date | |
var displayName: String |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM swift:5.9-slim | |
RUN apt-get update && apt-get -y install curl fish | |
ARG PKL_VERSION=0.25.1 | |
RUN curl -L -o /usr/local/bin/pkl https://github.com/apple/pkl/releases/download/${PKL_VERSION}/pkl-linux-aarch64 && chmod +x /usr/local/bin/pkl | |
# requires Swift runtime libraries, that's why the base image is swift:5.9-slim | |
ARG PKL_GEN_SWIFT_VERSION=0.2.1 | |
RUN curl -L -o /usr/local/bin/pkl-gen-swift https://github.com/apple/pkl-swift/releases/download/${PKL_GEN_SWIFT_VERSION}/pkl-gen-swift-linux-aarch64.bin && chmod +x /usr/local/bin/pkl-gen-swift |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
workflow_dispatch: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
``` | |
❯ ./.build/debug/daws server | |
starting server... | |
running. | |
2023-12-08T13:09:21+0100 info WebSocketActors : channel=[IPv6]::1/::1:57175 op=handleWebsocketChannel(_:remoteNodeID:) [WebSocketActors] new client connection | |
``` | |
``` | |
❯ ./.build/debug/daws client | |
starting client... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -euo pipefail | |
# Set the paths to your Old/New Xcodes | |
OLD_XCODE="/Applications/Xcode-14.3.1.app" | |
NEW_XCODE="/Applications/Xcode-15.0.0.app" # To get build number | |
# Get New Xcode build number | |
OLD_XCODE_BUILD=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" ${OLD_XCODE}/Contents/Info.plist) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func run(_ operation: () async throws -> Void, | |
defer deferredOperation: () async throws -> Void) async throws { | |
do { | |
try await operation() | |
try await deferredOperation() | |
} catch { | |
try await deferredOperation() | |
throw error | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
import Charts | |
import PlaygroundSupport | |
let spiData: [(package: String, fileCount: Int, mbSize: Int)] = [ | |
(package: "swift-markdown-ui", fileCount: 3796, mbSize: 44), | |
(package: "Microya", fileCount: 414, mbSize: 4), | |
(package: "swift-url-routing", fileCount: 9430, mbSize: 101), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import NIO | |
extension Array where Element == EventLoopFuture<Void> { | |
/// Converts a collection of `EventLoopFuture<Void>`s to an `EventLoopFuture<Void>`. | |
/// | |
/// Acts as a helper for the `EventLoop.flatten(_:[EventLoopFuture<Value>])` method. | |
/// | |
/// let futures = [el.future(1), el.future(2), el.future(3), el.future(4)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum Barcode { | |
case upc(Int, Int, Int, Int) | |
case qrCode(String) | |
} | |
var productBarcode = Barcode.upc(8, 85909, 51226, 3) | |
productBarcode = .qrCode("ABCDEFGHIJKLMNOP") | |
switch productBarcode { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Cocoa | |
func context(for cgImage: CGImage) -> CGContext? { | |
guard | |
let space = cgImage.colorSpace, | |
let context = CGContext( | |
data: nil, | |
width: cgImage.width, | |
height: cgImage.height, | |
bitsPerComponent: cgImage.bitsPerComponent, |
NewerOlder