<?xml version='1.0' encoding='utf-8'?>

<rss version='2.0'
  xmlns:content='http://purl.org/rss/1.0/modules/content/'
  xmlns:dc='http://purl.org/dc/elements/1.1/'
>

<!--
<rdf:RDF
  xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'
  xmlns='http://purl.org/rss/1.0/'
>
-->

<channel>

  <title>Borkware Quickies</title>
  <description>
    Quickies - Little chunklets of Mac OS X and Unix Information.
  </description>
  <pubDate>Sun, 16 Feb 2025 20:41:05 UTC</pubDate>
  <link>http://borkware.com</link>

<item>
  <title> (General-&gt;Hacks)</title>
  <pubDate>Sun, 16 Feb 2025 20:41:05 UTC</pubDate>
  <description>
     Getting a really annoying warning with nothing actionable when implemented secure (de)coding?&lt;br&gt;&lt;br&gt;

&lt;pre&gt;
*** -[NSKeyedUnarchiver validateAllowedClass:forKey:] allowed unarchiving safe plist type &#39;&#39;NSString&#39; (0x1ec071f50)
[/Library/Developer/CoreSimulator/Volumes/iOS_22B81/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS
18.1.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/Foundation.framework]&#39; for key &#39;&#39;, 
even though it was not explicitly included in the client allowed classes set: 
&#39;&amp;lt;decode: bad range for [%{public}@] got [offs:647 len:474 within:0]&gt;&#39;. 
This will be disallowed in the future.&amp;lt;decode: bad range for [%{public}@] 
got [offs:1121 len:1 within:0]&gt;
&lt;/pre&gt;

you can set this breakpoint to break there. (wouldn&#39;t it have been nice if they had mentioned that in the warning?):

&lt;pre&gt;
-[NSCoder _warnAboutPlistType:forKey:missingInAllowedClasses:]
&lt;/pre&gt;&lt;br&gt;
  </description>
  <link>http://borkware.com/quickies/single?id=627</link>
  <guid isPermaLink='true'>http://borkware.com/quickies/single?id=627</guid>
</item>

<item>
  <title>Adding a new environment value (SwiftUI-&gt;Random)</title>
  <pubDate>Sun, 24 Dec 2023 02:33:07 UTC</pubDate>
  <description>
     &lt;pre&gt;&lt;br&gt;&lt;br&gt;private struct ScreamAtMeKey: EnvironmentKey {
    static let defaultValue = false
}

// Set via .environent(\.screamAtMe, true)
extension EnvironmentValues {
    var screamAtMe: Bool {
        get { self[ScreamAtMeKey.self] }
        set { self[ScreamAtMeKey.self] = newValue }
    }
}

// Set via .screamAtMe(true)
extension View {
    func screamAtMe(_  aaaaaah: Bool) -&gt; some View {
        environment(.screamAtMe, aaaaaah)
    }
}
&lt;/pre&gt;&lt;br&gt;
  </description>
  <link>http://borkware.com/quickies/single?id=626</link>
  <guid isPermaLink='true'>http://borkware.com/quickies/single?id=626</guid>
</item>

<item>
  <title>Doing Notifications Swiftstyle (Swift-&gt;Random)</title>
  <pubDate>Mon, 06 Nov 2023 03:24:09 UTC</pubDate>
  <description>
     Posting end&lt;br&gt;&lt;br&gt;
&lt;pre&gt;
   NotificationCenter.default.post(name: Notification.Name(&#34;FishBattery&#34;), object: tour)
&lt;/pre&gt;

Receiving end

&lt;pre&gt;
NotificationCenter.default.addObserver(
    forName: Notification.Name(&#34;FishBattery&#34;),
    object: tour,
    queue: OperationQueue.main) { [weak self] notification in
        guard let tour = notification.object as? Tour else {
            return
        }
        if tour == self?.tour {
            self?.uploadIfNeeded()
        }
    }
&lt;/pre&gt;&lt;br&gt;
  </description>
  <link>http://borkware.com/quickies/single?id=625</link>
  <guid isPermaLink='true'>http://borkware.com/quickies/single?id=625</guid>
</item>

<item>
  <title>Making a simple button (SwiftUI-&gt;Random)</title>
  <pubDate>Sun, 22 Oct 2023 16:35:30 UTC</pubDate>
  <description>
     &lt;pre&gt;&lt;br&gt;&lt;br&gt;Button(&#34;Button Text&#34;) {
    print(&#34;Snorgle&#34;)
}
&lt;/pre&gt;&lt;br&gt;
  </description>
  <link>http://borkware.com/quickies/single?id=624</link>
  <guid isPermaLink='true'>http://borkware.com/quickies/single?id=624</guid>
</item>

<item>
  <title>Making a custom button style (SwiftUI-&gt;Random)</title>
  <pubDate>Fri, 06 Oct 2023 14:55:50 UTC</pubDate>
  <description>
     &lt;pre&gt;&lt;br&gt;&lt;br&gt;struct CustomButtonStyle: ButtonStyle {
    func makeBody(configuration: Configuration) -&gt; some View {
        configuration.label
            .padding()
            .background(.purple)
            .foregroundStyle(.green)
            .clipShape(RoundedRectangle(cornerRadius: 25, style: .continuous))
            .scaleEffect(configuration.isPressed ? 2.0 : 1)
            .animation(.easeOut(duration: 0.05), value: configuration.isPressed)
    }
}
&lt;/pre&gt;

(please don&#39;t actually make buttons with this style...)

And then attach it to something (say an individual button, or a top-level view) like

&lt;pre&gt;
        .buttonStyle(CustomButtonStyle())
&lt;/pre&gt;&lt;br&gt;
  </description>
  <link>http://borkware.com/quickies/single?id=623</link>
  <guid isPermaLink='true'>http://borkware.com/quickies/single?id=623</guid>
</item>

<item>
  <title>Easily giving buttons a border/background (SwiftUI-&gt;Random)</title>
  <pubDate>Fri, 06 Oct 2023 14:41:54 UTC</pubDate>
  <description>
     I still dislike the iOS 7 &#34;here&#39;s some random blue text. Really, it&#39;s a button&#34;. I like buttons to look like buttons.  You can add a `.buttonStyle` to a view, and it&#39;ll apply the style to al the buttons inside.&lt;br&gt;&lt;br&gt;
Here&#39;s the different out of the box styles. You can also make your own custom button style.

&lt;pre&gt;
        .buttonStyle(.bordered)  // gray filled oval
        .buttonStyle(.borderedProminent) // blue filled oval
        .buttonStyle(.borderless) // default (I think) - free floating random blue text
        .buttonStyle(.plain)  // free floating random plain text. that&#39;s also a button
&lt;/pre&gt;&lt;br&gt;
  </description>
  <link>http://borkware.com/quickies/single?id=622</link>
  <guid isPermaLink='true'>http://borkware.com/quickies/single?id=622</guid>
</item>

<item>
  <title>Exposing documents directory to Files / Finder (Hacks-&gt;Random)</title>
  <pubDate>Tue, 03 Oct 2023 01:18:25 UTC</pubDate>
  <description>
     Set these both to YES in the Info.plist&lt;br&gt;&lt;br&gt;
&lt;pre&gt;
UIFileSharingEnabled
LSSupportsOpeningDocumentsInPlace
&lt;/pre&gt;&lt;br&gt;
  </description>
  <link>http://borkware.com/quickies/single?id=621</link>
  <guid isPermaLink='true'>http://borkware.com/quickies/single?id=621</guid>
</item>

<item>
  <title>Default to a particular tab bar tab (SwiftUI-&gt;Random)</title>
  <pubDate>Tue, 03 Oct 2023 00:48:52 UTC</pubDate>
  <description>
     &lt;pre&gt;&lt;br&gt;&lt;br&gt;enum Tab: Hashable {
    case simplePlan
    case complicatedPlan
    case multiPlan

    var id: Self { self }
}

struct ContentView: View {
    &lt;b&gt;@State private var tab = Tab.complicatedPlan&lt;/b&gt;

    var body: some View {
        &lt;b&gt;TabView(selection: $tab)&lt;/b&gt; {
            SimplePlan(captureModel: SimpleCaptureModel.shared)
              .tabItem {
                  Label(&#34;Simple Plan&#34;, systemImage: &#34;house&#34;)
              }
              &lt;b&gt;.tag(Tab.simplePlan)&lt;/b&gt;
            CompliPlan(captureModel: CompliCaptureModel.shared)
              .tabItem {
                  Label(&#34;Complicated Plan&#34;, systemImage: &#34;house.circle.fill&#34;)
              }
              &lt;b&gt;.tag(Tab.complicatedPlan)&lt;/b&gt;
            MultiPlan()
              .tabItem {
                  Label(&#34;Multi Plan&#34;, systemImage: &#34;house.lodge&#34;)
              }
              &lt;b&gt;.tag(Tab.multiPlan)&lt;/b&gt;
        }
    }
}
&lt;/pre&gt;&lt;br&gt;
  </description>
  <link>http://borkware.com/quickies/single?id=620</link>
  <guid isPermaLink='true'>http://borkware.com/quickies/single?id=620</guid>
</item>

<item>
  <title>Wrapping a UIView (SwiftUI-&gt;Random)</title>
  <pubDate>Sat, 30 Sep 2023 23:52:06 UTC</pubDate>
  <description>
     Given a UIView, add it to SwiftUI via UIViewRepresentable.&lt;br&gt;&lt;br&gt;
&lt;pre&gt;
struct PlaceholderContainerView: UIViewRepresentable {

    func makeUIView(context: Context) -&gt; PlaceholderUIView {
        return PlaceholderUIView()
    }

    func updateUIView(_ uIView: PlaceholderUIView, context: Context) {
        print(&#34;update ui view (context)&#34;)
    }
}
&lt;/pre&gt;&lt;br&gt;
  </description>
  <link>http://borkware.com/quickies/single?id=619</link>
  <guid isPermaLink='true'>http://borkware.com/quickies/single?id=619</guid>
</item>

<item>
  <title>Basic Tab View (SwiftUI-&gt;Random)</title>
  <pubDate>Sat, 30 Sep 2023 23:30:36 UTC</pubDate>
  <description>
     &lt;pre&gt;&lt;br&gt;&lt;br&gt;struct ContentView: View {
    var body: some View {
        TabView {
            SimplePlan()
              .badge(23)
              .tabItem {
                  Label(&#34;Simple Plan&#34;, systemImage: &#34;house&#34;)
              }
            MultiPlan()
              .tabItem {
                  Label(&#34;Simple Plan&#34;, systemImage: &#34;house.lodge&#34;)
              }
        }
    }
}
&lt;/pre&gt;&lt;br&gt;
  </description>
  <link>http://borkware.com/quickies/single?id=618</link>
  <guid isPermaLink='true'>http://borkware.com/quickies/single?id=618</guid>
</item>

<item>
  <title>move to previous buffer C-x p (emacs-&gt;Hacks)</title>
  <pubDate>Sat, 15 Jul 2023 18:52:28 UTC</pubDate>
  <description>
     &lt;pre&gt;&lt;br&gt;&lt;br&gt;(global-set-key (kbd &#34;C-x p&#34;) &#39;move-to-previous-window)

(defun move-to-previous-window ()
  &#34;Move to the previous window.&#34;
  (interactive)
  (other-window -1))
&lt;/pre&gt;&lt;br&gt;
  </description>
  <link>http://borkware.com/quickies/single?id=617</link>
  <guid isPermaLink='true'>http://borkware.com/quickies/single?id=617</guid>
</item>

<item>
  <title>Turn off xcode's brace-matching animation (Xcode-&gt;Hacks)</title>
  <pubDate>Tue, 13 Apr 2021 20:48:57 UTC</pubDate>
  <description>
     &lt;pre&gt;&lt;br&gt;&lt;br&gt;% defaults write com.apple.dt.Xcode DVTTextShowMatchingBrace -bool NO
&lt;/pre&gt;

I &lt;3 Zach Waldowski for this tidbit.&lt;br&gt;
  </description>
  <link>http://borkware.com/quickies/single?id=616</link>
  <guid isPermaLink='true'>http://borkware.com/quickies/single?id=616</guid>
</item>

<item>
  <title>Silencing Macbook power chime (Unix-&gt;General)</title>
  <pubDate>Thu, 08 Aug 2019 17:55:37 UTC</pubDate>
  <description>
     The modern-day flutterby keyboard Macbooks make a soothing (?) chime when plugged in to power, even if the system volume is muted.  If you don&#39;t want to hear that, you can do&lt;br&gt;&lt;br&gt;
&lt;pre&gt;
% defaults write com.apple.PowerChime ChimeOnNoHardware -bool true
% sudo killall PowerChime
&lt;/pre&gt;&lt;br&gt;
  </description>
  <link>http://borkware.com/quickies/single?id=615</link>
  <guid isPermaLink='true'>http://borkware.com/quickies/single?id=615</guid>
</item>

<item>
  <title>Scroll to a particular collection view item. (UIContainerView-&gt;General)</title>
  <pubDate>Sat, 17 Nov 2018 19:37:34 UTC</pubDate>
  <description>
     &lt;pre&gt;&lt;br&gt;&lt;br&gt;- (void) viewDidLayoutSubviews {
    // doing this in viewDidAppear might not work well b/c the collection view might
    // not have completed layout yet
   [super viewDidLayoutSubviews];

   NSIndexPath *indexPath = [NSIndexPath indexPathForItem: self.currentPatchNumber
                                         inSection: 0];
   UICollectionViewScrollPosition scrollPosition =
       UICollectionViewScrollPositionCenteredVertically; // maybe also horizontally if you want

   [self.collectionView scrollToItemAtIndexPath: indexPath
                               atScrollPosition: scrollPosition
                                       animated: NO];

} // viewDidLayoutSubviews
&lt;/pre&gt;&lt;br&gt;
  </description>
  <link>http://borkware.com/quickies/single?id=614</link>
  <guid isPermaLink='true'>http://borkware.com/quickies/single?id=614</guid>
</item>

<item>
  <title>Accessing a class method from an instance. (General-&gt;Swift)</title>
  <pubDate>Tue, 06 Nov 2018 19:17:04 UTC</pubDate>
  <description>
     Say you have an instance, and you want to call a class method, similar to objc where you could do something like &lt;tt&gt;self.class.insets.left&lt;/tt&gt;.  Use &lt;tt&gt;type(of: self).methodName()&lt;/tt&gt;&lt;br&gt;&lt;br&gt;
&lt;pre&gt;
class Bargle {
    static func greeble() {
        print(&#34;Blargle greeble&#34;)
    }

    func oopack() {
        type(of: self).greeble()
    }
}

let bargle = Bargle()
bargle.oopack()
&lt;/pre&gt;

This will cause &lt;i&gt;Blargle greeble&lt;/i&gt;&lt;br&gt;
  </description>
  <link>http://borkware.com/quickies/single?id=613</link>
  <guid isPermaLink='true'>http://borkware.com/quickies/single?id=613</guid>
</item>

<item>
  <title>sizeof in swift (General-&gt;Swift)</title>
  <pubDate>Mon, 05 Nov 2018 21:22:34 UTC</pubDate>
  <description>
     Say you have a struct:&lt;br&gt;&lt;br&gt;
&lt;pre&gt;
struct Thingie {
    let blah: Uint8
    let greeble: UInt8
    let splunge: UInt8
}
&lt;/pre&gt;

Get the &lt;tt&gt;sizeof&lt;/tt&gt; via 

&lt;pre&gt;
let packetLength = MemoryLayout&lt;Thingie&gt;.size
&lt;/pre&gt;

That&#39;s the packed size.  To account for alignment/padding, use &lt;tt&gt;stride&lt;/tt&gt;.&lt;br&gt;
  </description>
  <link>http://borkware.com/quickies/single?id=612</link>
  <guid isPermaLink='true'>http://borkware.com/quickies/single?id=612</guid>
</item>

<item>
  <title>Making a Data out of an array of UInt8 (General-&gt;Swift)</title>
  <pubDate>Mon, 05 Nov 2018 21:20:53 UTC</pubDate>
  <description>
     &lt;pre&gt;&lt;br&gt;&lt;br&gt;var payload: [UInt8] = [0x09, 0x00, 0x07, 0x00, 0x12, 0x00, 0x64, 0x02, 0x03, 0x04,
                        0x09, 0x81, 0x12, 0x00, 0x07, 0x00, 0x32, 0x04, 0x05, 0x06,
                        0x00, 0x00, 0x00, 0x00]

let bufferPointer = UnsafeBufferPointer(start: &amp;payload, count: payload.count)
let buffer = Data(buffer: bufferPointer)
&lt;/pre&gt;&lt;br&gt;
  </description>
  <link>http://borkware.com/quickies/single?id=611</link>
  <guid isPermaLink='true'>http://borkware.com/quickies/single?id=611</guid>
</item>

<item>
  <title>Make archive of locally modified files in subversion (Subversion-&gt;General)</title>
  <pubDate>Mon, 07 May 2018 17:43:13 UTC</pubDate>
  <description>
     &lt;pre&gt;&lt;br&gt;&lt;br&gt;$ zip ~/modified.zip $(svn status | grep ^M | awk &#39;{ print $2;}&#39;)
&lt;/pre&gt;

(Bash syntax)&lt;br&gt;
  </description>
  <link>http://borkware.com/quickies/single?id=610</link>
  <guid isPermaLink='true'>http://borkware.com/quickies/single?id=610</guid>
</item>

<item>
  <title>Sort grep-c (Unix-&gt;General)</title>
  <pubDate>Sun, 15 Apr 2018 20:45:14 UTC</pubDate>
  <description>
     &lt;tt&gt;grep -c&lt;/tt&gt; will give you the number of hits for the given pattern in each file.  It&#39;d be nice to sort them, but the count occurs after the filename, e.g. &lt;tt&gt;GreebleBork:23&lt;/tt&gt;&lt;br&gt;&lt;br&gt;
&lt;p&gt;

So, trick &lt;tt&gt;sort&lt;/tt&gt; into using the last field (with a colon separator) as the sort key:

&lt;pre&gt;
% grep -c translatesAuto *.xib | sort -t: -n -k2
&lt;/pre&gt;&lt;br&gt;
  </description>
  <link>http://borkware.com/quickies/single?id=609</link>
  <guid isPermaLink='true'>http://borkware.com/quickies/single?id=609</guid>
</item>

<item>
  <title>Swift if case let (Swift-&gt;General)</title>
  <pubDate>Fri, 16 Mar 2018 13:44:02 UTC</pubDate>
  <description>
     Because I can never remember the syntax:&lt;br&gt;&lt;br&gt;
Given

&lt;pre&gt;
enum FilterOptionValue {
    case oneSided(value: Double)
    case twoSided(low: Float, high: Double)
}
&lt;/pre&gt;

You can unpack it piecewise on demand with

&lt;pre&gt;
        if case let .twoSided(low, high) = thingieOption.value {
            minThingie = Int(low)
            upperThingie = Int(high)
        }
&lt;/pre&gt;&lt;br&gt;
  </description>
  <link>http://borkware.com/quickies/single?id=608</link>
  <guid isPermaLink='true'>http://borkware.com/quickies/single?id=608</guid>
</item>

</channel>
</rss>
