Skip to content

Instantly share code, notes, and snippets.

View below's full-sized avatar
💭
I love feedback on my ARM64 Repo

Alexander von Below below

💭
I love feedback on my ARM64 Repo
View GitHub Profile
@below
below / libSRTP_build.sh
Last active April 25, 2022 14:35 — forked from rtcexpert/libSRTP_build.sh
build libSRTP script for iOS.
dobuild() {
export CC="$(xcrun -find -sdk ${SDK} cc)"
# export CXX="$(xcrun -find -sdk ${SDK} cxx)"
export CPP="$(xcrun -find -sdk ${SDK} cpp)"
export CFLAGS="${HOST_FLAGS} ${OPT_FLAGS}"
export CXXFLAGS="${HOST_FLAGS} ${OPT_FLAGS}"
export LDFLAGS="${HOST_FLAGS}"
./configure --host=${CHOST} --prefix=${PREFIX} --enable-openssl --with-openssl-dir="../openssl/"
make
}
import CoreBluetooth
class Test: NSObject, CBPeripheralManagerDelegate {
func peripheralManager(_ peripheral: CBPeripheralManager, didAdd service: CBService, error: Error?) {
let peripheral: CBPeripheral
// So what I would like is something like this
// But this does not work :(
if #available(iOS 15, *) {
public typealias AccessTokenPublisher = AnyPublisher<String, Error>
func fetchAuthorizedURLRequest(_ urlRequest: URLRequest,
accessToken: AccessTokenPublisher) -> AnyPublisher<Data, Error> {
accessToken
.flatMap { (accessToken: String) -> AnyPublisher<(data: Data, response: URLResponse), Error> in
URLSession.shared.dataTaskPublisher(
for: urlRequest.requestWithToken(accessToken)
@below
below / Contents.swift
Created February 26, 2021 09:53
Controlling your Future: DispatchSemaphore and Combine
/*:
### Controlling your Future
For my little Combine Project, I need to control acccess to a critical
section. (For those following along it won't be hard to guess: I don't want the accessToken mechanism to be accessed from two places).
So, building on an existing [sample](https://medium.com/swiftcairo/avoiding-race-conditions-in-swift-9ccef0ec0b26), I built
something in combine.
@below
below / AppAuthenticator.swift
Last active February 25, 2021 13:18
Using AppAuth with Combine
//
// AppAuthenticator.swift
// HomeOS API Demo
//
// Created by Alexander v. Below on 10.02.21.
//
import AppAuth
import Combine
struct TeamMemberView: View {
var columns: [GridItem] =
Array(repeating: .init(.flexible()), count: 2)
var body: some View {
ScrollView {
LazyVGrid(columns: columns, alignment: .leading) {
Text("Name:")
Text("Anne Applebaum")
Text("Contact:")
Text("+1-415-555-1111, [email protected]").lineLimit(0)
@below
below / Combine.swift
Last active February 6, 2021 09:57
Is this good Combine Code?
public func behindThePublisher(url: URL) -> AnyPublisher<NSAttributedString, Never> {
/// …
}
class ActionViewController: UIViewController {
@IBOutlet weak var textView: UITextView!
var cancellables = Set<AnyCancellable>()
@Published var displayText: NSAttributedString = NSAttributedString()
// Do you like my endless iterator?
struct EndlessIterator {
var baseIterator: String.Iterator?
var start: String
init(_ start: String) {
self.start = start
}
@below
below / Test.swift
Last active August 27, 2020 13:37
Why is this not working?
import SwiftUI
import PlaygroundSupport
struct TestView: View {
@State var foo = "faz"
init() {
foo = "bar"
debugPrint(foo) // prints "faz"
}
var body: some View { Text(foo) }
@below
below / playground.swift
Last active August 27, 2020 10:33
Why is this assignment not working … it compiles
//: A UIKit based Playground for presenting user interface
//
// QuizList.swift
// QuizList
//
// Created by Alexander v. Below on 09.06.19.
// Copyright © 2019 None. All rights reserved.
//