Skip to content

Instantly share code, notes, and snippets.

@AlexZhukovich
AlexZhukovich / README.md
Last active September 21, 2021 07:04
Testing redirect with Cypress

This gist shows how to create a Cypress test case that verifies redirect.

In the current example, the redirect-data.json has only one object. However, you can add more objects.

Article: https://alexzh.com/testing-redirect-with-cypress/

File pathes:

  • cypress/fixtures/redirect-data.json
  • cypress/integration/website-redirect/website-redirect.spec.js
@AlexZhukovich
AlexZhukovich / DemoAlignModifier.kt
Created March 7, 2021 12:54
Jetpack Compose: Layouts
package com.alexzh.composeplayground
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
@AlexZhukovich
AlexZhukovich / customRange.kt
Created November 20, 2020 07:36
Kotlin: Custom Range - Restaurant delivery time options
data class Restaurant(
val id: Long,
val name: String,
val openTime: Date,
val closeTime: Date
) {
private val deliveryTimeStep: Long = 15 * 60 * 1000
fun getDeliveryTimeOptions(): DeliveryTimeOptions {
return openTime..closeTime step deliveryTimeStep
@AlexZhukovich
AlexZhukovich / gist:084fcf7d89e1080d574b62eb25b5a79b
Created February 7, 2020 12:17
Jetpack Compose - combine composable functions
@Composable
fun CoffeeDrinkCard(
coffeeDrink: CoffeeDrinkModel
) {
MaterialTheme {
Column {
Row {
CoffeeDrinkLogo(id = coffeeDrink.imageUrl)
Container(alignment = Alignment.TopLeft,modifier = LayoutFlexible(1f)) {
Column {
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
CoffeeDrinksList(coffeeDrinks)
}
}
@Composable
fun CoffeeDrinkList(
coffeeDrinks: List<CoffeeDrink>
@Composable
fun CoffeeDrinkCard(
coffeeDrink: CoffeeDrinkModel
) {
Row {
Container(modifier = LayoutSize(80.dp), alignment = Alignment.Center) {
DrawImage(image = imageResource(coffeeDrink.imageUrl))
}
Container(
alignment = Alignment.TopLeft,
fun getCoffeeDrinks(): List<CoffeeDrink> {
return listOf(
CoffeeDrink(
name = "Americano",
imageUrl = R.drawable.americano_small,
ingredients = "Espresso, Water"
),
CoffeeDrink(
name = "Cappuccino",
imageUrl = R.drawable.cappuccino_small,
data class CoffeeDrink(
val name: String,
@DrawableRes val imageUrl: Int,
val description: String,
val ingredients: String
)
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
Text(text = "Hello, World")
}
}
}
android {
...
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
}