Skip to content

Instantly share code, notes, and snippets.

View jmbeck's full-sized avatar

John Beck jmbeck

  • San Francisco, CA
View GitHub Profile
@sxcore
sxcore / UIImage+Rotation.swift
Last active March 21, 2018 19:00 — forked from ffried/UIImage+Rotation.swift
Swift 4.0 updated version, without "bangs" and with proper variable naming.
extension UIImage {
func rotate(degrees: CGFloat) -> UIImage? {
let degreesToRadians: (CGFloat) -> CGFloat = {
return $0 / 180.0 * .pi
}
let rotatedViewBox = UIView(frame: CGRect(origin: CGPoint(x:0, y:0), size: size))
let transformation = CGAffineTransform(rotationAngle: degreesToRadians(degrees))
@NatashaTheRobot
NatashaTheRobot / WatchConnectivitySingletonDemo.swift
Last active May 21, 2024 18:21
WatchConnectivity Singleton Demo
//
// WatchSessionManager.swift
// WatchConnectivityDemo
//
// Created by Natasha Murashev on 9/3/15.
// Copyright © 2015 NatashaTheRobot. All rights reserved.
//
import WatchConnectivity
@brentsimmons
brentsimmons / gist:5810992
Last active January 3, 2021 02:22
Detect a tap on a URL inside a UITextView. Note: the rs_links method isn't included -- you'll need something that takes text and returns an array of detected links. This gist just demonstrates walking through the UITextView characters.
@implementation UITextView (RSExtras)
static BOOL stringCharacterIsAllowedAsPartOfLink(NSString *s) {
/*[s length] is assumed to be 0 or 1. s may be nil.
Totally not a strict check.*/
if (s == nil || [s length] < 1)
return NO;