Skip to content

Instantly share code, notes, and snippets.

View nomisRev's full-sized avatar
🏂

Simon Vergauwen nomisRev

🏂
View GitHub Profile
@raulraja
raulraja / typeclassless_tagless_extensions.kt
Last active June 17, 2018 12:43
Tagless with Arrow & typeclassless using extension functions and instances
import arrow.Kind
import arrow.core.Option
import arrow.core.Try
import arrow.core.functor
import arrow.effects.IO
import arrow.effects.fix
import arrow.effects.functor
import arrow.typeclasses.Functor
/* algebras */
@raulraja
raulraja / dstagless.kt
Last active December 15, 2018 01:23
Tagless data source strategies with Arrow
import arrow.Kind
import arrow.core.Option
import arrow.core.left
import arrow.core.right
import arrow.effects.typeclasses.Async
import arrow.typeclasses.ApplicativeError
data class UserId(val value: String)
data class User(val userId: UserId)
data class Task(val value: String)
@raulraja
raulraja / validation.kt
Last active May 9, 2019 08:25
Validation: Accumulating errors and failing fast in Arrow with `ApplicativeError`
import arrow.*
import arrow.core.*
import arrow.typeclasses.*
import arrow.data.*
sealed class ValidationError(val msg: String)
data class DoesNotContain(val value: String) : ValidationError("Did not contain $value")
data class MaxLength(val value: Int) : ValidationError("Exceeded length of $value")
data class NotAnEmail(val reasons: Nel<ValidationError>) : ValidationError("Not a valid email")
@EricKuck
EricKuck / ButterknifeConductor.kt
Last active May 9, 2019 20:30
Kotterknife(ish) view binding for Conductor controllers
// Largely borrowed from Jake Wharton's Kotterknife (https://github.com/JakeWharton/kotterknife)
// and paweljaneczek's PR for resetting cached views (https://github.com/JakeWharton/kotterknife/pull/37)
package com.bluelinelabs.conductor.butterknife
import android.view.View
import com.bluelinelabs.conductor.Controller
import java.util.Collections
import java.util.WeakHashMap
import kotlin.properties.ReadOnlyProperty
@MisterRager
MisterRager / Rx2ServiceBindingFactory.java
Last active July 17, 2019 18:46
Bind to an Android service using RxJava!
import android.app.Service;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Binder;
import android.os.IBinder;
import io.reactivex.Observable;
@colomboe
colomboe / fx-test.kt
Created July 4, 2019 19:25
Porting of "Simple example of testing with ZIO environment" to Kotlin
// Porting of https://gist.github.com/jdegoes/dd66656382247dc5b7228fb0f2cb97c8
typealias UserID = String
data class UserProfile(val name: String)
// The database module:
interface DatabaseService {
suspend fun dbLookup(id: UserID): UserProfile
suspend fun dbUpdate(id: UserID, profile: UserProfile)
}
@timrijckaert
timrijckaert / AndroidManifest.xml
Last active May 2, 2020 19:32
Test rule that disables animations and softkeyboard before any test. Easy access function to control demo modus on API 23 and up devices
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="be.rijckaert.tim.disableanimations">
<!-- Place this permission in your debug folder -->
<uses-permission android:name="android.permission.SET_ANIMATION_SCALE"/>
</manifest>
@LordRaydenMK
LordRaydenMK / ValueClass.kt
Created February 2, 2020 22:09
Kotlin compiler plugin built with arrow-meta. Generates equals, hashCode and toString for classes annotated with @valueclass
@Retention(AnnotationRetention.BINARY)
@Target(AnnotationTarget.CLASS)
annotation class ValueClass
@aahlenst
aahlenst / RxIdlingResource.java
Last active July 27, 2021 15:56
IdlingResource that makes Espresso 2 wait until all RxJava 2 tasks have finished
/*
* The MIT License
*
* Copyright (c) 2016 Andreas Ahlenstorf
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@gildor
gildor / build.gradle.kts
Last active January 28, 2022 12:03
Protobuf Gradle Plugin + Kotlin DSL
import com.google.protobuf.gradle.protobuf
import com.google.protobuf.gradle.protoc
plugins {
java
idea
id("com.google.protobuf") version "0.8.7"
}
repositories {