Skip to content

Instantly share code, notes, and snippets.

View OleksiiShvachenko's full-sized avatar

Oleksii Shvachenko OleksiiShvachenko

  • Readdle
  • Kharkiv
View GitHub Profile
@OleksiiShvachenko
OleksiiShvachenko / FontManager.swift
Created March 18, 2019 09:51
Font manager for fonts generated by SwiftGen
import UIKit
enum FontStyle {
case largeTitle
case headline
case title2
case title3
case subheadline
case body
case callout
let volumeController = MPVolumeView()
// to change volume we need to get slider and set it value
let volumeSlider = volumeController.subviews.first as? UISlider
volumeSlider?.value = newVolume
open class Pet: Codable {
public enum Status: String, Codable {
case available = "available"
case pending = "pending"
case sold = "sold"
}
public var id: Int64?
public var category: Category?
public var name: String
final class LinkLabel: UILabel {
private var layoutManager: NSLayoutManager?
private var textContainer: NSTextContainer?
private var textStorage: NSTextStorage?
var tapOnLink: (() -> Void)?
override init(frame: CGRect) {
super.init(frame: frame)
setupView()
@OleksiiShvachenko
OleksiiShvachenko / AutoLocalize.swift
Created November 2, 2017 14:41
AutoLocalize for stroryboards and xibs.
import UIKit
private func AutoLocalize(_ string: String?) -> String? {
guard let string = string else {
return nil
}
if string.hasPrefix("%") {
return NSLocalizedString(string, comment: "")
}
return string
public class DropboxDestination: BaseDestination {
private let client: DropboxClient
public init(accessToken: String) {
client = DropboxClient(accessToken: accessToken)
}
override public func send(_ level: SwiftyBeaver.Level, msg: String,
thread: String, file: String, function: String,
line: Int, context: Any?) -> String? {
let str = super.send(level, msg: msg, thread: thread,
class AutolayoutTextView: UITextView {
override func layoutSubviews() {
super.layoutSubviews()
if bounds.size != intrinsicContentSize {
invalidateIntrinsicContentSize()
}
}
import RealmSwift
import ObjectMapper
import Alamofire
enum CRUDState: Int {
case normal = 0
case update = 1
}
class Reminder: Object, Mappable, NSCopying {
static func Medication(_ typeID: Int) -> String {
switch typeID {
case 1...5: return "aerosol"
case 6: return "bar_chewable"
case 7...15: return "pellet"
case 16: return "cloth"
case 17: return "concentrate"
case 18...19: return "cream"
case 20: return "krystal"
case 21: return "disk"
const char* cKey = [password cStringUsingEncoding:NSUTF8StringEncoding];
const char* cData = [url cStringUsingEncoding:NSUTF8StringEncoding];
unsigned char cHMAC[CC_SHA256_DIGEST_LENGTH];
CCHmac(kCCHmacAlgSHA256, cKey, strlen(cKey), cData, strlen(cData), cHMAC);
NSData* data = [NSData dataWithBytes:cHMAC length:sizeof(cHMAC)];
NSString* signature = [data base64String];
return [NSString stringWithFormat:@"%@:%@", username, signature];