Skip to content

Instantly share code, notes, and snippets.

View GregoryMaks's full-sized avatar

Gregory Maksiuk GregoryMaks

View GitHub Profile
@GregoryMaks
GregoryMaks / RunningApplicationsObserver.swift
Created August 1, 2023 10:32
Observes current running applications through `NSWorkspace` and notifies if any of the requested applications change their running status
import AppKit
import Combine
import CombineExt
import Foundation
import SharedUtils
// sourcery: Automockable
protocol RunningApplicationsObserverType {
func observeApplicationsRunningStatus(bundleIdentifiers: [String]) -> AnyPublisher<Void, Never>
}
@GregoryMaks
GregoryMaks / fileExtensionsForUTType.swift
Created February 16, 2022 17:29
File extensions for specified UTType and all its descenders
import UniformTypeIdentifiers
let allTypes: [UTType] = [
.item,
.content,
.compositeContent,
.diskImage,
.data,
.directory,
@GregoryMaks
GregoryMaks / enable-xcode-debug-menu.sh
Created February 23, 2020 13:05 — forked from dsabanin/enable-xcode-debug-menu.sh
Enable internal Xcode debug menu in Xcode 11
defaults write com.apple.dt.Xcode ShowDVTDebugMenu -bool YES
sudo mkdir -p /Applications/Xcode.app/Contents/Developer/AppleInternal/Library/Xcode
sudo touch /Applications/Xcode.app/Contents/Developer/AppleInternal/Library/Xcode/AppleInternal.plist
# Don't forget to restart Xcode
@GregoryMaks
GregoryMaks / used-macbook-cheatsheet.md
Last active October 19, 2023 10:11
Buying used Macbook?
static func from(serverModel: DoctorCustomRulesServerModel) -> Rules? {
guard let motherRule = serverModel.rules.first(where: { $0.subjectType == .mHR }),
let fetusRule = serverModel.rules.first(where: { $0.subjectType == .fHR })
else {
return nil
}
return Rules(
fetalNormalRangeMin: fetusRule.normalCurrentRangeFrom,
fetalNormalRangeMax: fetusRule.normalCurrentRangeTo,
static func from(serverModel: DoctorCustomRulesServerModel) -> Rules? {
guard let motherRule = serverModel.rules.first(where: { $0.subjectType == .mHR }),
let fetusRule = serverModel.rules.first(where: { $0.subjectType == .fHR })
else {
return nil
}
return Rules(
fetalNormalRangeMin: fetusRule.normalCurrentRangeFrom,
fetalNormalRangeMax: fetusRule.normalCurrentRangeTo,
func currenthWiFiSSIDInfo() -> String? {
if let interfaces = CNCopySupportedInterfaces() {
for i in 0..<CFArrayGetCount(interfaces){
let interfaceName: UnsafeRawPointer = CFArrayGetValueAtIndex(interfaces, i)
let rec = unsafeBitCast(interfaceName, to: AnyObject.self)
let unsafeInterfaceData = CNCopyCurrentNetworkInfo("\(rec)" as CFString)
if let unsafeInterfaceData = unsafeInterfaceData as? Dictionary<AnyHashable, Any> {
logger(unsafeInterfaceData["SSIDDATA"].debugDescription)
return unsafeInterfaceData["SSID"] as? String
func requestTopPosts(completion: @escaping (Result<RedditListingResult<RedditPostServerModel>, RedditError>) -> Void) {
let request = URLRequest(url: Constants.topPostsAbsoluteURL)
networkService.perform(request: request) {
completion(
$0.flatMap(ifSuccess: self.verifyServerResponse, ifFailure: self.networkErrorToResult)
.flatMap(ifSuccess: self.parsePostModels, ifFailure: liftError)
)
}
}
// ***
// Option 1 (functional approach, minimum variables)
// ***
let pagingTuple: (String?, String?) = try zip(
dataNode.validatedOptionalValue(forKey: "after"),
dataNode.validatedOptionalValue(forKey: "before")
)
let pagingMarker = unwrap(pagingTuple)
.flatMap { RedditListingResult<ServerModel>.PagingMarker(before: $0.0, after: $0.1) }

Test task

Description

github.com has public API to get list of users: "https://api.github.com/users". There are helpfull parameters like "per_page" and "since", check them. You need to create iOS application that displays list of github users loaded into table. Each row should contain login, profile link (html_url) and avatar preview(100x100). Tap on user should result in opening list of his followers.

Requirements

  • application should be written in Swift (Swift 3.0 is preferred, but 2.3 will do just fine)
  • source code should be available on github.com