Skip to content

Instantly share code, notes, and snippets.

@exallium
exallium / .gitconfig
Last active October 19, 2016 13:54
Clean all merged branches and prune origin
# Allows us to call the script via git bp
[alias]
bp = !~/clean_merged_branches.py
#!/usr/bin/python
import subprocess
EXCLUDE = ["patrick-video-player-integration"]
GET_MERGED_BRANCHES = ["git", "branch", "--merged"]
DELETE_BRANCH = ["git", "branch", "--delete"]
PRUNE_ORIGIN = ["git", "remote", "prune", "origin"]
def runSubProc(proc):
@exallium
exallium / monads.kt
Created September 21, 2016 18:47
monads
package main;
sealed class Maybe<A>(private val a: A?) {
class Just<A>(a: A) : Maybe<A>(a) {
override fun toString() = "Just(${wrapped()})"
}
class None<A> : Maybe<A>(null) {
override fun toString() = "None"
}
@exallium
exallium / createButton.kt
Created January 14, 2016 19:29
JavaFX Button Column Creation in Kotlin
public fun <T> createButtonColumn(title: String, text: String, onClick: (T) -> Unit): TableColumn<T, T> {
val buttonColumn = TableColumn<T, T>(title)
buttonColumn.cellValueFactory = Callback { ReadOnlyObjectWrapper<T>(it.value) }
buttonColumn.cellFactory = Callback {
val button = Button()
object : TableCell<T, T>() {
override fun updateItem(item: T?, empty: Boolean) {
super.updateItem(item, empty)
public class Opt<T> {
public interface Function<T> {
void apply(T object);
}
private final T object;
public Opt(T object) {
this.object = object;
@exallium
exallium / build.workaround-missing-resources.gradle
Created September 18, 2015 14:27
Workaround Missing Resources for Robolectric 3.0
// Workaround for missing test resources when run unit tests within android
// studio.
// This copy the test resources next to the test classes for each variant.
// Tracked at https://github.com/nenick/AndroidStudioAndRobolectric/issues/7
// Original solution comes from
// https://code.google.com/p/android/issues/detail?id=136013#c10
// apply with:
// apply from: build.workaround-missing-resources.gradle
gradle.projectsEvaluated {
@exallium
exallium / Action.java
Last active August 29, 2015 14:27
UndoCommand Pattern
public enum Action {
ACTION1, ACTION2
}
@exallium
exallium / adapter.java
Last active August 29, 2015 14:25
flat
/* within adapter class */
private static class ItemDeletate<T> {
private final T item;
private boolean isViewed;
public ItemDelegate(T item) {
this.item = item;
}
package controller
public class Controller {
val editText : RxEditText<User> = // ...
val model : Model<User> = // ...
val modelObserver: Observer<User>? = null
val editTextObserver: Observer<User>? = null
@exallium
exallium / datak.kt
Last active August 29, 2015 14:21
kotlinvsxtend
data class MyValueObject(val a: Int, val b: String)