Skip to content

Instantly share code, notes, and snippets.

View wtsnz's full-sized avatar
🛠️
Working

Will Townsend wtsnz

🛠️
Working
View GitHub Profile
@wtsnz
wtsnz / CollectionView.swift
Created October 6, 2023 16:06 — forked from KazaiMazai/CollectionView.swift
Better SwiftUI wrapper for UICollectionView
import SwiftUI
extension CollectionView {
typealias UIKitCollectionView = CollectionViewWithDataSource<SectionIdentifierType, ItemIdentifierType>
typealias DataSource = UICollectionViewDiffableDataSource<SectionIdentifierType, ItemIdentifierType>
typealias Snapshot = NSDiffableDataSourceSnapshot<SectionIdentifierType, ItemIdentifierType>
typealias UpdateCompletion = () -> Void
}
struct CollectionView<SectionIdentifierType, ItemIdentifierType>
@wtsnz
wtsnz / !swiftui-reflection-dump.md
Last active April 14, 2023 12:35 — forked from ole/!swiftui-reflection-dump.md
A dump of the SwiftUI.framework binary for the iOS simulator (as of Xcode 12.0 beta 2) using the swift-reflection-dump tool.

A dump of the SwiftUI.framework binary for the iOS simulator (as of Xcode 12.0 beta 2) using the swift-reflection-dump tool.

Note: I used a Swift 5.3 compiler build from a few weeks ago that I had laying around. Because of ABI stability, I don't think the swift-reflection-dump version has to match the compiler version that was used to build the binary, but I'm not 100% sure.

@wtsnz
wtsnz / bitcoin.md
Last active November 28, 2021 00:09
Introducing Bitcoin by Ryan X Charles
Introducing Bitcoin
ryan@ryanxcharles.com
Nov 19, 2021
https://www.ryanxcharles.com/content/

Introduction

I’ve been involved in Bitcoin since May 13, 2011 when I read an article about Bitcoin on Hacker News. It struck me that Bitcoin had the potential to be the foundation of a new global industry like the internet, but with money instead of communications. I was hooked right away and spent weeks researching it.

官方视频地址:https://developer.apple.com/videos/wwdc/2014/
权当留个念想,选择下面的链接,然后复制,在迅雷中新建下载,粘贴即可。支持多文件下载。
对应的字幕可以查看 https://github.com/qiaoxueshi/WWDC_2014_Video_Subtitle
http://devstreaming.apple.com/videos/wwdc/2014/704xx7dmqd5m9l4/704/704_sd_building_apps_for_enterprise_and_education.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2014/236xxwk3fv82sx2/236/236_sd_building_interruptible_and_responsive_interactions.mov?dl=1
@wtsnz
wtsnz / ContentView.swift
Last active February 27, 2024 15:53
Playing around with hosting SwiftUI Views in an NSWindow from inside a View 🙃 (also works for the NSStatusBar item!)
import SwiftUI
struct ContentView: View {
@State var now = Date()
@State var showWindow = false
@State var text: String = ""
let timer = Timer.publish(every: 1, on: .current, in: .common).autoconnect()
@wtsnz
wtsnz / RemoteImage.swift
Created October 12, 2019 18:53
(Extremely) Basic way to load a remote image from URL in SwiftUI
import Combine
import SwiftUI
class RemoteImageLoader: ObservableObject {
@Published var data: Data = Data()
init(imageURL: URL) {
URLSession.shared.dataTask(with: imageURL) { data, response, error in
guard let data = data else { return }

Keybase proof

I hereby claim:

  • I am wtsnz on github.
  • I am wtsnz (https://keybase.io/wtsnz) on keybase.
  • I have a public key ASC17QHmm7ML5wO9fwnmJCHCSRYVxhI1_-F7x5mw7euY9Qo

To claim this, I am signing this object:

@wtsnz
wtsnz / Scale Around Anchor Point.swift
Created June 12, 2019 23:45
Scale transform around anchor point
func scaleTransform(for view: UIView, scaledBy scale: CGPoint, aroundAnchorPoint relativeAnchorPoint: CGPoint) -> CGAffineTransform {
let bounds = view.bounds
let anchorPoint = CGPoint(x: bounds.width * relativeAnchorPoint.x, y: bounds.height * relativeAnchorPoint.y)
return CGAffineTransform.identity
.translatedBy(x: anchorPoint.x, y: anchorPoint.y)
.scaledBy(x: scale.x, y: scale.y)
.translatedBy(x: -anchorPoint.x, y: -anchorPoint.y)
}
@wtsnz
wtsnz / fix-diffmerge.applescript
Last active December 12, 2018 00:47
Sometimes after using DiffMerge with multiple monitor setups, it's positioned way up above the OSX menu bar and I'm unable to see the entire window. This small Apple Script snippet rescues me.
tell application "System Events" to tell application process "DiffMerge"
tell window 1
set {size, position} to {{400, 400}, {50, 50}}
end tell
end tell
@wtsnz
wtsnz / blue-cube.dae
Last active October 25, 2018 18:37
An example Collada file
<?xml version="1.0" encoding="UTF-8"?>
<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1">
<asset>
<contributor>
<authoring_tool>SceneKit Collada Exporter v1.0</authoring_tool>
</contributor>
<created>2018-10-25T16:29:03Z</created>
<modified>2018-10-25T16:29:03Z</modified>
<unit meter="1.000000"/>
<up_axis>Y_UP</up_axis>