Skip to content

Instantly share code, notes, and snippets.

View michalfaber's full-sized avatar

MFaber michalfaber

View GitHub Profile
@michalfaber
michalfaber / example00.scala
Created July 23, 2015 11:18
Flat structure -> chierarchy
def comments(postId: Int) : Future[Seq[CommentNode]] = {
val query = for {
comment <- Comments if comment.objectId === postId
author <- Users if author.id === comment.userId
} yield (author, comment)
val comments: Future[Seq[Comment]] = for {
result <- db.run(query.result)
} yield result.map { case (author, comment) =>
Comment(comment.id, comment.replyToId, author.name, author.site, comment.date, comment.body, comment.bodyHtml)
@michalfaber
michalfaber / fadeinfadeout.java
Created November 18, 2014 16:34
Universal FadeIn FadeOut for Android
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void fadeOut(final View view) {
int sdk = android.os.Build.VERSION.SDK_INT;
if(sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) {
AlphaAnimation alpha = new AlphaAnimation(1f, 0f);
alpha.setDuration(mShortAnimationDuration);
alpha.setFillAfter(true);
view.startAnimation(alpha);
} else {
view.animate()