Skip to content

Instantly share code, notes, and snippets.

Kyle Sherman drumnkyle

Block or report user

Report or block drumnkyle

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
@drumnkyle
drumnkyle / AllComponentPreviews.swift
Last active Feb 19, 2020
SwiftUI Preview Helpers for Most Edge Cases
View AllComponentPreviews.swift
/**
Copyright 2019 Kyle Sherman
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial
@drumnkyle
drumnkyle / allComponentPreviews.swift
Last active Feb 18, 2020
All Component Previews Example
View allComponentPreviews.swift
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
Group {
ContentView(title: "Short String")
ContentView(title: """
This is a super long title \
spread across a single line
""")
}.allComponentPreviews()
View multiplePreviews.swift
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
Group {
ContentView()
.environment(\.sizeCategory,
.accessibilityLarge)
ContentView()
.environment(\.sizeCategory,
.accessibilityExtraExtraLarge)
@drumnkyle
drumnkyle / simplePreview.swift
Created Jan 23, 2020
SwiftUI Previews for All Configurations
View simplePreview.swift
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
Group {
ContentView(title: "Small Title")
ContentView(title: "Longer Title to Make Sure It Works")
}
}
}
View cleanup_files.sh
#!/bin/bash
rm "compile_commands.json"
rm "xcodebuild.log"
@drumnkyle
drumnkyle / ButtonScrollPerformanceTest.m
Last active Feb 12, 2019
Full Scroll Performance Framework
View ButtonScrollPerformanceTest.m
/*
The MIT License
Copyright (c) 2010-2018 Google, Inc. http://angularjs.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@drumnkyle
drumnkyle / ButtonScrollPerformanceTest.m
Last active Aug 17, 2018
ButtonScrollPerformanceTest
View ButtonScrollPerformanceTest.m
#import <XCTest/XCTest.h>
#import <KIF/KIF.h>
#import "KSScrollPerformanceDetector.h"
#import "usage.h"
// This is specifically chosen to be the right speed to not trigger optimizations
static const CGFloat KSScrollPerformanceTestsVelocity = -0.15f;
@interface ButtonScrollPerformanceTests : KIFTestCase <KSScrollPerformanceDetectorDelegate>
@drumnkyle
drumnkyle / usage.h
Last active Aug 17, 2018
iOS Device Usage
View usage.h
#ifndef usage_h
#define usage_h
#import <mach/mach.h>
double cpu_usage(int64_t *count);
float mem_usage();
#endif /* usage_h */
@drumnkyle
drumnkyle / KSScrollPerformanceDetector.h
Last active Aug 17, 2018
KSScrollPerformanceDetector
View KSScrollPerformanceDetector.h
#import <Foundation/Foundation.h>
/**
These methods will not be called on the main thread. So,
if you will be doing anything with UIKit, ensure you dispatch back
to the main thread.
*/
@protocol KSScrollPerformanceDetectorDelegate<NSObject>
@optional
- (void)framesDropped:(NSInteger)framesDroppedCount cumulativeFramesDropped:(NSInteger)cumulativeFramesDropped cumulativeFrameDropEvents:(NSInteger)cumulativeFrameDropEvents;
@drumnkyle
drumnkyle / safeMutation.swift
Created Nov 30, 2016
Makes it so you can throw an error and revert any mutation changes in a struct
View safeMutation.swift
protocol SafeMutation {
mutating func safeMutate(_ work: () throws -> ()) rethrows
}
extension SafeMutation {
mutating func safeMutate(_ work: () throws -> ()) rethrows {
let old = self
do {
try work()
} catch {
You can’t perform that action at this time.