View FixChapGTP.css
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
/* word wrap for code blocks */ | |
.\!whitespace-pre { | |
white-space: pre-wrap!important; | |
} | |
/* make chat window wider */ | |
#__next > div.overflow-hidden.w-full.h-full.relative.flex.z-0 > div.relative.flex.h-full.max-w-full.flex-1.overflow-hidden > div > main > div.flex-1.overflow-hidden > div > div > div > div > div { | |
max-width: 95% !important; | |
} |
View obsidian-pico-publish.py
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 python3 | |
import os | |
import json | |
import re | |
import fnmatch | |
from pathlib import Path | |
##################### |
View URL+OpenInFilesApp.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
// thanks to this thing! | |
// https://www.macstories.net/ios/fs-bookmarks-a-shortcut-to-reopen-files-and-folders-directly-in-the-files-app/ | |
extension URL { | |
func openParentDirectoryInFilesApp() { | |
guard var components = URLComponents(url: self.deletingLastPathComponent(), resolvingAgainstBaseURL: false) else { return } | |
components.scheme = "shareddocuments" | |
guard let newURL = components.url else { return } |
View Publisher.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
import Foundation | |
/* | |
* Prompt: | |
* I want a Swift object that will sit on an object (let's call that object A) which will allow other objects (B, C, D) to subscribe to changes in A on a certain variable. | |
* | |
* So the Swift class/object that you're making allows subscribers to provide a block to be executed based on the changes in that variable. The variable could be a Bool, but if you have to box it as an NSNumber, that's fine. | |
* | |
* Response: | |
* You can achieve this behavior in Swift using a closure (or block in Objective-C terminology) for notifying changes. Here's a simple example with a Publisher class that wraps an object and allows other classes to subscribe for changes: |
View LockingScrollView.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
// (c) Confusion Studios LLC and affiliates. Confidential and proprietary. | |
import UIKit | |
public class LockingScrollView: UIScrollView, UIScrollViewDelegate { | |
public var isPanningZoomingEnabled = false | |
init() { | |
super.init(frame: .zero) | |
delegate = self |
View MakeViewsInSwiftUI.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
// MARK: - Bad: "Use of protocol 'View' as a type must be written 'any View'" | |
struct LeftRightView: View { | |
let leftView: View | |
let rightView: View | |
var body: some View { | |
HStack { | |
leftView | |
rightView |
View ViewController.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
// (c) Confusion Studios LLC and affiliates. Confidential and proprietary. | |
import SwiftUI | |
import UIKit | |
class ViewController: UIViewController { | |
override func viewDidLoad() { | |
view.backgroundColor = .orange | |
let swiftUIView = ContentView().asUIView |
View MultipartRequest.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
/// MultipartRequest by Dan Rosenstark | |
/// Thanks to tinyurl.com/2qpbyh7v: this code is just a remix | |
/// | |
/// Steps to use | |
/// 1. init | |
/// 2. add form fields (if any) | |
/// 3. add file data (if any) | |
/// 4. grab the urlRequest and use it | |
struct MultipartRequest { | |
private let boundary = "Boundary-\(UUID().uuidString)" |
View DispatchQueue+Util.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
// Copyright 2022 Confusion Studios LLC | |
// by Dan Rosenstark | |
import Foundation | |
/// Extension on DispatchQueue? for Testing | |
/// If you don't have a DispatchQueue, run immediately (on current queue) | |
extension Optional where Wrapped : DispatchQueue { | |
public func asyncIfNotNil(execute block: @escaping ()->()) { | |
if let self = self { | |
self.async(execute: block) |
NewerOlder