Skip to content

Instantly share code, notes, and snippets.

@KalpeshTalkar
KalpeshTalkar / actualSurvey
Last active April 15, 2023 18:57
sample json file
{
"participantId": "all-widgets-test",
"surveyId": "63c911d8e5b4ba0018c6ce35",
"downloadTimestamp": "2023-03-26T15:39:26.397Z",
"mobileModelName": "Google sdk_gphone64_x86_64",
"mobileOperatingSystemVersion": "33",
"created": "2023-01-19T09:48:08.043Z",
"id": "63c911d8e5b4ba0018c6ce3f",
"status": "",
"survey": {
@KalpeshTalkar
KalpeshTalkar / JSONUtils-v2.swift
Last active October 15, 2023 23:37
Some extensions for converting json string to dictionary or array and vice versa.
// MIT License
//
// Copyright (c) [2022] [Kalpesh Talkar]
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// APIServiceError.swift
//
// Copyright © 2021 Kalpesh Talkar. All rights reserved.
//
import Foundation
public struct APIServiceError: LocalizedError {
@KalpeshTalkar
KalpeshTalkar / JSONUtils.swift
Last active July 28, 2021 04:59
Some useful extensions to map Data to Codable object, convert Data to JSON
//
// Copyright © 2021 Kalpesh Talkar. All rights reserved.
//
import Foundation
extension Data {
/// Foundation object from given JSON data.
var jsonValue: Any? {
//
// Copyright © 2017 Kalpesh Talkar. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
@KalpeshTalkar
KalpeshTalkar / ReuseIdentifying.swift
Created August 25, 2020 13:19
A protocol that automatically adds an identifier on a class. Mostly useful in working with collection views and table views.
//
// Copyright © 2020 Kalpesh Talkar. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
@KalpeshTalkar
KalpeshTalkar / ResetPasswordAlert.swift
Last active May 8, 2019 09:23
A customised UIAlertController for reset password functionality written in Swift.
//
// ResetPasswordAlert.swift
//
// Created by Kalpesh on 06/05/19.
// Copyright © 2019 Kalpesh Talkar. All rights reserved.
//
// For support: https://gist.github.com/KalpeshTalkar/1f8078f0e9340125f24102fdd4c73a82
import UIKit
@KalpeshTalkar
KalpeshTalkar / TableCollectionUtils.swift
Last active October 29, 2018 15:14
Extension for UITableView, UITableViewCell, UICollectionView, UICollectionViewCell.
//
// TableCollectionUtils.swift
//
// Created by Kalpesh on 25/05/18.
// Copyright © 2018 Kalpesh Talkar. All rights reserved.
//
// Support: https://gist.github.com/KalpeshTalkar/aaa6d41bb6b0b10a8ceb2b8cd8c1b791
// GitHub: https://github.com/KalpeshTalkar
// Gists: https://gist.github.com/KalpeshTalkar
//
@KalpeshTalkar
KalpeshTalkar / Validator.kt
Last active October 2, 2022 09:42
A validator class written in Kotlin can be used to validate the data. Eg. checks for valid email, phone, password, name, etc.
//
// Copyright © 2018 Kalpesh Talkar. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
@KalpeshTalkar
KalpeshTalkar / KButton.swift
Last active February 27, 2021 08:30
A custom IBDesignable UIButton which offers rounded corners, border color, border width, gradient background, on click closure and more.
// Copyright © 2017 Kalpesh Talkar. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,