Skip to content

Instantly share code, notes, and snippets.

View ahmattox's full-sized avatar
🍤

Anthony Mattox ahmattox

🍤
View GitHub Profile

Keybase proof

I hereby claim:

  • I am ahmattox on github.
  • I am anthonymattox (https://keybase.io/anthonymattox) on keybase.
  • I have a public key ASDnimJTesfRDN3xLlOqPK5HHKrY7eERguHRFkahNOmV-Ao

To claim this, I am signing this object:

extension UITableView {
func animateSection<Element: Equatable>(section: Int, from:[Element], to: [Element], rowAnimation: UITableViewRowAnimation = .Top) {
assert(from.containsUniqueElements() && to.containsUniqueElements(), "\(#function) can only be used if all elements in the collection are unique.")
func path(index: Int) -> NSIndexPath {
return NSIndexPath(forRow: index, inSection: section)
}
// Find indexes in the old array that should be deleted
// Resizes an image file to necessary sizes for iOS application icons.
// Accepts the path to the file to be resized, e.g. `swift icons.swift icon.png`
// Created by Anthony Mattox on 2016-02-11
import Cocoa
extension NSImage {
func resize(size: CGSize) -> NSImage {
let cgImage = self.CGImageForProposedRect(nil, context: nil, hints: nil)
function dsp(t) {
// return sinOsc(t, 220, .5);
return .3 * saw(t, 220, 4, .5) + saw(t, 221, 4, .5);
// return 0.1 * Math.sin(2 * Math.PI * t * 440);
}
@ahmattox
ahmattox / ResizeScrollViewWithKeyboard.m
Last active December 19, 2015 01:08
Resize a UIScrollview when the keyboard is shown based on the overlap between the scroll view and keyboard frame
- (void) keyboardWillChangeFrame:(NSNotification *)notification {
CGRect originalKeyboardFrame = [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
CGRect keyboardFrame = [[[UIApplication sharedApplication] keyWindow] convertRect:originalKeyboardFrame toView:self];
CGFloat keyboardHeight = CGRectIntersection(keyboardFrame, self.contentScrollView.frame).size.height;
[UIView animateWithDuration:[notification.userInfo[UIKeyboardAnimationDurationUserInfoKey] floatValue] delay:0 options:[notification.userInfo[UIKeyboardAnimationCurveUserInfoKey] integerValue] animations:^{
self.contentScrollView.scrollIndicatorInsets = UIEdgeInsetsMake(0, 0, keyboardHeight, 0);
self.contentScrollView.contentInset = UIEdgeInsetsMake(0, 0, keyboardHeight, 0);
} completion:nil];
}
@ahmattox
ahmattox / MainStoryboard.storyboard
Created March 24, 2013 19:07
UITableView Sorting with Animations
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="2.0" toolsVersion="3084" systemVersion="12C60" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" initialViewController="2">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="2083"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="5">
<objects>
<viewController id="2" customClass="TTViewController" sceneMemberID="viewController">
@ahmattox
ahmattox / FTWDropCapTextView.h
Last active September 16, 2016 16:36
Text View with Drop Caps UIView subclass which renders text using core text with an enlarged, floating first character.
//
// FTWDropCapTextView.h
//
// Created by Anthony Mattox on 1/22/13.
// Copyright (c) 2013 Friends of The Web. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface FTWDropCapTextView : UIView
@ahmattox
ahmattox / UITextField+SelectionRanges.h
Created January 5, 2013 19:35
UITextField category to handle selections with NSRanges. Adds methods to get an NSRange representing the current selection and to select a range of characters with an NSRange.
//
// UITextField+SelectionRanges.h
// Kitchen Unit Converter
//
// Created by Anthony Mattox on 1/5/13.
// Copyright (c) 2013 Friends of The Web. All rights reserved.
//
#import <UIKit/UIKit.h>
@ahmattox
ahmattox / ListFonts.m
Created October 30, 2012 15:56
List all fonts and styles available on an iOS device.
- (void) listFonts {
NSArray *familyNames = [UIFont familyNames];
for (NSString *family in familyNames) {
NSLog(@"family: %@", family);
NSArray *styles = [UIFont fontNamesForFamilyName:family];
for (NSString *style in styles) {
NSLog(@" - %@", style);
}
}
}
@ahmattox
ahmattox / UIColor+Additions.h
Created September 28, 2012 14:42
UIColor Additions
//
// UIColor+Additions.h
//
// Created by Anthony Mattox on 9/28/12.
// Copyright (c) 2012 Friends of The Web. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UIColor (Additions)