Skip to content

Instantly share code, notes, and snippets.

View TsRebornz's full-sized avatar

Anton Makarenkov TsRebornz

  • Yerevan
View GitHub Profile
@TsRebornz
TsRebornz / Using_NSURLSession.m
Created June 30, 2017 10:54
Using_NSURLSession.m
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0ul);
dispatch_async(queue, ^{
NSURL *url = [NSURL URLWithString: @"http://upload.wikimedia.org/wikipedia/commons/7/7f/Williams_River-27527.jpg"];
NSURLSessionDownloadTask *downloadPhotoTask = [[NSURLSession sharedSession]
downloadTaskWithURL:url completionHandler:^(NSURL *location, NSURLResponse *response, NSError *error) {
UIImage *downloadedImage = [UIImage imageWithData:
[NSData dataWithContentsOfURL:location]];
}];
[downloadPhotoTask resume];
});
@TsRebornz
TsRebornz / .swift
Created April 4, 2018 15:59
Set subraction
var localIdSet = Set<Int>()
var netIdSet = Set<Int>()
let idToDelete = localIdSet.subtracting(netIdSet)
var localIdSet = Set<Int>()
var netIdSet = Set<Int>()
let idToDelete = localIdSet.subtracting(netIdSet)
class Node {
var visited = false
var connections: [Connection] = []
}
class Connection {
public let to: Node
public let weight: Int
public init(to node: Node, weight: Int) {
@TsRebornz
TsRebornz / LeetCodeWithTestsExample.swift
Created March 27, 2019 11:21
LeetCode with tests example
//98. Validate Binary Search Tree
class TreeNode {
var val: Int
var left: TreeNode?
var right: TreeNode?
init(_ val: Int) {
self.val = val
self.left = nil
self.right = nil
}
@TsRebornz
TsRebornz / BackgroundTaskExample.m
Last active July 10, 2019 13:14
BackGroundTaskExample
- (void)applicationDidEnterBackground:(UIApplication *)application
{
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
NSLog(@"%s", __FUNCTION__);
__block UIBackgroundTaskIdentifier task = [application beginBackgroundTaskWithExpirationHandler:^{
NSLog(@"Expiration handler called %f",[application backgroundTimeRemaining]);
final class SharedTokenManager {
private let tokenKey = "token"
private let accessGroup: String
init(accessGroup: String) {
self.accessGroup = accessGroup
}
func getToken() -> String? {
@TsRebornz
TsRebornz / CircularProgressBarViewController.swift
Last active September 1, 2020 19:31
CircularProgressBarViewController
//
// CircularProgressBarViewController.swift
// iOS_CoreAnimation_Advanced_practice
//
// Created by Anton Makarenkov on 08/08/2020.
// Copyright © 2020 Anton Makarenkov. All rights reserved.
//
import UIKit
let basicAnimation = CABasicAnimation(keyPath: "bounds")
@TsRebornz
TsRebornz / Keypath_mapping.swift
Last active August 31, 2022 16:35
Keypath_mapping
let phones: [Phone] = [
.init(model: "Samsung A3", manufacturer: "Samsung"),
.init(model: "iPhone 13", manufacturer: "Apple")
]
let phoneModels = phones.map(\.model)