Skip to content

Instantly share code, notes, and snippets.

View bugrym's full-sized avatar
🥋
Focusing

Vladyslav bugrym

🥋
Focusing
  • Ukraine
View GitHub Profile
@bugrym
bugrym / leetCode
Created February 20, 2020 15:55
771. Jewels and Stones
func numJewelsInStones(_ J: String, _ S: String) -> Int {
var counter = 0
let stones = Array(S)
let jewels = Array(J)
for i in 0..<stones.count {
for j in 0..<jewels.count {
let lhs = stones[i]
let rhs = jewels[j]
@bugrym
bugrym / UIImageView extension
Created February 18, 2020 12:45
UIImageView with a convenience initializer that allows us to include the insets
extension UIImageView {
convenience init(named name: String, top: CGFloat, left:
CGFloat, bottom: CGFloat, right: CGFloat) {
let insets = UIEdgeInsetsMake(top, left, bottom, right) let originalImage = UIImage(named: name)
let insetImage = originalImage?.withAlignmentRectInsets(insets) self.init(image: insetImage)
}
}
//
// PaneViewController.swift
// PaneApp
//
// Created by Vladyslav Bugrym on 18.02.2020.
// Copyright © 2020 admin. All rights reserved.
//
import UIKit
@bugrym
bugrym / Keyboard_handler
Created November 18, 2019 11:38
Keyboard handler
@objc func adjustForKeyboard(notification: Notification) {
guard let keyboardValue = notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue else { return }
let keyboardScreenEndFrame = keyboardValue.cgRectValue
let keyboardViewEndFrame = view.convert(keyboardScreenEndFrame, from: view.window)
if notification.name == UIResponder.keyboardWillHideNotification {
scrollView.contentInset.bottom = self.logInButton.frame.height
} else {
private func buildTree(allProducts:[Product], handler: @escaping(()->Void)) {
let group = DispatchGroup()
let asyncQueue = DispatchQueue(label: "com.shop.tree.build.queue", qos: .utility, attributes: .concurrent, autoreleaseFrequency: .inherit, target: nil)
var byCategory:[ProductSection] = []
group.enter()
asyncQueue.async {
for product in allProducts {
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
var coreDataStack = CoreDataStack()
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let navigationController = window?.rootViewController as! UINavigationController
import Foundation
import CoreData
class CoreDataStack {
// MARK: - Core Data stack
lazy var persistentContainer: NSPersistentContainer = {
/*
The persistent container for the application. This implementation
creates and returns a container, having loaded the store for the