Skip to content

Instantly share code, notes, and snippets.

View tschuchortdev's full-sized avatar
🐛
master of bugs

Thilo Schuchort tschuchortdev

🐛
master of bugs
  • inoio GmbH
  • Hamburg, Germany
View GitHub Profile
@tschuchortdev
tschuchortdev / exists.scala
Last active September 5, 2023 11:59
Scala 2 existential typeclass pattern
object Main {
def main(args: Array[String]) = {
implicit val showInt = new Show[Int] {
override def show(a: Int): String = a.toString
}
implicit val readInt = new Read[Int] {
override def read(s: String): Int = s.toInt
}
@tschuchortdev
tschuchortdev / AnnotatedConstruct.kt
Created April 7, 2020 16:53
getAnnotationsByType
override fun <A : Annotation> getAnnotationsByType(annotationType: Class<A>): Array<out A> {
require(annotationType.isAnnotation) { "Not an annotation type: $annotationType" }
/* If the annotation class we are interested in is repeatable, then the annotation class must itself
be annotated with the java.lang.annotation.Repeatable meta-annotation. For the repeatable annotation class
there must be another annotation class whose property is an array of the repeatable annotation. Example:
```
@Repeatable(value = Foos::class)
annotation class Foo // Foo is the contained class
@tschuchortdev
tschuchortdev / Channel.java
Last active January 25, 2018 19:50 — forked from macsystems/Channel.java
If you want to parse an RSS Feed using SimpleXML you can use this as an Start. I used this to parse RSS using RetroFit from Square
import org.simpleframework.xml.Attribute;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.ElementList;
import org.simpleframework.xml.Namespace;
import org.simpleframework.xml.NamespaceList;
import org.simpleframework.xml.Root;
import org.simpleframework.xml.Text;
import java.util.List;
@tschuchortdev
tschuchortdev / ExampleItem.java
Created April 22, 2016 13:09
generic RecyclerAdapter that can hold all types of views without modifications
/**
* example implementation of GenericRecyclerAdapter.Item
**/
public class ExampleItem extends GenericRecyclerAdapter.Item {
public String title;
public ExampleItem(String title)
{
this.title = title;
}