Skip to content

Instantly share code, notes, and snippets.

Artem Sherbachuk artem-sherbachuk

Block or report user

Report or block artem-sherbachuk

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@artem-sherbachuk
artem-sherbachuk / MeasureCode.swift
Created Jan 19, 2017
measure code execution time with block.
View MeasureCode.swift
func measure(title: String, block: (() -> ()) -> ()) {
let startTime = CFAbsoluteTimeGetCurrent()
block {
let timeElapsed = CFAbsoluteTimeGetCurrent() - startTime
println("\(title):: Time: \(timeElapsed)")
}
}
@artem-sherbachuk
artem-sherbachuk / FadingInOutAVPlayer.swift
Created Jan 19, 2017
Fading audio in and out AVPlayer
View FadingInOutAVPlayer.swift
let player = AVPlayer()
func playFileAtURL(url: NSURL) {
let asset = AVAsset.assetWithURL(url) as AVAsset
let duration = asset.duration
let durationInSeconds = CMTimeGetSeconds(duration)
let item = AVPlayerItem(asset: asset)
let params = AVMutableAudioMixInputParameters(track: asset.tracks.first! as AVAssetTrack)
@artem-sherbachuk
artem-sherbachuk / xcodebuild_profiling_func_swift.sh
Created Nov 15, 2016
Profiling compilation time of most expensivest func in swift
View xcodebuild_profiling_func_swift.sh
# Clean and build, capturing only lines containing `X.Yms` where X > 0, sorting from largest to smallest
# http://irace.me/swift-profiling
xcodebuild -workspace App.xcworkspace -scheme App clean build | grep [1-9].[0-9]ms | sort -nr > culprits.txt
View Custom HTTP Headers with Swift 3.0 and Alamofire 4.0.swift
// MARK: - Adding a header to a single request
let headers: HTTPHeaders = [
"X-Mashape-Key": MY_API_KEY,
"Accept": "application/json"
]
Alamofire.request("https://mashape-community-urban-dictionary.p.mashape.com/define?term=smh", headers: headers)
.responseJSON { response in
debugPrint(response)
You can’t perform that action at this time.