Skip to content

Instantly share code, notes, and snippets.

View moderateepheezy's full-sized avatar

Afees Lawal moderateepheezy

View GitHub Profile
public class VendorNewAdapter extends FirebaseRecyclerAdapter<NewsPaper, NewsPaperHolder> implements SimpleAlertDialog.SingleChoiceArrayItemProvider{
private static final int REQUEST_CODE_SINGLE_CHOICE_LIST = 34005;
private static final int REQUEST_CODE_SINGLE_Any_CHOICE_LIST = 340005;
private static final java.lang.String CHOICE_DIALOG = "dialogTagChoice";
private boolean isColorsInverted = false;
@moderateepheezy
moderateepheezy / PairByGroup.java
Created April 15, 2017 11:25
Shuffle and pair in group of two.
public class MainClass {
public static void main(String[] args) {
Scanner lop = new Scanner(System.in);
List<Pair> pairList = new ArrayList<>();
System.out.println("Enter number total number of people to group");
@moderateepheezy
moderateepheezy / PairByGroup.swift
Created April 15, 2017 14:28
Shuffle and pair in group
extension Array {
func chunked(by chunkSize: Int) -> [[Element]] {
return stride(from: 0, to: self.count, by: chunkSize).map {
Array(self[$0 ..< Swift.min($0 + chunkSize, self.count)])
}
}
}
extension Array {
mutating func shuffle () {
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))
@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;
@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
import UIKit
@IBDesignable
open class GradientView: UIView {
@IBInspectable
public var startColor: UIColor = .white {
didSet {
gradientLayer.colors = [startColor.cgColor, endColor.cgColor]
setNeedsDisplay()
}
import UIKit
final class ColorSelectionControl: UIControl {
private var buttons = [UIButton]()
private let colors: [UIColor]
lazy var currentSelectedColor: UIColor = colors[0]
init(colors: [UIColor]) {
@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 / 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.