Skip to content

Instantly share code, notes, and snippets.

View guelo's full-sized avatar
💭
Engineering @PandoraMedia

Miguel Vargas guelo

💭
Engineering @PandoraMedia
View GitHub Profile
@guelo
guelo / java-sealed-class.java
Created September 30, 2017 01:27 — forked from rjrjr/java-sealed-class
Poor Man's Sealed Classes (visitor pattern)
/**
* For Java developers all excited by and jealous of Kotlin's sealed classes.
* Do this when you wish you could put parameters on an enum.
*/
public class PoorMan {
interface Event {
<T> T dispatch(EventHandler<T> handler);
}
interface EventHandler<T> {
export PS1="\u:$ "
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH="/usr/local/bin:/usr/local/sbin:~/bin:$PATH:$ANDROID_HOME/emulator:$ANDROID_HOME/platform-tools:$ANDROID_HOME/build-tools/26.0.2:~/scripts:.:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:/usr/local/share/npm/bin:$HOME/bin/gsutil:$HOME/.rvm/bin"
export NODE_PATH="/usr/local/lib/node_modules"
export EDITOR="subl -w"
export GRADLE_OPTS="-Dorg.gradle.daemon=true"
export HISTTIMEFORMAT="%m-%d %T "
#[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
@JakeWharton
JakeWharton / AutoGson.java
Last active November 28, 2021 12:32
A Gson TypeAdapterFactory which allows serialization of @autovalue types. Apache 2 licensed.
import com.google.auto.value.AutoValue;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
* Marks an {@link AutoValue @AutoValue}-annotated type for proper Gson serialization.
* <p>