Skip to content

Instantly share code, notes, and snippets.

View maciejpiotrowski89's full-sized avatar
πŸ‘¨β€πŸ’»

Maciej Piotrowski maciejpiotrowski89

πŸ‘¨β€πŸ’»
View GitHub Profile
- (void)applicationDidEnterBackground:(UIApplication *)application {
@weakify(self);
self.backgroundTaskIdentifier = [application beginBackgroundTaskWithExpirationHandler:^{
@strongify(self);
[application endBackgroundTask:self.backgroundTaskIdentifier];
self.backgroundTaskIdentifier = UIBackgroundTaskInvalid;
}];
}
- (void)testApplicationDidEnterBackgroundExpirationHandler {
@maciejpiotrowski89
maciejpiotrowski89 / iterm2-solarized.md
Created November 27, 2017 10:15 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Meslo powerline font + [Powerlevel9k] - (macOS)

Default

Default

Powerlevel9k

Powerlevel9k

import Foundation
func machToNanoseconds(_ mach: UInt64) -> Double {
struct Static {
static var info: mach_timebase_info = {
var info = mach_timebase_info()
mach_timebase_info(&info)
return info
}()
}
extension Optional {
// `then` function executes the closure if there is some value
func then(_ handler: (Wrapped) -> Void) {
switch self {
case .some(let wrapped): return handler(wrapped)
case .none: break
}
}
}
//
// WatchSessionManager.swift
// WatchConnectivityDemo
//
// Created by Natasha Murashev on 9/3/15.
// Copyright Β© 2015 NatashaTheRobot. All rights reserved.
//
import WatchConnectivity
@maciejpiotrowski89
maciejpiotrowski89 / dispatch_once.swift
Last active March 11, 2016 15:10 — forked from kristopherjohnson/dispatch_once.swift
Example of using dispatch_once() in Swift
import Foundation
func bindData() {
struct Static {
static var token: dispatch_once_t = 0
}
dispatch_once(&Static.token) {
self.title = self.viewModel.title
self.navigationItem.title = self.viewModel.title
self.viewModel.viewPresenter = self