Skip to content

Instantly share code, notes, and snippets.

@pkliang
pkliang / json_compat_formatter.py
Created December 26, 2023 17:40
Format json file without whitespaces
import json
import glob
def format_json_compat(file):
json_file = open(file)
raw_json = json.load(json_file)
json_compat = json.dumps(raw_json, indent=None, separators=(',', ':'))
print(json_compat)
write_file = open(file, 'w')
@pkliang
pkliang / HiltDataBinding.kt
Created September 17, 2020 12:34 — forked from nuhkoca/HiltDataBinding.kt
A demonstration about how to inject BindingAdapters with Dagger Hilt.
BindingScoped.kt
@Scope
@Retention(AnnotationRetention.BINARY)
annotation class BindingScoped
-------------------------------------------------------
CustomBindingComponent.kt
@pkliang
pkliang / mds_log
Created February 14, 2020 14:39
mds log
2017-12-22 18:02:34.064 5625-5625/com.movesense.samples.connectivityapisample I/MainActivity: Connecting to BLE device: 0C:8C:DC:2B:B9:5A
2017-12-22 18:02:34.065 5625-5625/com.movesense.samples.connectivityapisample I/Mds: Connecting to BLE device: 0C:8C:DC:2B:B9:5A
2017-12-22 18:02:34.065 5625-5625/com.movesense.samples.connectivityapisample I/Mds: MdsConnectionListener exists
2017-12-22 18:02:34.071 5625-5647/com.movesense.samples.connectivityapisample I/Komposti: [SDS REQUEST] type: POST uri: suunto://MDS/EventListener contract: {"Uri":"suunto://MDS/ConnectedDevices"}
2017-12-22 18:02:34.073 5625-5653/com.movesense.samples.connectivityapisample I/Komposti: Adding EventListener for path: suunto://MDS/ConnectedDevices
2017-12-22 18:02:34.075 5625-5653/com.movesense.samples.connectivityapisample I/Komposti: [SDS RESPONSE] type: POST status: OK header: {"Location": "MDS/EventListener/24", "TaskId": 24, "Uri": "suunto://MDS/EventListener", "Content-Length": 0, "Reason": "OK", "Status": 200}
2017-12-22 18:02:34.
@pkliang
pkliang / HeaderItemDecoration.kt
Created June 7, 2019 21:48 — forked from filipkowicz/HeaderItemDecoration.kt
Item Decorator for sticky headers in Kotlin
/*
solution based on - based on Sevastyan answer on StackOverflow
changes:
- take to account views offsets
- transformed to Kotlin
- now works on viewHolders
- try to cache viewHolders between draw's
@pkliang
pkliang / CustomView.java
Last active November 23, 2020 15:25
Android Custom View
public class CustomView extends LinearLayout implements OnMapReadyCallback {
SupportMapFragment mapFragment;
@BindView(R.id.location_text) MapChip locationText;
private GoogleMap googleMap;
private LocationWithPolygon locationWithPolygon;
private Polygon polygon;
public CustomView(Context context) {
public class CountriesPresenter {
private final CountryRepository repository = new CountryRepositoryImpl();
private CountriesActivity view;
public CountriesPresenter(CountriesActivity countryActivity) {
view = countryActivity;
}
public void getCountries() {
@pkliang
pkliang / RxFirebase.java
Created September 8, 2016 08:06 — forked from gsoltis/RxFirebase.java
RxJava Bindings for Firebase
package com.firebase.client;
import com.firebase.client.core.Constants;
import rx.Observable;
import rx.Subscriber;
import rx.functions.Action0;
import rx.functions.Func1;
import rx.subscriptions.Subscriptions;
public class RxFirebase {
@pkliang
pkliang / Pager.java
Created August 19, 2016 08:55 — forked from mttkay/Pager.java
A simple Rx based pager
public class Pager<I, O> {
private static final Observable FINISH_SEQUENCE = Observable.never();
private PublishSubject<Observable<I>> pages;
private Observable<I> nextPage = finish();
private Subscription subscription = Subscriptions.empty();
private final PagingFunction<I> pagingFunction;
private final Func1<I, O> pageTransformer;
@pkliang
pkliang / RecyclerViewButterKnifeAdapter
Created November 25, 2015 12:28
Android Studio file template for RecyclerViewAdapter with ButterKnife
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
import android.support.v7.widget.RecyclerView;
import butterknife.Bind;
import butterknife.ButterKnife;
#parse("File Header.java")
public class ${NAME} extends RecyclerView.Adapter<${NAME}.ViewHolder> {
@Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
@pkliang
pkliang / build.txt
Last active November 9, 2015 09:46
build
[sts] -----------------------------------------------------
[sts] Starting Gradle build for the following tasks:
[sts] build
[sts] -----------------------------------------------------
Inferred version 0.8.12 for final PATCH change.
:framework:compileJavawarning: [options] bootstrap class path not set in conjunction with -source 1.6
1 warning
:framework:compileAspectJ
warning at /Users/liangsong/RoboBinding/framework/src/main/java/org/robobinding/aspects/PresentationModelAspect.aj:37::0 advice defined in org.robobinding.aspects.PresentationModelAspect has not been applied [Xlint:adviceDidNotMatch]