Skip to content

Instantly share code, notes, and snippets.

// Copied from https://github.com/ToxicBakery/ViewPagerTransforms
@SuppressWarnings("WeakerAccess")
public abstract class BaseTransformer implements PageTransformer {
public static final float DAMPING_RATIO_NO_BOUNCY = 1f;
/**
* Called each {@link #transformPage(View, float)}.
*
* @param view the view
@AndiMiko
AndiMiko / migrateAndroidX.py
Created February 8, 2019 02:16
Replaces the pairs in androidx-class-mapping.csv (get it here: https://developer.android.com/jetpack/androidx/migrate) to migrate Android support to AndroidX
import glob
import csv
dictCSV = "C:/path/to/androidx-class-mapping.csv"
projectPath = "C:/path/to/project/src/"
def replace_all(text, dic):
for i, j in dic.items():
text = text.replace(i, j)
return text
@dlew
dlew / script.sh
Created November 9, 2018 16:36
Simple AndroidX Migration Script
#!/usr/bin/env bash
# I've found that the "Migrate to AndroidX" converter in Android Studio doesn't work very
# well, so I wrote my own script to do the simple job of converting package names.
#
# You can download a CSV of package names here: https://developer.android.com/topic/libraries/support-library/downloads/androidx-class-mapping.csv
#
# It'll run faster on a clean build because then there are fewer files to scan over.
#
# Uses `gsed` because I'm on a Mac. Can easily replace with `sed` if you don't have `gsed`.
@oliveratgithub
oliveratgithub / emojis.json
Last active July 25, 2024 07:18
Emoji-list with emojis, names, shortcodes, unicode and html entities [massive list]
{
"emojis": [
{"emoji": "👩‍👩‍👧‍👧", "name": "family: woman, woman, girl, girl", "shortname": ":woman_woman_girl_girl:", "unicode": "1F469 200D 1F469 200D 1F467 200D 1F467", "html": "👩‍👩‍👧‍👧", "category": "People & Body (family)", "order": ""},
{"emoji": "👩‍👩‍👧‍👦", "name": "family: woman, woman, girl, boy", "shortname": ":woman_woman_girl_boy:", "unicode": "1F469 200D 1F469 200D 1F467 200D 1F466", "html": "👩‍👩‍👧‍👦", "category": "People & Body (family)", "order": ""},
{"emoji": "👩‍👩‍👦‍👦", "name": "family: woman, woman, boy, boy", "shortname": ":woman_woman_boy_boy:", "unicode": "1F469 200D 1F469 200D 1F466 200D 1F466", "html": "👩‍👩‍👦‍👦", "category": "People & Body (family)", "order": ""},
{"emoji": "👨‍👩‍👧‍👧", "name": "family: man, woman, girl, girl", "shortname": ":man_woman_girl_girl:", "unicode": "1F468 200D 1F469 200D 1F467 200D 1F467", "html": "👨‍👩&z
@ibraheem4
ibraheem4 / postgres-brew.md
Last active July 18, 2024 00:18 — forked from sgnl/postgres-brew.md
Installing Postgres via Brew (OSX)

Installing Postgres via Brew

Pre-Reqs

Brew Package Manager

In your command-line run the following commands:

  1. brew doctor
  2. brew update
@xingstarx
xingstarx / MapDeserializerDoubleAsIntFix.java
Last active March 21, 2022 02:21
处理Gson中,json转换map造成的int变double的问题
/**
*最近在研究网络请求数据解析的问题,发现json数据被强制转换为map结构的时候,会出现int变成double的问题
*在stackoverflow上看到了一个这个How can I prevent gson from converting integers to doubles 的问题,采用了这个答案
*https://stackoverflow.com/a/36529534/5279354答案
*/
import com.google.gson.JsonArray;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
@CarolusX74
CarolusX74 / AuthTokenRefreshInterceptor.java
Last active March 15, 2022 04:42
How I automatically refresh OAuth "access token" with okhttp interceptors using "refresh token". All requests will wait until token refresh finished, and then will continue with the new token. - EN (By Carlos Torres)
package com.cjtp.android.api.interceptors;
import android.util.Log;
import com.google.gson.JsonObject;
import com.inviteez.android.core.Session;
import com.inviteez.android.utils.Constant;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
@BramYeh
BramYeh / LowercaseEnumTypeAdapterFactory
Created March 28, 2017 13:11
LowercaseEnumTypeAdapterFactory
public class LowercaseEnumTypeAdapterFactory implements TypeAdapterFactory {
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
Class<T> rawType = (Class<T>) type.getRawType();
if (!rawType.isEnum()) {
return null;
}
final Map<String, T> lowercaseToConstant = new HashMap<String, T>();
for (T constant : rawType.getEnumConstants()) {
lowercaseToConstant.put(toLowercase(constant), constant);
@JosiasSena
JosiasSena / DeCryptor.java
Last active September 12, 2023 12:40
Encryptor and Decryptor for data encryption.decryption using the Android KeyStore.
/**
_____ _____ _
| __ \ / ____| | |
| | | | ___| | _ __ _ _ _ __ | |_ ___ _ __
| | | |/ _ \ | | '__| | | | '_ \| __/ _ \| '__|
| |__| | __/ |____| | | |_| | |_) | || (_) | |
|_____/ \___|\_____|_| \__, | .__/ \__\___/|_|
__/ | |
|___/|_|
*/
@brucevanfdm
brucevanfdm / setUpIndicatorWidth.java
Last active June 12, 2020 03:38
通过反射修改TabLayout Indicator的宽度
/**
* 通过反射修改TabLayout Indicator的宽度(仅在Android 4.2及以上生效)
*/
private void setUpIndicatorWidth() {
Class<?> tabLayoutClass = tabLayout.getClass();
Field tabStrip = null;
try {
tabStrip = tabLayoutClass.getDeclaredField("mTabStrip");
tabStrip.setAccessible(true);
} catch (NoSuchFieldException e) {