Skip to content

Instantly share code, notes, and snippets.

View hhariri's full-sized avatar

Hadi Hariri hhariri

View GitHub Profile
package x
fun fn(items: List<String?>) {
items.foreach(filter.notNull) { value ->
println("$value")
}
items.foreach(map.indexed) { (index,value) ->
println("$index $value")
}
trait SelectResult<T> {
val take: Boolean
val value: T
class object {
fun take<T>(value: T) = object : SelectResult<T> {
override val value: T = value
override val take: Boolean = true
}
fun skip<T>() = object : SelectResult<T> {
fun String.pluralize() : String{
val rules = listOf(
"$" to "s",
"s$"to "s",
"(ax|test)is$" to "$1es",
"us$" to "i",
"(octop|vir)us$" to "$1i",
"(octop|vir)i$" to "$1i",
"(alias|status)$" to "$1es",
"(bu)s$" to "$1ses",
@meza
meza / CalculatorTest.java
Last active August 29, 2015 13:56
Mini-blogpost in response of a twitter correspondence
/**
* Disclamer: This is sort of a rant, but without any negative feelings towards the creators of the project
* in question.
* I value their desire to help people write more readable code, and wish there were more people doing this!
* The only thing I'm questioning is the ever growing trend of tools over craft.
*
* This is a mini blog-post in response to https://twitter.com/hhariri/status/435457449232171008
*
* The reason I have some negative feelings is that writing readable code is not rocket
* science, and with tools like Spek, we're basically allowing people to be ignorant about crafting clean