Skip to content

Instantly share code, notes, and snippets.

@jonathan-beebe
jonathan-beebe / alasset_to_phasset.swift
Created July 18, 2015 16:26
Convert ALAsset to iOS8+ PHAsset
import Photos
import AVFoundation
func ALAssetToPHAsset(asset:ALAsset) -> PHAsset {
var fetchOptions: PHFetchOptions = PHFetchOptions()
var url:NSURL = asset.valueForProperty(ALAssetPropertyAssetURL) as! NSURL
let fetchResult:PHFetchResult = PHAsset.fetchAssetsWithALAssetURLs([url], options: fetchOptions)
return fetchResult.firstObject as! PHAsset
}
@jonathan-beebe
jonathan-beebe / clean_old_code_simulators.sh
Last active February 12, 2019 19:40
Clean out unused Xcode Simulators
# Close Xcode & the iOS Simulator
# http://stackoverflow.com/a/30940055
# Remove any old runtimes from this directory.
cd /Library/Developer/CoreSimulator/Profiles/Runtimes
# e.g.
sudo rm -rf iOS\ 8.1.simruntime
# http://stackoverflow.com/a/11790983
# Remove the download receipts for simulators you don't need anymore.
@jonathan-beebe
jonathan-beebe / fix_alcatraz_plugins.sh
Last active December 9, 2015 18:36
Fixing Alcatraz after upgrading Xcode
# Upgrading Xcode can wreak havok on your custom Alcatraz setup.
# Each plugin must list the UUIDs of Xcode that it supports. Thus
# with each new release we must update the list of UUIDs for each
# plugin we want to continue using.
#
# You can discover the UUID of an Xcode app bundle by running this command
defaults read /Applications/Xcode.app/Contents/Info DVTPlugInCompatibilityUUID
# > 7FDF5C7A-131F-4ABB-9EDC-8C5F8F0B8A90
@jonathan-beebe
jonathan-beebe / debug_functions.h
Created July 6, 2015 18:46
Log all fonts & colors of view
void logFonts(UIView* view);
void logColors(UIView* view);
@jonathan-beebe
jonathan-beebe / UIVIew+Layout Example.m
Last active August 29, 2015 14:23
A set of NSArray category methods (for arrays of UIViews) to automatically layout auto-hugging rows or columns. Requires PureLayout.
// Example — say you had some content for a scrollView.
// Create a contentView and add each row as a subview.
// Then simply call the category method on the subviews array to layout
// the subviews as rows.
//
// This requires that the contentView be setup via autolayout to
// properly pin to the scrollView.
[contentView addSubviews:@[
viewA,
@jonathan-beebe
jonathan-beebe / TableViewCellWithAutoLayout.m
Created January 8, 2015 20:46
Using UITableViewCell with dynamic height & autolayout
// https://github.com/smileyborg/TableViewCellWithAutoLayout/blob/master/TableViewCellWithAutoLayout/TableViewController/RJTableViewController.m
// http://stackoverflow.com/a/18746930/123781
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
// This project has only one cell identifier, but if you are have more than one, this is the time
// to figure out which reuse identifier should be used for the cell at this index path.
NSString *reuseIdentifier = CellIdentifier;
// Use the dictionary of offscreen cells to get a cell for the reuse identifier, creating a cell and storing
@jonathan-beebe
jonathan-beebe / UIView+FindSubview.h
Created October 8, 2014 18:57
Helpful category for finding a subview during a gesture
#import <UIKit/UIKit.h>
typedef BOOL (^TestViewCallback)(UIView*);
@interface UIView (FindSubview)
- (UIView*) findSubviewWithTest:(TestViewCallback)callback;
- (BOOL) hitByGesture:(UIGestureRecognizer*)recognizer;
@end
@jonathan-beebe
jonathan-beebe / UIImage+NegativeImage.h
Created October 8, 2014 18:55
UIImage category for inverting the image
// Retina-ready version of this StackOverflow answer
// http://stackoverflow.com/a/6672628/123781
#import <UIKit/UIKit.h>
@interface UIImage (NegativeImage)
- (UIImage *)negativeImage;
@end
@jonathan-beebe
jonathan-beebe / SassMeister-input.scss
Created August 7, 2014 12:46
Generated by SassMeister.com.
// ----
// Sass (v3.3.14)
// Compass (v1.0.0.rc.1)
// ----
//
// Code from http://thesassway.com/intermediate/a-standard-module-definition-for-sass
//
// # Thoughts
//
@jonathan-beebe
jonathan-beebe / SassMeister-input.scss
Created August 6, 2014 13:24
Generated by SassMeister.com.
// ----
// Sass (v3.3.14)
// Compass (v1.0.0.rc.1)
// ----
$text-base: (
font-size: 1.0rem,
line-height: 1.8rem,
font-weight: normal,
text-color: #333