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
node{ | |
timestamps{ | |
stage('Samples'){ | |
// Single quotes with no interpolation, at least not in Jenkins. | |
// The dollar variable will be evaluated before being run by the | |
// shell command, so variables which Jenkins makes available as | |
// environment variables can still be accessed from within a | |
// single-quoted string, passed to the sh task. | |
sh 'echo $PATH' |
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
let start = CFAbsoluteTimeGetCurrent() | |
// run your work | |
let diff = CFAbsoluteTimeGetCurrent() - start | |
print("Took \(diff) seconds") |
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
@discardableResult | |
func measure<A>(name: String = "", _ block: () -> A) -> A { | |
let startTime = CACurrentMediaTime() | |
let result = block() | |
let timeElapsed = CACurrentMediaTime() - startTime | |
print("Time: \(name) - \(timeElapsed)") | |
return result | |
} |
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]; |
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
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
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
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
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
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 | |
} |
NewerOlder