Skip to content

Instantly share code, notes, and snippets.

Avatar

Matt Curtis matt-curtis

View GitHub Profile
@matt-curtis
matt-curtis / SwiftUIKeyboardResizing.swift
Last active Aug 28, 2021
iOS 15 SwiftUI Keyboard Resizing (Bug?) Workaround
View SwiftUIKeyboardResizing.swift
import UIKit
import SwiftUI
class KeyboardViewController: UIInputViewController {
override func viewDidLoad() {
super.viewDidLoad()
struct ContentView: View {
@matt-curtis
matt-curtis / AnimatableMemberHaving.swift
Last active Aug 22, 2021
AnimatableMemberHaving: A protocol that enables types whose members are made up of Animatable or VectorArithmetic-conforming properties to become Animatable themselves by specifying those members
View AnimatableMemberHaving.swift
import SwiftUI
/// A protocol that enables types whose members are made up of `Animatable` or `VectorArithmetic`-conforming properties
/// to become `Animatable` themselves by specifying those members.
///
/// Here's an example of how to use this protocol:
///
/// ```
/// struct CornerRadii: AnimatableMemberHaving {
///
@matt-curtis
matt-curtis / 1.Info.md
Last active Dec 22, 2020
CALayer.shadowPath and CALayer.path don't overshoot when spring animated.
View 1.Info.md

Playground demonstrating CALayer.shadowPath's failure to overshoot when spring animated.

@matt-curtis
matt-curtis / LocalServer.swift
Created Mar 18, 2020
Really simple example showing how to create a basic local HTTP server in Swift
View LocalServer.swift
import Foundation
import Cocoa
private enum Constants {
static let crlf: Character = "\r\n"
}
/*
View SubstringFontReporting.js
let sketch = require('sketch')
let settingsAttribute = getSettingsAttributeForKey_Value(kLowerCaseType, kLowerCaseSmallCapsSelector)
applySubstringFontModification()
//getFontAttributesForSelectedRange()
function applySubstringFontModification() {
let document = sketch.getSelectedDocument()
let textLayer = document.selectedLayers.layers[0]
@matt-curtis
matt-curtis / example.js
Created Jan 27, 2019
Applying attributes to a text layer that's being edited in Sketch
View example.js
framework("CoreText");
const DOM = require("sketch/dom");
const textLayer = DOM.getSelectedDocument().pages[0].selectedLayers.layers[0];
const textView = textLayer.sketchObject.editingDelegate().textView();
// [NSTextView selectedRanges] returns an NSArray of NSValues:
const selectedRange = textView.selectedRanges()[0].rangeValue();
@matt-curtis
matt-curtis / DelegateForwarder.swift
Last active Mar 11, 2022
Delegate Forwarding in Swift. Useful for choosing some methods of a delegate to handle yourself and others to pass to a different delegate. Inspired by WebKit's Objective-C implementation of the same for UIScrollViewDelegate: https://github.com/WebKit/WebKit/blob/20586209d4e623ecaf489c9913a5732d80ba6e39/Source/WebKit/UIProcess/ios/WKScrollView.m…
View DelegateForwarder.swift
class DelegateForwarder<T: NSObjectProtocol>: NSObject {
// MARK: - Properties
weak var internalDelegate: T?
weak var externalDelegate: T?
var asConforming: T {
View UnitBezier.swift
//
// UnitBezier.swift
//
// Created by Matt Curtis on 12/24/18.
// Copyright © 2018 Matt Curtis. All rights reserved.
//
import Foundation
// Almost exact translation of WebKit's UnitBezier struct:
@matt-curtis
matt-curtis / FontSpike.js
Last active Dec 18, 2018 — forked from KevinGutowski/FontSpike.js
Testing to see if I can build an Opentype Panel
View FontSpike.js
framework("CoreText");
const document = require("sketch").getSelectedDocument();
const textLayer = document.selectedLayers.layers[0];
// WORKS (System font has native support for small caps):
const font = NSFont.systemFontOfSize_weight(28, NSFontWeightBold);
@matt-curtis
matt-curtis / Lenovo G510 High Sierra Notes.md
Last active Feb 10, 2019
Lenovo G510 High Sierra Notes
View Lenovo G510 High Sierra Notes.md

Checklist:

  • WIFI
  • Ethernet
  • Display
  • Touchpad
  • USB (2 & 3)
  • HDMI (Video works, haven't bothered to fix audio yet)
  • Sleep
  • Audio (No microphone)