Skip to content

Instantly share code, notes, and snippets.

  1. Create a new Implementation of Logger that makes all message uppercase and replace the existing one.
  2. Create a new Implementation of Logger that inherits from the uppercase version. Add new functionality
  3. Create a new LogHandler that inherits from LogHandler. This should allow for the Logger to be changed after the constructor is used
  4. Create a new LogHandler that can accept multiple Loggers and uses all of them to display messages
@sdoward
sdoward / ShouldUpdate.kt
Created April 11, 2020 15:25
Testing Examples
fun AppConfig.shouldUpdate(appVersion: String): Boolean {
val appNumbers = appVersion.substringBefore(" ").split(".").map { it.toInt() }
val minNumbers = minAndroidVersion.split(".").map { it.toInt() }
appNumbers.forEachIndexed { index, number ->
val minNumber = minNumbers.elementAtOrElse(index) { 0 }
if (number > minNumber) {
return false
} else if (number < minNumber) {
return true
}
{
"employees":[
{
"imageUrl":" ",
"name":"Sam Doward"
},
{
"imageUrl":"",
"name":"Enrique Anaya"
},
@sdoward
sdoward / Models.kt
Last active March 27, 2019 14:31
HomeCard Api Response
sealed class HomeCard {
data class Campaign(val campaignId: String,
val imageUrl: String,
val videoUrl: String?,
val mapUrl: String,
val title: String,
val progress: Int,
val footer: Footer) : HomeCard()
{
"cameraPage": {
"id": "camera_test123",
"text1": "",
"text2": "",
"image": null,
"data": {
"campaignId": "yemen",
"teamId": "asfasdf",
"meals": 234,
@sdoward
sdoward / annon_git.sh
Last active March 3, 2016 21:15
a script which anonymises a git repo
#!/bin/sh
# Suppose you want to do blind reviewing of code (eg for job interview
# purposes). Unfortunately, the candidates' names and email addresses are
# stored on every commit! You probably want to assess each candidate's version
# control practices, so just `rm -rf .git` throws away too much information.
# Here's what you can do instead.
# Rewrite all commits to hide the author's and commiter's name and email
for branch in `ls .git/refs/heads`; do