Skip to content

Instantly share code, notes, and snippets.

View pedrovgs's full-sized avatar
😃

Pedro Gómez pedrovgs

😃
View GitHub Profile
@Serchinastico
Serchinastico / fizzbuzz.kt
Created September 11, 2018 09:13
Tail recursive FizzBuzz in kotlin
tailrec fun fizzbuzz(vararg args: Int) {
if (args.isEmpty()) return
val arg = args[0]
when {
arg % 15 == 0 -> print("FizzBuzz")
arg % 3 == 0 -> print("Fizz")
arg % 5 == 0 -> print("Buzz")
}
suspend fun getCards() =
service.getCards()
.async(IO.async())
.fix()
.map { response ->
when (response.code()) {
200 -> response.body()?.cards?.right() ?: NoContent.left()
204 -> NoContent.left()
404 -> NoInternetConnection.left()
401 -> NotAllowedError.left()
@pedrovgs
pedrovgs / ScreenshotTest.kt
Last active November 22, 2019 12:50
Interface you can import from your tests to be able to use screenshot testing for Android with different resolutions easily
import android.app.Activity
import android.app.Dialog
import android.content.Context
import android.view.View
import androidx.fragment.app.Fragment
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation
import com.facebook.testing.screenshot.Screenshot
import com.facebook.testing.screenshot.ViewHelpers
@lencioni
lencioni / waitUntilSettled.ts
Last active October 20, 2023 14:43
cy.waitUntilSettled()
/**
* We often run into a problem with functions that select DOM nodes like
* `cy.get`, where in between the `cy.get` call and the next item in the chain,
* the DOM element that `cy.get` found ends up being removed from the DOM. This
* can affect code as simple as:
*
* cy.get('button').click();
*
* When it fails sporadically, it uses the following error message:
*