This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun countdownTimer( | |
duration: Long, | |
scheduler: Scheduler = Schedulers.io() | |
) = Observable.interval(1, TimeUnit.SECONDS, scheduler) | |
.takeWhile { it < duration } | |
.map { duration - it } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ -z "$1" ]; then | |
echo "Recursively looks for Kotlin files having missing @SerializedName annotations." | |
echo | |
echo "Usage: $0 <directory to analyze>" | |
exit 1 | |
fi | |
currentPath=$PWD | |
cd $1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface CountryProvider { | |
fun getCountryCode(): String | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.junit.Assert | |
import org.junit.Test | |
import org.junit.runner.RunWith | |
import org.junit.runners.Parameterized | |
class Multiplier { | |
fun byTwo(value: Int): Int = value * 2 | |
} | |
@RunWith(Parameterized::class) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.text.TextUtils | |
import io.mockk.every | |
import io.mockk.mockkStatic | |
import org.junit.Assert | |
import org.junit.Test | |
class TextValidator { | |
fun validate(string: String) = !TextUtils.isEmpty(string) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ $# -eq 0 ]; then | |
echo | |
echo "Example usage:" | |
echo "Having MyProject-Starter and MyProject-Final folders execute:" | |
echo | |
echo "$ bash $0 MyProject-Starter MyProject-Final" | |
echo | |
echo "This will generate a Materials.zip containing MyProject-Starter and MyProject-Final folders." | |
exit 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sealed class SampleAction { | |
object Action1 : SampleAction() | |
data class Action2WithParams(val param1: String, val param2: String) : SampleAction() | |
} | |
sealed class SampleResource { | |
object Loading : SampleResource() | |
object Error : SampleResource() | |
data class Success(val resource: MyResource) : SampleResource() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.imageio.ImageIO; | |
import java.awt.Color; | |
import java.awt.image.BufferedImage; | |
import java.io.File; | |
import java.io.IOException; | |
... | |
public static boolean isFirstPixelWhite(String imageFilename) throws IOException { | |
BufferedImage image = ImageIO.read(new File(imageFilename)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
CMD="mvn test" # Run the tests before pushing | |
$CMD | |
RESULT=$? | |
if [ $RESULT -ne 0 ]; then | |
echo "Failed $CMD" | |
exit 1 | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class WebMvcConfig | |
extends WebMvcConfigurerAdapter { | |
... | |
@Override | |
public void addInterceptors(InterceptorRegistry registry) { | |
registry.addIntercetpro(this.webContentInterceptor()); | |
super.addInterceptors(registry); | |
} |
NewerOlder