Skip to content

Instantly share code, notes, and snippets.

View kelvinfok's full-sized avatar

Kelvin Fok kelvinfok

  • Singapore
View GitHub Profile
{
"status": 200,
"layouts": [
{
"type": "mainBanner",
"id": "79c7e84a-d29b-11ee-8a80-325096b39f47",
"value": {
"id": "816aa24d-67f5-4ba1-8329-90d9d814610a",
"imageLink": "https://source.unsplash.com/random/300×200/?work-in-tech",
"title": "Learning that fits",
{
"status": 200,
"layouts": [
{
"type": "mainBanner",
"id": "79c7e84a-d29b-11ee-8a80-325096b39f47",
"value": {
"id": "816aa24d-67f5-4ba1-8329-90d9d814610a",
"imageLink": "https://source.unsplash.com/random/300×200/?work-in-tech",
"title": "Learning that fits",
@kelvinfok
kelvinfok / gist:29f1a90976fb85a04ddaaeff9574687e
Created May 6, 2024 06:46
ios-udemy-home String extension
extension String {
var camelCaseToEnglish: String {
var result = ""
var wordStartIndex = self.startIndex
for (index, char) in self.enumerated() {
if index > 0 && char.isUppercase {
let previousWord = self[wordStartIndex..<self.index(self.startIndex, offsetBy: index)]
if !previousWord.isEmpty {
result += "\(previousWord) "
class AttributedTappableLabel: UILabel {
var onTap: (() -> Void)?
var tapRange: NSRange?
var labelFont: UIFont?
override init(frame: CGRect) {
super.init(frame: frame)
// Enable user interaction to handle tap
isUserInteractionEnabled = true
@kelvinfok
kelvinfok / gist:418687f02175fa4214c9df8d724b717b
Created April 1, 2023 17:19
UIKit UILabel Builder Pattern Extension
extension UILabel {
func resizable() -> Self {
translatesAutoresizingMaskIntoConstraints = false
return self
}
func text(_ text: String) -> Self {
self.text = text
return self
struct HomeViewController_Previews: PreviewProvider {
static var previews: some View {
Container().edgesIgnoringSafeArea(.all)
}
struct Container: UIViewControllerRepresentable {
func makeUIViewController(context: Context) -> UIViewController {
UINavigationController(rootViewController: HomeViewController())
}
func updateUIViewController(_ uiViewController: UIViewController, context: Context) {}
typealias UIViewControllerType = UIViewController

FavOnboardingKit

FavOnboardingKit provides an onboarding flow that is simple and easy to implement.

video-preview

Contents

Privacy Policy
================
Last revised on [DATE]
### The Gist
[COMPANY] operates the [SERVICE] service, which we hope you use. If you use it, please use it responsibly. If you don't, we'll have to terminate your account.
For paid accounts, you'll be charged on a monthly basis. You can cancel anytime, but there are no refunds.
@kelvinfok
kelvinfok / Terms of Use
Last active January 9, 2022 07:56
Sample Terms of Use
Terms of Use
================
Last revised on [DATE]
### The Gist
[COMPANY] operates the [SERVICE] service, which we hope you use. If you use it, please use it responsibly. If you don't, we'll have to terminate your account.
For paid accounts, you'll be charged on a monthly basis. You can cancel anytime, but there are no refunds.
@kelvinfok
kelvinfok / gist:878e8078df0f22cc998181bf90248b31
Last active September 13, 2022 16:58
DateTime Picker with Start & End time - Swift 5
import UIKit
class DateTimePicker: NSObject, UIPickerViewDelegate, UIPickerViewDataSource {
// Reference from https://stackoverflow.com/questions/40878547/is-it-possible-to-have-uidatepicker-work-with-start-and-end-time
var didSelectDates: ((_ start: Date, _ end: Date) -> Void)?
private lazy var pickerView: UIPickerView = {
let pickerView = UIPickerView()