This file contains hidden or 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
You are FanAI — a casual, confident sports chat assistant in a group chat. | |
You’re here to talk scores, matchups, league banter, and the kinds of things sports fans would talk about. | |
⛔ You are NOT a file assistant or tech support. | |
You do NOT access, mention, or even think about files, uploads, or documents. | |
If you were going to respond about a file, or if someone asks about files, don't. Do not use the word "file" in your response at all; you do not know about "files". | |
Ignore that word and answer naturally based on group chat history or live data. | |
If you can't find the info, just say: |
This file contains hidden or 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 GestureTester: View { | |
@State var isPressed = false | |
@State var location = CGPoint.zero | |
var body: some View { | |
let pressGesture = LongPressGesture(minimumDuration: 0.5).onEnded { | |
self.isPressed = $0 | |
} |
This file contains hidden or 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 | |
public extension Spacer { | |
static func exactly(_ value: CGFloat) -> some View { | |
Spacer() | |
.frame( | |
minWidth: value, | |
idealWidth: value, | |
maxWidth: value, | |
minHeight: value, |
This file contains hidden or 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
public struct VSpacer: View { | |
private let spacing: CGFloat | |
public init(_ spacing: CGFloat) { | |
self.spacing = spacing | |
} | |
public var body: some View { | |
Spacer() | |
.frame(idealHeight: spacing, maxHeight: spacing) |
This file contains hidden or 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 highestKey<T, N: Comparable>(of dictionary: Dictionary<T, N>) -> T? { | |
var highestKey: T? | |
var highestValue: N? | |
for key in dictionary.keys { | |
let value = dictionary[key] | |
if highestValue == nil || value! > highestValue! { | |
highestKey = key | |
highestValue = value | |
} |
This file contains hidden or 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 | |
class Weak<T> { | |
private weak var _value: AnyObject? | |
var value: T? { return _value as? T } | |
init(_ value: T) { | |
_value = value as AnyObject | |
} | |
} |
This file contains hidden or 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 | |
public class BidirectionalMap<Left: Hashable, Right: Hashable> { | |
private var leftToRightMapping = [Left : Right]() | |
private var rightToLeftMapping = [Right : Left]() | |
public subscript(left: Left) -> Right? { | |
get { return leftToRightMapping[left] } | |
set (newValue) { |
This file contains hidden or 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
@propertyWrapper | |
class Lazy<T> { | |
fileprivate var loader: (()->T) | |
fileprivate var _value: T? | |
var projectedValue: Lazy<T> { return self } | |
var wrappedValue: T { | |
_value = _value ?? loader() | |
return _value! | |
} |
This file contains hidden or 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 | |
func setIfNotNil<T>(_ obj: inout T?, _ other: T?) { | |
guard other != nil else { return } | |
obj = other | |
} |
This file contains hidden or 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 RealmSwift | |
extension Realm { | |
func sync<T: Object>(_ obj: T) { | |
var beganWriteTransaction = false | |
if !isInWriteTransaction { | |
beganWriteTransaction = true | |
beginWrite() | |
} | |
NewerOlder