Skip to content

Instantly share code, notes, and snippets.

@mengdd
mengdd / .zshrc
Last active April 21, 2023 03:38
Mac iterm2 Settings
# If you come from bash you might have to change your $PATH.
export PATH=$HOME/bin:/usr/local/bin:$PATH
export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"
# Path to your oh-my-zsh installation.
export ZSH="/Users/ddmeng/.oh-my-zsh"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
@mengdd
mengdd / proguard-rules.pro
Created June 16, 2020 05:59
Remove Logs in Production
# no logging in production
-assumenosideeffects class android.util.Log {
v(...);
d(...);
i(...);
w(...);
e(...);
println(...);
}
@mengdd
mengdd / test.json
Created April 10, 2020 16:12
Test Json
{
"name": "Bulbasaur",
"id": "#001",
"imageurl": "https://assets.pokemon.com/assets/cms2/img/pokedex/full/001.png"
}
@mengdd
mengdd / SwitchTab.java
Created January 26, 2019 09:06
Custom Switch Widget to draw the textOff too
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.support.v7.widget.SwitchCompat;
import android.text.Layout;
@mengdd
mengdd / StickyHeaderInterface.java
Created December 28, 2018 07:55
Light weight Sticky Headers RecyclerView Decoration
import android.view.View;
public interface StickyHeaderInterface {
/**
* This method gets called by {@link StickyHeaderItemDecoration} to fetch the position of the header item in the adapter
* that is used for (represents) item at specified position.
*
* @param itemPosition int. Adapter's position of the item for which to do the search of the position of the header item.
@mengdd
mengdd / ActivityModule.java
Last active August 24, 2018 09:06
Dagger Android basic classes sample code in Java
import dagger.Module;
import dagger.android.ContributesAndroidInjector;
@Module
public abstract class ActivityModule {
@ContributesAndroidInjector(modules = {FragmentBuildersModule.class})
abstract MainActivity contributeMainActivity();
}
@mengdd
mengdd / RecyclerHeadersDecoration.java
Created June 29, 2017 07:54
ItemDecoration for RecyclerView, use View as Header
public class RecyclerHeadersDecoration extends RecyclerView.ItemDecoration {
private HeaderAdapter adapter;
private SparseArray<View> headers;
public interface HeaderAdapter {
boolean hasHeader(int position);
View getHeaderView(int position);
}
@mengdd
mengdd / ProcessUtils
Created November 10, 2016 02:46
method to check if is on main process
import android.app.ActivityManager;
import android.content.Context;
import android.os.Process;
import android.util.Log;
import java.util.List;
public class ProcessUtils {
@mengdd
mengdd / RxPermissionsDemoActivity.java
Last active July 27, 2016 02:18
RxPermissions sample codes
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
rxPermissions = RxPermissions.getInstance(this);
rxPermissions.setLogging(true);
setContentView(R.layout.act_main);
surfaceView = (SurfaceView) findViewById(R.id.surfaceView);
RxView.clicks(findViewById(R.id.enableCamera))
@mengdd
mengdd / Endpoints.java
Created June 28, 2016 05:31
Retrofit request to get all endpoints of github
package com.ddmeng.githubclient.model;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import javax.annotation.Generated;
@Generated("org.jsonschema2pojo")
public class Endpoints {