View BarDBConfig.scala
This file contains 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
case class BarDBConfig(connectionString: String) extends DBConfig | |
object BarDBConfig extends DBConfig.Builder[BarDBConfig]("bar") |
View Backspaced.scala
This file contains 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 scala.annotation.tailrec | |
sealed trait Stack[A]: | |
def push(a: A): Stack[A] | |
def pop(): (Option[A], Stack[A]) | |
def size: Int | |
def reverse(): Stack[A] = | |
@tailrec def go(s1: Stack[A], s2: Stack[A]): Stack[A] = | |
s1.pop() match |
View JacksonExtensions.kt
This file contains 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 com.fasterxml.jackson.databind.JsonNode | |
object JsonExtensions { | |
fun JsonNode.objectAt(key: String): JsonNode? = this.takeIf { it.isObject }?.get(key)?.takeIf { it.isObject } | |
fun JsonNode.arrayAt(key: String): JsonNode? = this.takeIf { it.isObject }?.get(key)?.takeIf { it.isArray } | |
fun JsonNode.booleanAt(key: String): Boolean? = this.takeIf { it.isObject && it.has(key) }?.get(key)?.takeIf { it.isBoolean }?.asBoolean() | |
fun JsonNode.intAt(key: String): Int? = this.takeIf { it.isObject && it.has(key) }?.get(key)?.takeIf { it.isIntegralNumber }?.asInt() | |
fun JsonNode.longAt(key: String): Long? = this.takeIf { it.isObject && it.has(key) }?.get(key)?.takeIf { it.isIntegralNumber }?.asLong() | |
fun JsonNode.doubleAt(key: String): Double? = this.takeIf { it.isObject && it.has(key) }?.get(key)?.takeIf { it.isFloatingPointNumber }?.asDouble() |
View KotlinJson.kt
This file contains 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 java.math.BigDecimal | |
sealed class Json { | |
companion object { | |
fun `null`(): JNull = JNull | |
fun arr(vararg values: Json): JArray = JArray(*values) | |
fun obj(vararg pairs: Pair<String, Json>): JObject = JObject(*pairs) |
View KotlinVarianceTrick.kt
This file contains 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 Option<out A>(open val value: A?) { | |
fun <B> fold(ifNone: () -> B, ifSome: (A) -> B): B = | |
when (this) { | |
is None -> ifNone() | |
is Some -> ifSome(this.value) | |
} | |
// This doesn't compile because `out` type A is in `in` position | |
fun getOrElseThatWontWork(default: () -> A): A = | |
when (this) { |
View KotlinExtensions.scala
This file contains 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 scala.util.Try | |
implicit class KotlinLikeExtensions[A](a: => A) { | |
/** | |
* Produce a new value using current value | |
*/ | |
def let[B](f: A => B): B = f(a) | |
/** | |
* Do something with current value and produce nothing |
View InterfaceAbstractClass.java
This file contains 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
// Behavior of talking | |
interface Talks { | |
void talk(String what); | |
} | |
// Behavior of making sound | |
interface MakesSound { | |
void makeSound(String what); | |
} |
View rename_package.sh
This file contains 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
git filter-branch -f --prune-empty --tree-filter ' | |
find . \ | |
-name .git -prune -o \ | |
-exec sh -c "file {} | grep -q text" \; \ | |
-exec sed -i "" \ | |
-e "s/X/Y/g" \ | |
-e "s/com.x.y/com.github.makiftutuncu.trump/g" \ | |
-e "s/x/y/g" \ | |
{} \; \ | |
&& mkdir -p src/main/scala/com/github/makiftutuncu/trump && mkdir -p src/test/scala/com/github/makiftutuncu/trump && tree src && mv src/main/scala/com/x/y/* src/main/scala/com/github/makiftutuncu/trump && mv src/test/scala/com/x/y/* src/test/scala/com/github/makiftutuncu/trump && tree src |
View Either.java
This file contains 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 java.util.Optional; | |
import java.util.function.Consumer; | |
import java.util.function.Function; | |
import java.util.function.Supplier; | |
public abstract class Either<L, R> { | |
public static final class Left<L, R> extends Either<L, R> { | |
public Left(L left) { | |
super(left, null); | |
} |
View PrivacyPolicyForTextInstead.html
This file contains 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
<!DOCTYPE html><html><body><h2>Privacy Policy</h2><p>Mehmet Akif Tütüncü built the Text Instead? app as an open source app. This SERVICE is provided by Mehmet Akif Tütüncü at no cost and is intended for use as is.</p><p>This page is used to inform website visitors regarding my policies with the collection, use, and disclosure of Personal Information if anyone decided to use my Service.</p><p>If you choose to use my Service, then you agree to the collection and use of information in relation to this policy. The Personal Information that I collect are used for providing and improving the Service.I will not use or share your information with anyone except as described in this Privacy Policy.</p> <p>The terms used in this Privacy Policy have the same meanings as in our Terms and Conditions, which is accessible at Text Instead?, unless otherwise defined in this Privacy Policy.</p><p><strong>Information Collection and Use</strong></p><p>For a better experience, while using our Service, I may require you to provide |
NewerOlder