This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSString *testedString; | |
__block NSString *selected; | |
((void (^)())@{ | |
@"A" : ^{ | |
selected = @"A selected"; | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (UIImage *)snapshot:(UIView *)view | |
{ | |
UIGraphicsBeginImageContextWithOptions(view.bounds.size, YES, 0); | |
[view drawViewHierarchyInRect:view.bounds afterScreenUpdates:YES]; | |
UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); | |
return image; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo -H -u www-data git status |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func roundImage(image: Image) -> Image? { | |
let rect = CGRect(origin:CGPoint(x: 0, y: 0), size: image.size) | |
UIGraphicsBeginImageContextWithOptions(image.size, false, 0.0) | |
UIBezierPath(roundedRect: rect, cornerRadius: self.cornerRadius).addClip() | |
image.draw(in: rect) | |
let roundedImage = UIGraphicsGetImageFromCurrentImageContext() | |
UIGraphicsEndImageContext() | |
return roundedImage | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
typealias GradientPoints = (startPoint: CGPoint, endPoint: CGPoint) | |
enum GradientOrientation { | |
case horizontal | |
case vertical | |
var startPoint: CGPoint { | |
return points.startPoint |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
extension UIColor { | |
convenience init(hex: Int, alpha: CGFloat = 1.0) { | |
self.init( | |
red: CGFloat((hex >> 16) & 0xFF) / 255.0, | |
green: CGFloat((hex >> 8) & 0xFF) / 255.0, | |
blue: CGFloat(hex & 0xFF) / 255.0, | |
alpha: alpha |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func fixPerformance() { | |
if (self.cornerRadius > 0) { | |
self.masksToBounds = false | |
self.shouldRasterize = true | |
self.rasterizationScale = UIScreen.main.scale | |
} | |
if (self.shadowRadius > 0) { | |
self.shadowPath = UIBezierPath(roundedRect: self.bounds, cornerRadius: self.cornerRadius).cgPath | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension CGPath { | |
func forEach( body: @convention(block) (CGPathElement) -> Void) { | |
typealias Body = @convention(block) (CGPathElement) -> Void | |
let callback: @convention(c) (UnsafeMutableRawPointer, UnsafePointer<CGPathElement>) -> Void = { (info, element) in | |
let body = unsafeBitCast(info, to: Body.self) | |
body(element.pointee) | |
} | |
print(MemoryLayout.size(ofValue: body)) | |
let unsafeBody = unsafeBitCast(body, to: UnsafeMutableRawPointer.self) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CFNETWORK_DIAGNOSTICS 3 | |
OS_ACTIVITY_MODE disable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UIBezierPath * imgRect = [UIBezierPath bezierPathWithRect:CGRectMake(0, 0, 100, 100)]; | |
self.textView.textContainer.exclusionPaths = @[imgRect]; |
OlderNewer