// Try.ts | |
// By Colin Teahan | |
// August 14th, 2024 | |
// | |
// This TypeScript file enables usage of the .try() method which will return a result tuple of [T?, Error?] | |
// from any function or async function. This works by defining a new property on the global Object.prototype | |
// and then do some type-fu. | |
// | |
// Example usage: | |
// https://www.typescriptlang.org/play/?target=99#code/MYewdgziA2CmB0w4EMBOAKAlAKGwejwAJCAVVAT3gBcJ8jCAhcwgYRgEsxTZkALZMHWIBBAK4BzURCqEAjABYqvADSEATAAY18ukNK92EUuQAOsAMrBU7EzIBm7OIVhhkAIzhGpycbEIg7QiU-agosQgBbWCUQABNCAHcDYF5Ex2hCVGjRVC5kTNgIUWgZKlETJwDCAG0SAH5VAFFUVBBUOoBdPTtWiMIBZjtRMGAqdnB-VH6IchHCIZGx8Hh9Q0S2gGsjN2ZY2AcwTnF+wjBYBMITVrNUKmYJ4MJxaBA3ZAyAeTcAK1hR+CuICoQNMsD0AniwS4sRAhCgUSCoIAtEN4LoCMRGgAPZARCp+by+ABc6PoC1G4y4vioAFUILBUEwAJKxdDsWJE06iCJuBmYQgAbz0xGI7ECbPiAB4ALyEDT8pStC5nC7NVoYADknAAbu92YQpAzCOyNTgMSLiFkyrlBadcbBORqGK8Nap9QBfPSegh6UCQGTVQ2oVQM9UdQiy6l0hnM2KhcjoeWESVIpHOFptNLQDK8grWs6xX3gaQ1IMhjOocOR6LRxnkFnx9CyfkptNBwhOl3GoxWnIF0nEAByHxIjU5JAMRjW0nSJwSm2NXEB4iyECMEO7pyBcNE |
// fork of https://gist.github.com/b-nnett/2749adb44566239e4c85ad1a8937c2bc | |
// origin by @B_nnett → https://twitter.com/joshm/status/1648346253355282432?s=20 | |
/* | |
To set up this boost for chat.openai.com: | |
1) open Arc browser and login at chat.openai.com. | |
2) Head over to the + button in your sidebar and select New Boost. | |
Or hit ⌘ + T and type New Boost into your Command Bar. | |
3) Click the `Code` button. |
// | |
// App.swift | |
// | |
// Created by Ben Tindall on 30/03/2022. | |
// | |
import Foundation | |
import SwiftUI | |
import Cocoa |
How to Force RGB Color Output instead of YPbPr on your M1 Apple Silicon Mac for an External Monitor.
This step-by-step video tutorial will guide you through the procedure of forcing RGB color output on your M1 Mac.
Here is the direct link to the video tutorial: https://www.youtube.com/watch?v=Z1EqH3fd0V4
The video also has Closed Captions (Subtitles) that you can enable, to make it easier to follow if needed.
On Mac, SwiftUI's .onHover
closure is not always called on mouse exit, particularly with high cursor velocity. A grid of targets or with finer target shapes will often have multiple targets falsely active after the mouse has moved on.
It is easy to run back to AppKit's safety. Below is a SwiftUI-like modifier for reliable mouse-tracking. You can easily adapt it for other mouse tracking needs.
import SwiftUI
The package that linked you here is now pure ESM. It cannot be require()
'd from CommonJS.
This means you have the following choices:
- Use ESM yourself. (preferred)
Useimport foo from 'foo'
instead ofconst foo = require('foo')
to import the package. You also need to put"type": "module"
in your package.json and more. Follow the below guide. - If the package is used in an async context, you could use
await import(…)
from CommonJS instead ofrequire(…)
. - Stay on the existing version of the package until you can move to ESM.
// | |
// KeyCommand.swift | |
// Adds Keyboard Shortcuts to SwiftUI on iOS 13 | |
// See https://steipete.com/posts/fixing-keyboardshortcut-in-swiftui/ | |
// License: MIT | |
// | |
// Usage: (wrap view in `KeyboardEnabledHostingController`) | |
// Button(action: { | |
// print("Button Tapped!!") | |
// }) { |
import Foundation | |
extension Data { | |
init?(hexString: String) { | |
let len = hexString.count / 2 | |
var data = Data(capacity: len) | |
for i in 0..<len { | |
let j = hexString.index(hexString.startIndex, offsetBy: i*2) | |
let k = hexString.index(j, offsetBy: 2) | |
let bytes = hexString[j..<k] |
@propertyWrapper | |
public struct AnyProxy<EnclosingSelf, Value> { | |
private let keyPath: ReferenceWritableKeyPath<EnclosingSelf, Value> | |
public init(_ keyPath: ReferenceWritableKeyPath<EnclosingSelf, Value>) { | |
self.keyPath = keyPath | |
} | |
@available(*, unavailable, message: "The wrapped value must be accessed from the enclosing instance property.") | |
public var wrappedValue: Value { |