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
// | |
// OCXML.swift | |
// Created by Marco Arment on 9/23/24. | |
// | |
// Released into the public domain. Do whatever you'd like with this. | |
// No guarantees that it'll do anything, or do it correctly. Good luck! | |
// | |
import Foundation |
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
// I think this works and doesn't create circular references? | |
/* | |
Usage: Add OCObservableKeyPaths conformance to the observed type. Then, e.g. | |
audioPlayer | |
.publisher(forObservableKeyPaths: [ \.timestamp, \.duration ]) | |
.sink { | |
// respond to change | |
} |
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 | |
extension View { | |
public func searchable_iOS16(text: Binding<String>, isPresented: Binding<Bool>, placement: SearchFieldPlacement) -> some View { | |
modifier(Searchable_iOS16(text: text, isPresented: isPresented, placement: placement)) | |
} | |
} | |
public struct Searchable_iOS16: ViewModifier { | |
@Binding var text: 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
import SwiftUI | |
extension Text { | |
public struct InlineSymbol { | |
public let name: String | |
public let accessibilityLabel: String | |
public let color: Color? | |
public init(name: String, accessibilityLabel: String, color: Color? = nil) { | |
self.name = name |
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 | |
struct ContentView: View { | |
@State var numbers = [1, 2, 3, 4, 5, 6, 7, 8] | |
var body: some View { | |
Button { | |
withAnimation { | |
numbers.append(Int.random(in: 9..<99)) | |
numbers.sort() |
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/bash | |
shopt -s nullglob | |
LOCALUSER=marco # Change this for you, obviously | |
DISABLED_FILES_DIR=/Users/$LOCALUSER/.quit-adobe | |
# Are any Adobe user-facing apps running? Assuming they begin with "Adobe ", e.g. "Adobe Audition 2022" | |
ps ax -c -o 'command=' | egrep '^Adobe ' | fgrep -v 'Adobe Desktop Service' | fgrep -v 'Adobe Installer' > /dev/null | |
if [ $? -eq 1 ] ; then |
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 | |
extension UIColor: Identifiable { | |
public var id: String { | |
get { self.accessibilityName } | |
} | |
} | |
struct ContentView: View { |
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
<?php | |
/* | |
A simple PHP class to perform basic operations against Amazon S3 and compatible | |
services. Requires modern PHP (7+, probably) with curl, dom, and iconv modules. | |
Copyright 2022 Marco Arment. Released under the MIT license: | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights |
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
// Sun.swift | |
// Created by Marco Arment on 1/17/21 | |
// | |
// Solar-math functions are directly translated from the NOAA Solar Calculator: | |
// https://www.esrl.noaa.gov/gmd/grad/solcalc/ | |
// | |
// This is free and unencumbered software released into the public domain. | |
// | |
// Anyone is free to copy, modify, publish, use, compile, sell, or | |
// distribute this software, either in source code form or as a compiled |
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
<?php | |
function base64url_encode($binary_data) { return strtr(rtrim(base64_encode($binary_data), '='), '+/', '-_'); } | |
function apns_jwt_token($team_id, $key_id, $private_key_pem_str) | |
{ | |
if (! function_exists('openssl_get_md_methods') || ! in_array('sha256', openssl_get_md_methods())) throw new Exception('Requires openssl with sha256 support'); | |
$private_key = openssl_pkey_get_private($private_key_pem_str); | |
if (! $private_key) throw new Exception('Cannot decode private key'); |
NewerOlder