Skip to content

Instantly share code, notes, and snippets.

View jverkoey's full-sized avatar

Jeff jverkoey

View GitHub Profile
@jverkoey
jverkoey / Figma analytics API.md
Last active March 29, 2024 18:49
Figma's undocumented analytics API endpoints

Notice

This is an undocumented API. It may break at any time. Contributions welcome; please share in the comments and I will update the gist accordingly.

Authentication

Each request must be passed a valid authentication cookie. The cookie takes the following form and can be pulled from any authenticated request made in the browser:

@jverkoey
jverkoey / UIFont+CustomizedDynamicType.m
Created April 14, 2021 01:07
Dynamic Type system fonts with custom point sizes, weight, and italics
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 February 7, 2019 01:04
Personal machine configuration
## 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
@jverkoey
jverkoey / Data+xored.swift
Created February 6, 2019 18:33
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 })
}
}
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
}
/*
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 April 12, 2017 18:25
Directly manipulable constraints
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>?
}
}
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)
}
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)
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,