Skip to content

Instantly share code, notes, and snippets.

View GregoryMaks's full-sized avatar

Gregory Maksiuk GregoryMaks

View GitHub Profile
+ (UIImage *)launchImageWithPrefix:(NSString *)prefix interfaceOrientation:(UIInterfaceOrientation)orientation
{
NSString *imageName = nil;
// TODO.GregoryM: fillup rest of image names and check in different cases
CGFloat mainScreenHeight = CGRectGetHeight([UIScreen mainScreen].bounds);
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
if (mainScreenHeight == 568) {
imageName = UIInterfaceOrientationIsPortrait(orientation) ? @"-700-568h@2x.png" : nil;
@GregoryMaks
GregoryMaks / Maybe.h
Created July 28, 2016 20:58 — forked from samwgoldman/Maybe.h
Maybe monad-alike in Objective-C using parts of ReactiveCocoa and libextobjc concrete protocols
#import <Foundation/Foundation.h>
#import <libextobjc/EXTConcreteProtocol.h>
@protocol Maybe <NSObject>
- (id<Maybe>)map:(id (^)(id value))block;
- (id<Maybe>)flattenMap:(id<Maybe> (^)(id value))block;
- (id<Maybe>)orElse:(id)defaultValue;
- (id)getOrElse:(id)defaultValue;

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
// ***
// 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) }
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)
)
}
}
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
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,
@GregoryMaks
GregoryMaks / used-macbook-cheatsheet.md
Last active October 19, 2023 10:11
Buying used Macbook?
@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