Skip to content

Instantly share code, notes, and snippets.

View photizzo's full-sized avatar

Ememobong Akpanekpo photizzo

View GitHub Profile
//
// HomeViewModel.swift
// Okukk
//
// Created by Ememobong Akpanekpo on 06/02/2020.
// Copyright © 2020 AltaLabs. All rights reserved.
//
import Domain
import RxCocoa
@photizzo
photizzo / VisitorRemoteImplementation.kt
Created June 5, 2020 06:56
Visitor implementatin logic
package com.entraid.remote.implementation
import android.content.Context
import android.util.Log
import bolts.Continuation
import bolts.Task
import com.entraid.data.repository.visitors.VisitorRemote
import com.entraid.models.EluziniParseDbConstants
import com.entraid.models.GetHostResponseRequestModel
import com.entraid.models.welcome.*
@photizzo
photizzo / VisitorRemoteImplementation.kt
Created June 5, 2020 06:56
Visitor implementatin logic
package com.entraid.remote.implementation
import android.content.Context
import android.util.Log
import bolts.Continuation
import bolts.Task
import com.entraid.data.repository.visitors.VisitorRemote
import com.entraid.models.EluziniParseDbConstants
import com.entraid.models.GetHostResponseRequestModel
import com.entraid.models.welcome.*
@photizzo
photizzo / gist:5023a19095b6cf83ee079479bf55b821
Created November 20, 2019 14:14
Phone number validation nigeria
fun String.isValidPhoneNumber(): Boolean {
val clearDigitsRegex = "[^\\d]"
this.replace(clearDigitsRegex.toRegex(), "")
val regInternationalised = "^234[7,8,9]\\d{9}\$"
val regNorm = "^0[7,8,9]\\d{9}\$"
val pattern: Pattern = Pattern.compile(regNorm)
val internationalizedPattern: Pattern = Pattern.compile(regInternationalised)
return pattern.matcher(this).find().or(internationalizedPattern.matcher(this).find())
mWeekService.getCachedLessons() // From Cache
.doFinally(() -> {
mWeekService.getLessons() // From Network
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.map(new Function<WeekResponse, List<WeekModel>>() {
@Override
public List<WeekModel> apply(
@io.reactivex.annotations.NonNull final WeekResponse response)
throws Exception {
package com.dryva.data.boilerplate.source.trip
import android.arch.paging.PagedList
import com.dryva.data.boilerplate.repository.driver.DryvaCache
import com.dryva.data.boilerplate.repository.trip.TripCache
import com.dryva.data.boilerplate.repository.trip.TripRemote
import com.dryva.domain.model.BookingData
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.schedulers.Schedulers
import io.reactivex.subjects.PublishSubject
allprojects {
apply from: "$rootDir/ktlint.gradle"
}
Go to File -> Settings... -> Editor
General -> Auto Import
check Optimize imports on the fly (for current project).
Code Style -> Kotlin
Set from... -> Predefined style -> Kotlin style guide (Kotlin plugin 1.2.20+).
open Code Generation tab
uncheck Line comment at first column;
select Add a space at comment start.
open Imports tab
curl -sSLO https://github.com/pinterest/ktlint/releases/download/0.33.0/ktlint &&
chmod a+x ktlint &&
sudo mv ktlint /usr/local/bin/
apply plugin: 'kotlin'
apply from: "../ktlint.gradle"