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 / 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 / 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 / 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 / !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.

# Delete any existing NSAppTransportSecurity configurations
/usr/libexec/PlistBuddy -c "Delete :NSAppTransportSecurity" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
# Add the NSAppTransportSecurity dictionary again
/usr/libexec/PlistBuddy -c "Add :NSAppTransportSecurity dict" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
/usr/libexec/PlistBuddy -c "Add :NSAppTransportSecurity:NSExceptionDomains dict" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
# Add s3.amazonaws.com NSExceptionRequiresForwardSecrecy and set it to false
# This is a requirement of the Carnival.io SDK
/usr/libexec/PlistBuddy -c "Add :NSAppTransportSecurity:NSExceptionDomains:s3.amazonaws.com dict" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
官方视频地址: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 / 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 / OpenGLAudioVisualiserComponent.cpp
Created April 15, 2017 22:32
A hacky version of the JUCE AudioVisualiserComponent that renders the graph OpenGL
/*
==============================================================================
OpenGLAudioVisualiserComponent.cpp
Created: 15 Apr 2017 8:00:56pm
Author: Will Townsend
==============================================================================
*/