Skip to content

Instantly share code, notes, and snippets.

View jverkoey's full-sized avatar

Jeff Verkoeyen jverkoey

View GitHub Profile
@jverkoey
jverkoey / StockGraph.swift
Created August 5, 2024 13:25
Stock graph
import Charts
import SwiftUI
let oneDay: TimeInterval = 60 * 60 * 24
struct ContentView: View {
var body: some View {
let history = loadHistory()
.filter { $0.id > Date.now.addingTimeInterval(-oneDay * 30) }
let analysis = TradingAnalysis(history: history)
@jverkoey
jverkoey / FlipButton.swift
Last active August 1, 2024 12:49
Google Maps directions button
import SwiftUI
struct FlipButton: View {
@State private var orientation: Int = 0
var body: some View {
Button {
orientation += 180
} label: {
Image(systemName: "arrow.up.arrow.down")
@jverkoey
jverkoey / SpotifyDrilldown.swift
Created July 31, 2024 15:05
Spotify drilldown filter
import SwiftUI
struct SpotifyToggle: View {
let value: String
@Binding var selection: String?
let didTap: () -> Void
var body: some View {
Toggle(value, isOn: .init(get: { selection == value }, set: { _ in
withAnimation {
if selection == nil {
@jverkoey
jverkoey / LinkedInActivityIndicator.swift
Last active July 30, 2024 11:53
LinkedIn activity indicator in SwiftUI
import SwiftUI
struct LinkedInActivityIndicator: View {
@State private var animating = false
let cornerRadius: CGFloat
var body: some View {
GeometryReader { proxy in
ZStack {
@jverkoey
jverkoey / SeamlessCarousel.swift
Last active August 6, 2024 17:17
Threads: seamless carousel in SwiftUI
import SwiftUI
struct SeamlessCarouselDemo: View {
@State private var seamless = false
@ViewBuilder
func image(_ name: String) -> some View {
Image(name)
.resizable(resizingMode: .stretch)
.aspectRatio(contentMode: .fit)
@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
}