Skip to content

Instantly share code, notes, and snippets.

@parrots
parrots / ModernSegmentedControl.swift
Created June 28, 2019 16:00
A segmented control without the borders. Allows for a subtle background on the unselected states, and a tint on the selected state.
//
// ModernSegmentedControl.swift
//
//
// Created by Curtis Herbert on 3/8/18.
//
import Foundation
@objc final class ModernSegmentedControl: UIControl {
@parrots
parrots / AsyncOperation.swift
Last active May 17, 2021 10:44
A Swifty version of an AsyncOperation which solves two common problems I ran into. (see comment below for issues addressed)
//
// AsyncOperation.swift
// Slopes
//
import Foundation
class AsyncOperation: Operation {
private let stateLock = NSLock()
private var observers: [NSKeyValueObservation] = [NSKeyValueObservation]()

Keybase proof

I hereby claim:

  • I am parrots on github.
  • I am parrots (https://keybase.io/parrots) on keybase.
  • I have a public key whose fingerprint is 43FD FA59 6C6F 3419 9FC5 4702 9D99 E4DB 59AD B11F

To claim this, I am signing this object:

@parrots
parrots / CachingInterfaceController.h
Created April 14, 2015 02:32
CachingInterfaceController
@import WatchKit;
@interface CachingInterfaceController : WKInterfaceController
- (void)updateLabel:(WKInterfaceLabel *)label withString:(NSString *)string;
- (void)updateLabel:(WKInterfaceLabel *)label asHidden:(BOOL)hidden;
- (void)updateImage:(WKInterfaceImage *)image withImageNamed:(NSString *)imageName;
- (void)updateImage:(WKInterfaceImage *)image withBaseNameForAnimation:(NSString *)baseName withRange:(NSRange)range duration:(NSTimeInterval)duration repeatCount:(NSInteger)repeatCount;
- (NSString *)currentImageNameForImage:(WKInterfaceImage *)image;
@parrots
parrots / versioning.sh
Created April 9, 2015 01:28
Watchkit versioning build phase
git=`sh /etc/profile; which git`
branch_name=`$git symbolic-ref HEAD | sed -e 's,.*/\\(.*\\),\\1,'`
git_count=`$git rev-list $branch_name |wc -l | sed 's/^ *//;s/ *$//'`
simple_branch_name=`$git rev-parse --abbrev-ref HEAD`
build_number="$git_count"
if [ $CONFIGURATION != "Release" ]; then
build_number+="-$simple_branch_name"
fi
@parrots
parrots / CBCImageView
Created December 17, 2014 21:42
Work around IB_Designable bug with template images and Interface Builder
@import UIKit;
IB_DESIGNABLE @interface CBCImageView : UIImageView
@end
@implementation CBCImageView
- (void)awakeFromNib
{
@parrots
parrots / hack.sh
Last active January 23, 2019 14:23 — forked from DAddYE/hack.sh
OSX Defaults
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
#echo "Enable full keyboard access for all controls (e.g. enable Tab in modal dialogs)"
#defaults write NSGlobalDomain AppleKeyboardUIMode -int 3