Skip to content

Instantly share code, notes, and snippets.

View GregoryMaks's full-sized avatar

Gregory Maksiuk GregoryMaks

View GitHub Profile
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
@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;
+ (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) ? @"[email protected]" : nil;