Skip to content

Instantly share code, notes, and snippets.

View markiv's full-sized avatar

Vikram Kriplaney markiv

View GitHub Profile

Keybase proof

I hereby claim:

  • I am markiv on github.
  • I am krips (https://keybase.io/krips) on keybase.
  • I have a public key ASAKJil3iYQZB9JTkiKN9znoKe5RRyc1eOCy5pkcfaCkIgo

To claim this, I am signing this object:

import Foundation
extension URLComponents {
/// Abstracts away URLComponent’s array of URLQueryItems into a simple dictionary
var parameters: [String: CustomStringConvertible] {
get {
return queryItems?.reduce(into: [String: String]()) { $0[$1.name] = $1.value } ?? [:]
}
set {
queryItems = newValue.map { URLQueryItem(name: $0.key, value: String(describing: $0.value)) }
extension KeyedDecodingContainer {
func lenientDecode<T>(_ type: T.Type, forKey key: KeyedDecodingContainer.Key) throws -> T where T: Decodable & LosslessStringConvertible {
do {
return try decode(T.self, forKey: key)
} catch {
guard let stringValue = try? decode(String.self, forKey: key), let t = T(stringValue) else { throw error }
return t
}
}
}
@markiv
markiv / LeanCanvasTemplate.md
Created February 20, 2018 13:24
A simple lean canvas template in Markdown

Lean Canvas

Problem

List your top 1-3 problems.

Existing Alternatives

List how these problems are solved today.

@markiv
markiv / URLExtensions.swift
Created August 10, 2018 15:34
Useful URL extensions
extension URL {
typealias ComponentsManipulator = (inout URLComponents) -> ()
func manipulate(with manipulator: ComponentsManipulator) -> URL {
guard var components = URLComponents(url: self, resolvingAgainstBaseURL: true) else { return self }
manipulator(&components)
return components.url ?? self
}
/// Deletes first path component after the initial slash
@markiv
markiv / ContentView.swift
Last active November 7, 2019 17:46
Playing with a combined stepper and text field for entering numeric quantities
//
// ContentView.swift
// QuantityStepper
//
// Created by Vikram Kriplaney on 07.11.2019.
// Copyright © 2019 iPhonso GmbH. All rights reserved.
//
import SwiftUI
import Foundation
extension String.StringInterpolation {
fileprivate static let myMeasurementFormatter: MeasurementFormatter = {
let this = MeasurementFormatter()
this.unitOptions = [.naturalScale]
this.numberFormatter.maximumFractionDigits = 1
return this
}()
mutating func appendInterpolation<UnitType>(_ measurement: Measurement<UnitType>) where UnitType: Unit {
[
{
"title": "Contovista Result 1",
"summary": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"confidence": 0.75,
"provider": "Contovista",
"url": "banking://contovista/overview"
},
{
"title": "Contovista Result 1",
@markiv
markiv / FloatingTextField1.swift
Last active May 16, 2020 21:45
FloatingTextField1.swift
struct FloatingTextField: View {
let title: String
let text: Binding<String>
var body: some View {
VStack(alignment: .leading, spacing: 2) {
Text(title)
.font(.caption)
.foregroundColor(Color(.placeholderText))
TextField(title, text: text)
@markiv
markiv / FloatingTextField2.swift
Created May 16, 2020 16:35
FloatingTextField2.swift
struct FloatingTextField: View {
let title: String
let text: Binding<String>
var body: some View {
VStack(alignment: .leading, spacing: 2) {
Text(title)
.font(.caption)
.foregroundColor(Color(.placeholderText))
.opacity(text.wrappedValue.isEmpty ? 0 : 1)