I love New York, but one day I will move here!

The Code Times

Clone Undirected Graph with Javascript

A question that I got asked on the interview at Facebook on 2016 that I wasn’t able to finish coding within interview time frame. Finally got a chance to put it into code.

I used a LeetCode as a JS platform to test a code: https://leetcode.com/problems/clone-graph/description/

Find a second largest number in array with Javascript

Back to the simple coding questions. This time with javascript – it seems the easiest language to test with.
Code for the problem can be run over here: http://js.do/code/svetliy-second-largest

Finding a next lucky number with C++.

This is an easy task for Monday from Week of Code at Hackerrank.

The task is to find a next lucky number based on given 6 digit integer.

Missing Numbers Hackerrank problem with C++

https://www.hackerrank.com/challenges/missing-numbers/problem

Solved using sorting two arrays, finding missing number in the loop and putting them in the set.

Insert a node into Linked list with C++

Check if Linked List is null and just create a Node.
Otherwise, run to the end of the linked list and insert a node at the end.

2D Array easy hackerrank challenge in Swift 3

https://www.hackerrank.com/challenges/2d-array

Had to refresh memory how to parse input from Hackerrank in Swift 3.

Display image from Google Docs in the Github readme

The easies way to add an image to the Github readme that I can think of is displaying it from Google Drive. Since the assets are already hosted there.

Paste in the link into Readme.md file on github:

You’ll need to grab the ID of the image. Easiest way on the desktop is to right click the file in the drive and select View on the Web. Grab the string of characters from there and replace the in the code above with it.
Result can be seen here: https://github.com/zype/zype-ios#app-architecture

Result snapshot

Result snapshot

How to hide strange unwanted Xcode 8 logs

Running app in the simulator in a new shine xcode 8 noticed that there are a lot of extra information that is coming from the logs.
To disable it and see regular logs do the following:
1. Click on your project name and select “Edit Scheme”
2. Add environment variable OS_ACTIVITY_MODE and set it to “disable”
screen-shot-2016-09-19-at-5-07-53-pm

Woooo, your logs should be clean now!

Singleton in iOS

Recommended way of creating singleton according to Apple is in the following way:

Dispatch-once is a synchronous operation that will make sure that there are no multiple threads that are trying to allocate and instantiate singleton.