Skip to content

Instantly share code, notes, and snippets.

View moderateepheezy's full-sized avatar

Afees Lawal moderateepheezy

View GitHub Profile
/**
Some numbers can have strange behaviour going back to Double or Float
If rounding in Decimal it's best to keep it in Decimal until the point of display or transport in JSON
Read here: https://forums.swift.org/t/jsonencoder-encodable-floating-point-rounding-error/41390/6
**/
/*
A helper that assists in rounding a Double to a given number of decimal places
*/
import UIKit
import AVFoundation
import Core
import Permission
import RxCocoa
import RxOptional
import RxSwift
import Vision
import AVFoundation
import RxCocoa
import RxSwift
protocol CameraManagerDelegate: AnyObject {
func didStartRecord()
func didCapturedImage(_ image: CapturedImage)
func videoCapture(didCaptureVideoFrame pixelBuffer: CVPixelBuffer)
}
@moderateepheezy
moderateepheezy / Lesion.swift
Created April 9, 2021 09:58
Compute bounding box for MLModel
import CoreML
import Foundation
import UIKit
public class Lesion {
public static let inputWidth = 416
public static let inputHeight = 416
public static let maxBoundingBoxes = 4
// Tweak these values to get more or fewer predictions.
import UIKit
final class ColorSelectionControl: UIControl {
private var buttons = [UIButton]()
private let colors: [UIColor]
lazy var currentSelectedColor: UIColor = colors[0]
init(colors: [UIColor]) {
import UIKit
@IBDesignable
open class GradientView: UIView {
@IBInspectable
public var startColor: UIColor = .white {
didSet {
gradientLayer.colors = [startColor.cgColor, endColor.cgColor]
setNeedsDisplay()
}
@moderateepheezy
moderateepheezy / DropdownTextField.swift
Created July 21, 2020 23:27
A drop down textfield with RxSwift
import UIKit
import RxSwift
import RxCocoa
final class DropdownTextField: CustomTextField, UIPickerViewDataSource, UIPickerViewDelegate {
var onDoneClicked: BehaviorRelay<Void?> = BehaviorRelay(value: nil)
var source: [String] = []
@moderateepheezy
moderateepheezy / DeepLinking.swift
Last active May 3, 2020 11:00
Deep linking iOS: A prototype of how you can implement deep linking with Coordinator in an iOS app
typealias Param = [AnyHashable: Any]?
/// We use `CordinatorActionFactory` in AppDelegate to process data
final class CordinatorActionFactory {
/// make a CoordinatorAction from url scheme data gotten from `CordinatorActionFactory`
func make(from urlSchemeHost: String, parameters: [String: Any]) -> CoordinatorAction? {
var params = parameters
params["type"] = urlSchemeHost
@moderateepheezy
moderateepheezy / UserService.ts
Created May 28, 2018 09:10
Login with facebook Angular 5
import { Injectable } from "@angular/core";
import { Component } from "@angular/core";
import { Http } from "@angular/http";
import { facebookVariables } from "../../getFBSDK";
import { Router } from "@angular/router";
import { LocalStorage, JSONSchema } from "@ngx-pwa/local-storage";
import { User } from "../models/User";
import {GoogleAuthService} from "ng-gapi/lib/GoogleAuthService";
import GoogleUser = gapi.auth2.GoogleUser;
func isValidEmailAddress(email: String) -> Bool {
var returnValue = true
let emailRegEx = "[A-Z0-9a-z.-_]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,3}"
do {
let regex = try NSRegularExpression(pattern: emailRegEx)
let nsString = email as NSString
let results = regex.matches(in: email, range: NSRange(location: 0, length: nsString.length))