Skip to content

Instantly share code, notes, and snippets.

🛠
Working

Will Townsend wtsnz

🛠
Working
Block or report user

Report or block wtsnz

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@wtsnz
wtsnz / Scale Around Anchor Point.swift
Created Jun 12, 2019
Scale transform around anchor point
View Scale Around Anchor Point.swift
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 Dec 12, 2018
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.
View fix-diffmerge.applescript
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 Oct 25, 2018
An example Collada file
View blue-cube.dae
<?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 / cube.dae
Created Oct 25, 2018
An example Collada file
View cube.dae
<?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 / UIImage+InCurrentBundle.swift
Created May 8, 2017
Load a UIImage from an xcassets library in your framework.
View UIImage+InCurrentBundle.swift
extension UIImage {
convenience init?(inCurrentBundleNamed: String) {
class BundleClass { }
self.init(named: inCurrentBundleNamed, in: Bundle(for: BundleClass.self), compatibleWith: nil)
}
}
@wtsnz
wtsnz / OpenGLAudioVisualiserComponent.cpp
Created Apr 15, 2017
A hacky version of the JUCE AudioVisualiserComponent that renders the graph OpenGL
View OpenGLAudioVisualiserComponent.cpp
/*
==============================================================================
OpenGLAudioVisualiserComponent.cpp
Created: 15 Apr 2017 8:00:56pm
Author: Will Townsend
==============================================================================
*/
@wtsnz
wtsnz / index.js
Created Feb 18, 2017
Fabric to Pushover: New Users
View index.js
var Pushover = require('node-pushover');
var moment = require('moment');
var request = require('request');
// Fill out with your secrets
var secrets = {
pushover: {
token: '',
user: ''
},
View keybase.md

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

@wtsnz
wtsnz / delazy.js
Last active Aug 2, 2016
Super hacky script to delazy your swift files to decrease compile time.
View delazy.js
//
// Hacky script to convert lazy loaded closures into private instance functions
// The script ignores Pods, Carthage and build folders, and only looks for
// .swift files
// This doesn't work on all cases, and may break things. Be warned ⚠️
//
// Usage:
// node delazy.js <folder path>
//
View configure-ats.sh
# 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}"
You can’t perform that action at this time.