Skip to content

Instantly share code, notes, and snippets.

Avatar
👾
Hacking on Windfish 👾

featherless jverkoey

👾
Hacking on Windfish 👾
View GitHub Profile
@jverkoey
jverkoey / UIFont+CustomizedDynamicType.m
Created Apr 14, 2021
Dynamic Type system fonts with custom point sizes, weight, and italics
View UIFont+CustomizedDynamicType.m
static const CGFloat kFontWeightEpsilon = FLT_EPSILON;
@implementation UIFont (CustomizedDynamicType)
+ (nonnull UIFont *)preferredFontWithDefaultSize:(CGFloat)size
textStyle:(nonnull UIFontTextStyle)textStyle {
return [self preferredFontWithDefaultSize:size
textStyle:textStyle
fontWeight:UIFontWeightRegular
italic:NO];
@jverkoey
jverkoey / machine.sh
Last active Feb 7, 2019
Personal machine configuration
View machine.sh
## One-time setup
# Deletes references to remote branches during git fetch
git config --global fetch.prune true
## .bashrc
# Pushes the local branch to origin and makes the local branch track the remote
gpush() {
git push origin $(git rev-parse --abbrev-ref HEAD) -u
View Data+xored.swift
import Foundation
extension Data {
/**
Returns the result of xor'ing self with the given Data.
*/
public func xored(with rhs: Data) -> Data {
return Data(zip(self, rhs).map { $0 ^ $1 })
}
}
View PhotoAlbumTransition.swift
func start(with context: TransitionContext) {
guard let contextView = backDelegate.backContextView(for: self,
with: context.foreViewController) else {
return
}
guard let foreImageView = foreDelegate.foreContextView(for: self) else {
return
}
View MDMCoreAnimationAnimator.h
/*
Copyright 2017-present The Material Motion Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@jverkoey
jverkoey / DirectlyManipulable.swift
Created Apr 12, 2017
Directly manipulable constraints
View DirectlyManipulable.swift
public final class DirectlyManipulable {
public func add(to view: UIView, withRuntime runtime: MotionRuntime, constraints: NoConstraints)
public final class Constraints {
public var draggable: ConstraintApplicator<T>?
public var rotatable: ConstraintApplicator<T>?
public var scalable: ConstraintApplicator<T>?
}
}
View pluralOpenValve.swift
public func openValve<O: MotionObservableConvertible>(whenAllTrue observables: [O]) -> MotionObservable<T> where O.T == Bool {
return MotionObservable<T> { observer in
var upstreamSubscription: Subscription?
var connectUpstream = {
upstreamSubscription = self.asStream().subscribe(next: observer.next,
state: observer.state,
coreAnimation: observer.coreAnimation)
}
View rubberbanded-drag.swift
let square2Reactive = runtime.get(square2.layer)
let pan = runtime.get(UIPanGestureRecognizer())
let rawPosition = createProperty(withInitialValue: square2.layer.position)
runtime.add(pan.translated(from: rawPosition, in: view), to: rawPosition)
runtime.add(rawPosition.y().rubberBanded(below: 50, above: 400, length: 100), to: square2Reactive.positionY)
View spring-directly-manipulable.swift
let pan = UIPanGestureRecognizer()
let rotate = UIRotationGestureRecognizer()
let scale = UIPinchGestureRecognizer()
[pan, rotate, scale].forEach { $0.delegate = self }
let directlyManipulable = DirectlyManipulable(view: square,
containerView: view,
panGestureRecognizer: pan,
rotationGestureRecognizer: rotate,
View CardSwipeInteraction.swift
/*
Copyright 2016-present The Material Motion Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software