Skip to content

Instantly share code, notes, and snippets.

View Otbivnoe's full-sized avatar

Nikita Ermolenko Otbivnoe

View GitHub Profile
@joeymeyer
joeymeyer / ns_extension_unavailable.txt
Created July 23, 2014 16:17
NS_EXTENSION_UNAVAILABLE
./EventKitUI.framework/Headers/EKCalendarChooser.h:NS_EXTENSION_UNAVAILABLE_IOS("EventKitUI is not supported in extensions")
./EventKitUI.framework/Headers/EKEventEditViewController.h:NS_EXTENSION_UNAVAILABLE_IOS("EventKitUI is not supported in extensions")
./EventKitUI.framework/Headers/EKEventViewController.h:NS_EXTENSION_UNAVAILABLE_IOS("EventKitUI is not supported in extensions")
./Foundation.framework/Headers/NSObjCRuntime.h:#define NS_EXTENSION_UNAVAILABLE(_msg) __OS_EXTENSION_UNAVAILABLE(_msg)
./Foundation.framework/Headers/NSObjCRuntime.h:#define NS_EXTENSION_UNAVAILABLE_MAC(_msg) __OSX_EXTENSION_UNAVAILABLE(_msg)
./Foundation.framework/Headers/NSObjCRuntime.h:#define NS_EXTENSION_UNAVAILABLE_IOS(_msg) __IOS_EXTENSION_UNAVAILABLE(_msg)
./UIKit.framework/Headers/UIActionSheet.h:- (instancetype)initWithTitle:(NSString *)title delegate:(id<UIActionSheetDelegate>)delegate cancelButtonTitle:(NSString *)cancelButtonTitle destructiveButtonTitle:(NSString *)destructiveButtonTitle otherButtonTitles:(NSS
@nlutsenko
nlutsenko / yolo.sh
Last active July 22, 2024 05:12
Fast Xcode builds
defaults write xcodebuild PBXNumberOfParallelBuildSubtasks 4
defaults write xcodebuild IDEBuildOperationMaxNumberOfConcurrentCompileTasks 4
defaults write com.apple.xcode PBXNumberOfParallelBuildSubtasks 4
defaults write com.apple.xcode IDEBuildOperationMaxNumberOfConcurrentCompileTasks 4
@lopspower
lopspower / README.md
Last active July 26, 2024 10:57
Hexadecimal color code for transparency

Hexadecimal color code for transparency

Twitter

How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

Download This sample on Google Play Store

import UIKit
// Swift rewrite challenge
// Starting point: https://gist.github.com/jkereako/200342b66b5416fd715a#file-scale-and-crop-image-swift
func scaleAndCropImage(
image: UIImage,
toSize size: CGSize,
fitImage: Bool = true
) -> UIImage {
@dangthaison91
dangthaison91 / then.swift
Last active December 30, 2018 09:36
RxSwift - Then
@jamiepinkham
public extension ObservableType {
func then(closure: () -> Observable<E>?) -> Observable<E> {
return then(closure() ?? .empty())
}
func then(@autoclosure(escaping) closure: () -> Observable<E>) -> Observable<E> {
let next = Observable.deferred {
@artemnovichkov
artemnovichkov / UIView+Presentation.swift
Last active February 11, 2017 07:31
Extension for rounded corners in UIView. Warning: make sure that your UIView already has correct frame.
import UIKit
extension UIView {
func round(with radius: CGFloat, corners: UIRectCorner) {
let roundedPath = UIBezierPath(roundedRect: bounds,
byRoundingCorners: corners,
cornerRadii: CGSize(width: radius, height: radius))
let maskLayer = CAShapeLayer()
maskLayer.path = roundedPath.cgPath
@sooop
sooop / StreamReader.swift
Last active June 23, 2024 22:49
Read a large text file line by line - Swift 3
import Foundation
class StreamReader {
let encoding: String.Encoding
let chunkSize: Int
let fileHandle: FileHandle
var buffer: Data
let delimPattern : Data
var isAtEOF: Bool = false
@artemnovichkov
artemnovichkov / ServicesComposition.swift
Last active May 4, 2018 07:17
Using protocol composition and generics for dependency injection in Interactors (VIPER, SOA, another cool keywords...)
//Inspired by: http://merowing.info/2017/04/using-protocol-compositon-for-dependency-injection/
//Protocols for objects owning services. Interactors in VIPER, for example.
protocol HasLogService {
var logService: LogService { get }
}
protocol HasLoginService {
var loginService: LoginService { get }
}
@artemnovichkov
artemnovichkov / Optional+Operators.swift
Last active July 30, 2018 15:16
Addition and subtraction operators for Swift Optionals
func +=<T>(lhs: inout T?, rhs: T) where T: SignedNumeric {
switch lhs {
case .none:
break
case .some(let value):
lhs = .some(value + rhs)
}
}
func -=<T>(lhs: inout T?, rhs: T) where T: SignedNumeric {
@lsavino
lsavino / compilation-optimization.md
Last active July 27, 2022 17:44
Compiler Optimizations, Compiling Optimally, and Whole Modules

DEPRECATED for Xcode 10 🎈

(check out What's New in Swift at 11:40, slide 42)

Whole Module Compilation Optimizations: Why these terms are sometimes misleading

When you look up how to compile swift faster for debug builds, people very earnestly give advice that seems contradictory: you should "try using the whole module optimization flag," and also "never use whole module optimization for debugging". [^1]

This is confusing because some of us are using these two general words:

compilation: "turning text into an executable program"