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 / 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
==============================================================================
*/
@wtsnz
wtsnz / UIImage+InCurrentBundle.swift
Created May 8, 2017 01:17
Load a UIImage from an xcassets library in your framework.
extension UIImage {
convenience init?(inCurrentBundleNamed: String) {
class BundleClass { }
self.init(named: inCurrentBundleNamed, in: Bundle(for: BundleClass.self), compatibleWith: nil)
}
}
@wtsnz
wtsnz / cube.dae
Created October 25, 2018 18:36
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>
@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>
@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 / 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)
}

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 / 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 }
@wtsnz
wtsnz / ContentView.swift
Last active February 10, 2025 09:46
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()
官方视频地址: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