This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension String { | |
func insertStringAt(indexes: [Int], string: String) -> String { | |
var formatted = String() | |
for (i, str) in self.enumerated() { | |
if indexes.contains(i) { | |
formatted.append("\(str)\(string)") | |
} else { | |
formatted.append(str) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func validateSingaporeNRIC(_ nricString: String) -> Bool { | |
let str = nricString.uppercased() | |
let characters = [Character](str) | |
if characters[0] == "M" { | |
return true | |
} | |
guard str.count == 9 else { return false } | |
var weight = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func bigSorting(unsorted: [String]) -> [String] { | |
let strings = unsorted.sorted { (left, right) -> Bool in | |
if left.count > right.count { | |
return false | |
} | |
if left.count < right.count { | |
return true | |
} | |
if let l = Int(left), let r = Int(right) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
public class MyanmarNames { | |
private var keyValues = [String: String]() | |
public static let shared = MyanmarNames() | |
private init() { | |
dataString.components(separatedBy: .newlines).forEach { line in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
private struct OffsetPreferenceKey: PreferenceKey { | |
static var defaultValue: CGFloat = .zero | |
static func reduce(value: inout CGFloat, nextValue: () -> CGFloat) {} | |
} | |
struct CustomScrollView<Content: View>: View { | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Quiz { | |
public static void main(String[] args) { | |
// Question 1 | |
MultipleChoiceQuestion question1 = new MultipleChoiceQuestion( | |
"Name the most popular programming language used for developing Android Apps.", // question | |
"Python", // A | |
"Swift", // B | |
"Java", // C | |
"HTML", // D |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Helper Functions | |
def clear_screen(): | |
print("") | |
print("") | |
print("") | |
print("") | |
# convert english calender year to Myanmar calender year | |
def convert_to_mm_year(year_int, is_born_before_new_year): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
The following application calculates | |
- BMI, | |
- Ideal Weight and | |
- Amount of extra weight | |
from a person's weight and height. | |
""" | |
# convert meter to inch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import CoreImage | |
import AVFoundation | |
extension CIFilter { | |
static func accordionFoldTransition(inputImage: CIImage, inputTargetImage: CIImage, inputBottomHeight: NSNumber = 0, inputNumberOfFolds: NSNumber = 3, inputFoldShadowAmount: NSNumber = 0.1, inputTime: NSNumber = 0) -> CIFilter? { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension DispatchQueue { | |
func safeAsync(_ block: @escaping ()->()) { | |
if self === DispatchQueue.main && Thread.isMainThread { | |
block() | |
} else { | |
async { block() } | |
} | |
} | |
} |
NewerOlder