Skip to content

Instantly share code, notes, and snippets.

View jolasjoe's full-sized avatar
💭
🧑🏾‍💻

Jolas jolasjoe

💭
🧑🏾‍💻
View GitHub Profile
public class TreeNode {
public let val: Int
public var left: TreeNode?
public var right: TreeNode?
init(_ val: Int) {
self.val = val
}
}
func inorder(_ root: TreeNode) -> [Int] {
public class TreeNode {
public let val: Int
public var left: TreeNode?
public var right: TreeNode?
init(_ val: Int) {
self.val = val
}
}
func inorder(_ root: TreeNode) -> [Int] {
@jolasjoe
jolasjoe / Heap.swift
Created April 1, 2024 03:36
Simple implementation of Heap in swift
struct Heap<E> {
var storage: [E]
var compare: (E, E) -> Bool
var count: Int { storage.count }
init(storage: [E], compare: @escaping (E, E) -> Bool) {
self.storage = storage
self.compare = compare
for i in (0...((count - 1)/2)).reversed() {
siftDown(i)
}
@jolasjoe
jolasjoe / NoStoryboard new iOSApp Setup.md
Last active May 31, 2023 14:54
Steps to set up a new iOS app without Storyboard by removing Main.storyboard and its references and usages.

Steps to set up a new iOS app without Storyboard(Main.storyboard removal):

  1. Remove Main.storyboard
  2. Clear Main storyboard file base name
  3. Open info.plist and remove the property 'Storyboard name' under "Information property List > Application Scene Manifest > Scene Configuration > Application Session Role > Item 0(Default Configuration)"
  4. And finaly in your SceneDelegate update the following.

From:

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
 guard let _ = (scene as? UIWindowScene) else { return }
Thread 1 Queue : com.apple.main-thread (serial)
#0 0x000000010eed4e8e in kfun:kotlin.collections.ArrayList.Itr.next#internal at /Users/teamcity/buildAgent/work/cae0e6559deed4c4/runtime/src/main/kotlin/kotlin/collections/ArrayList.kt:309
#1 0x000000010eeed79c in forEach [inlined] at /Users/teamcity/buildAgent/work/cae0e6559deed4c4/backend.native/build/stdlib/generated/_Collections.kt:1799
#2 0x000000010eeed67f in sampleFuncForStringArrayList [inlined] at /Users/jolas-3134/Training/ArrayListSample/src/commonMain/kotlin/com.zoho.samples/Main.kt:16
#3 0x000000010eeed3d6 in objc2kotlin.43 at /<compiler-generated>:1
#4 0x000000010ec53070 in AppDelegate.application(_:didFinishLaunchingWithOptions:) at /Users/jolas-3134/Training/ArrayListSample/SampleApp/SampleApp/AppDelegate.swift:22
#5 0x000000010ec53333 in @objc AppDelegate.application(_:didFinishLaunchingWithOptions:) ()
#6 0x00007fff49369610 in -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] ()
#7 0x00007fff4936afaf in -[UIApplicat
//Swift
let namesStringList = NSMutableArray(array: ["Hello", "doctor"])
print("NSMutableArray COUNT : \(namesStringList.count)")
Main().sampleFuncForStringArrayList(names: namesStringList)
//Kotlin
public class Main {
public fun sampleFuncForStringArrayList(names: ArrayList<String>){
println("names.isNullOrEmpty() ${names.isNullOrEmpty()}")
class ViewController: UIViewController{
let collectionView: UICollectionView = {
let flowLayout = UICollectionViewFlowLayout()
flowLayout.estimatedItemSize = UICollectionViewFlowLayout.automaticSize
flowLayout.headerReferenceSize = CGSize(width: 100, height: 50)
flowLayout.sectionHeadersPinToVisibleBounds = true
flowLayout.scrollDirection = .vertical
let view = UICollectionView(frame: .zero, collectionViewLayout: flowLayout)
view.translatesAutoresizingMaskIntoConstraints = false
//Original Source: https://stackoverflow.com/a/3028660/10506244
public class DownloadService extends IntentService {
public static final int UPDATE_PROGRESS = 8344;
public DownloadService() {
super("DownloadService");
}
@Override
protected void onHandleIntent(Intent intent) {
//
// ViewController.swift
// CVSelfSizingCells
//
// Created by Jolas L on 13/06/20.
// Copyright © 2020 Jolas L. All rights reserved.
//
import UIKit
//
// ViewController.swift
// CVSelfSizingCells
//
// Created by Jolas L on 13/06/20.
// Copyright © 2020 Jolas L. All rights reserved.
//
import UIKit