{{ message }}

Instantly share code, notes, and snippets.

# Carlos Morera de la Chica CarlosMChica

Last active May 5, 2017
View Phone Exercise.hs
 mostPopularLetterWithCount :: String -> (Char, Int) mostPopularLetterWithCount xs = swap . maximum . fmap swap . Map.toList . Map.fromListWith (+) \$ [(x, 1) | x <- xs, not . isSpace \$ x] mostPopularWordWithCount :: String -> (String, Int) mostPopularWordWithCount xs = swap . maximum . fmap swap . Map.toList . Map.fromListWith (+) \$ [(x, 1) | x <- words xs]
Created Nov 28, 2016
Functional FizzBuzz
View FizzBuzz
 class FizzBuzz { private val fizzes = cycle("", "", "Fizz") private val buzzes = cycle("", "", "", "", "Buzz") private val fizzBuzzes = fizzes.zip(buzzes).map(x => x._1 ++ x._2) private lazy val fizzBuzz = fizzBuzzes.zip(Stream.from(1)).map(x => if (x._1.isEmpty) x._2.toString else x._1) def convert(x: Int): String = { convert(1 to x)(x - 1) }
Created Dec 12, 2014
how to animate transition between placeholder and image.
View animate transition between placeholder and image
 Dev tip: how to animate transition between placeholder and image. //Create a bitmap drawable from the bitmap to be shown Drawable bitmapDrawable = new BitmapDrawable(context,bitmap); Drawable[] layers = new Drawable[] { imageView.getDrawable(), //Current placeholder bitmapDrawable //Image to show };
Last active Aug 29, 2015
DividerItemDecoration
View DividerItemDecoration
 import android.content.Context; import android.content.res.TypedArray; import android.graphics.Canvas; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.support.annotation.DimenRes; import android.support.annotation.DrawableRes; import android.support.v7.widget.RecyclerView; import android.view.View;
Last active Aug 29, 2015
Workaround to change action bar background dynamically
View ActionBarBackgroundWorkaround.java
 //Looks like drawable is still not ready to be set when applying it to the action bar //in versions bellow 17 with default method. The action bar needs to be redrawed and it can be forced by using //the following workarround public void setActionBarbackground(ColorDrawable colorDrawable) { ActionBar actionBar = getActionBar(); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { actionBar.setBackgroundDrawable(colorDrawable); //switch true/false values if title is not needed actionBar.setDisplayShowTitleEnabled(false);