Skip to content

Instantly share code, notes, and snippets.

@Le0nX
Le0nX / WeakReference.swift
Created February 20, 2020 12:31
Virtual proxy pattern
final class WeakReference<T: AnyObject> {
weak var ref: T?
init (_ object: T) {
self.ref = object
}
}
extension WeakReference: CurrencyPresenterOutput where T: CurrencyPresenterOutput {
func present(_ currency: CurrencyPresenterModel) {
@Le0nX
Le0nX / naive_solution.cpp
Created December 10, 2019 12:34
Наивное решение O(n^2)
#include <iostream>
/*
Вспомогательный метод. Проверяет содержит ли
число num в себе цифру k. Работает за O(n)
*/
bool contains(int num, int k) {
if (k > 9) {
return false;
}
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
ThemeManager.setup() // theme settings
import Foundation
import UIKit
//MARK: - RGB
/**
- Descriptioin:
RGB color settings
*/
extension UIColor {
static func RGB (_ red: CGFloat, _ green: CGFloat, _ blue: CGFloat) -> UIColor {
import Foundation
import UIKit
class ThemeManager {
// Some hack is needed in ios 13
// to make navigationBar color grey in largeTittle mode
static func setup() {
if #available(iOS 13.0, *) {
let navBarAppearance = UINavigationBarAppearance()
import Foundation
import UIKit
class HeadlinesVewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
setupUI()
}