Skip to content

Instantly share code, notes, and snippets.

View pamartineza's full-sized avatar

Pablo A Martínez Andrés pamartineza

  • GreenLionSoft Desarrollos Digitales
  • Madrid
View GitHub Profile
@pamartineza
pamartineza / gist:330d33196a1abb7aac63
Last active April 19, 2016 10:09
Resolution Gist
NAME | Density | Pixels | 1/2 Square | 16:9 Image | Map Marker |
ldpi | 0.5 | 180 x 320 | |
mdpi | 1 | 360 x 640 | 180x180 | 360 x 202 | 32
hdpi | 1.5 | 540 x 960 | 270x270 | 540 x 304 | 48
xhdpi | 2 | 720 x 1280 | 360x360 | 720 x 405 | 64
xxhdpi | 3 | 1080 x 1920 | 540x540 | 1080 x 608 | 96
xxxhdpi | 4 | 1440 x 2560 | | 1440 x 810 |
@pamartineza
pamartineza / gist:dd496dda5e3c1360edd0
Created March 3, 2016 16:24
grep replace OSX command
grep -rl 'Copyright ©2015' . | xargs sed -i "" 's/2015/2016/g'
######
Application Class
######
AdtagInitializer.initInstance(this)
.initUrlType(Url.UrlType.PRE_PROD)
.initUser("*******", "**********")
.initCompany("********");
AdtagLogsManager.initInstance(this, Network.ALL, 200, 1000 * 60 * 2);
//package com.your.app.package;
import android.content.Context;
import java.io.File;
public final class PicassoCacheUtil {
public static boolean clearImageDiskCache(Context context) {
File cache = new File(context.getApplicationContext().getCacheDir(), "picasso-cache");
//Note: I'm using JodaTime API to handle dates
public void checkPicassoCacheDate() {
final DateTime remoteImagesDate = mRemoteConfig.getRemoteImagesDate();
final DateTime imagesCacheDate = mUserDefaults.getImagesCacheDate();
if (remoteImagesDate.isAfter(imagesCacheDate)) {
//Local cache is old, clear it and save new date in a different thread
Thread t = new Thread(new Runnable() {
import android.appwidget.AppWidgetProvider;
import android.content.Context;
import android.content.Intent;
import android.widget.RemoteViews;
import com.greenlionsoft.cercaniaslib.R;
import com.greenlionsoft.sharedlib.logs.Logx;
import java.util.Arrays;
class FavoritesProvider : IFavoritesProvider {
val database = FirebaseDatabase.getInstance()
val gson = Gson()
val favoritesCache = FavoritesMemoryCache()
override fun saveBusStopFavoritesList(favorites: List<BusStopFavorite>) {
//save in cache
favoritesCache.saveBusStopFavoritesList(favorites)
//save in remote
class FavoritesMemoryCache {
//Bus Stop Favorites
private var busStopFavoritesList: MutableList<BusStopFavorite>?=null
fun retrieveBusStopFavoriteList(): List<BusStopFavorite>? {
if (busStopFavoritesList != null) {
return busStopFavoritesList.toList()
}
return null
@pamartineza
pamartineza / Medium_RetryWhen_1.kt
Created September 7, 2018 10:11
Medium Gist Exponential
//It emits "1", "2", "3" then signals completion
Observable.range(1,3)
//retryCount is a Long variable value
//eg. When retryCount = 1, observable emmits a 0L after 2 sec, then completes
//eg. When retryCount = 2, observable emmits a 0L after 4 sec, then completes
//eg. When retryCount = 3, observable emmits a 0L after 8 sec, then completes
Observable.timer(Math.pow(2.toDouble(), retryCount.toDouble()).toLong(), TimeUnit.SECONDS)