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
rm "compile_commands.json"
rm "xcodebuild.log"
drumnkyle / ButtonScrollPerformanceTest.m
Last active Feb 12, 2019
Full Scroll Performance Framework
View ButtonScrollPerformanceTest.m
The MIT License
Copyright (c) 2010-2018 Google, Inc.
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 / ButtonScrollPerformanceTest.m
Last active Aug 17, 2018
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 / 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 / KSScrollPerformanceDetector.h
Last active Aug 17, 2018
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>
- (void)framesDropped:(NSInteger)framesDroppedCount cumulativeFramesDropped:(NSInteger)cumulativeFramesDropped cumulativeFrameDropEvents:(NSInteger)cumulativeFrameDropEvents;
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 {
drumnkyle / readableXIB-bookmarklet.js
Last active Nov 15, 2016
A helper that will take a XIB as a string and make it more human readable
View readableXIB-bookmarklet.js
var outletRegex = /<outlet property=\"(.*)\" destination=\"(.*)\" id=\".*\"\/>/g;
var xcodeIDRegex = /id=\"(.*)\".*userLabel=\"(.*)\"/g;
var customClass = /id=\"(.*)\".*customClass=\"(.*)\"/g;
var allDiffs = []"sidebyside"));
for (i = 0; i < allDiffs.length; i++) {
if (allDiffs[i].getElementsByClassName("filename-row")[0].textContent.includes(".xib")) {
var xibString = allDiffs[i].innerText;
var matches, output = [];
while (matches = outletRegex.exec(xibString)) {
drumnkyle / CropImageToCircle.swift
Last active Sep 24, 2017
Code to mask a square image to a circle
View CropImageToCircle.swift
// UIImage+Utils.swift
// This is just one way to do this.
public func croppedToCircle() -> UIImage {
// Begin a new image that will be the new image with the rounded corners
UIGraphicsBeginImageContextWithOptions(size, false, scale)
let circleWidth = size.width
let radius = circleWidth / 2
drumnkyle / swift2_error_handling_1.swift
Created Jun 15, 2015
Swift 2 Error Handling with asynchronous closures
View swift2_error_handling_1.swift
// Error Handling //
enum Either<T> {
case Success(T)
case Failure(ErrorType)
func getValue() throws -> T {
switch self {
case .Success(let value):
drumnkyle / single_line_closure.swift
Last active Aug 29, 2015
Single Line Closure Problem in Swift
View single_line_closure.swift
dispatch_async(dispatch_get_main_queue()) {
return // This is needed for it to compile
You can’t perform that action at this time.