Skip to content

Instantly share code, notes, and snippets.

View LanderlYoung's full-sized avatar

LanderlYoung LanderlYoung

  • Tencent.
  • Shenzhen City, Guang Dong province, R.P China
View GitHub Profile

ArrayMap ClassCastException Deep Analyze

preface

I'm a developer of 企鹅FM. Our app constantly report ClassCastException on ArrayMap, some stack trace looks like this.

Intent i = new Intent(ACTION);
i.putExtra(KEY, VALUE); // crashes here
@LanderlYoung
LanderlYoung / linux_smap_analyzer.py
Created December 20, 2017 04:08
Linux /proc/<pid>/smaps analyzer python script
#!/usr/bin/env python
# encoding: utf-8
from __future__ import print_function
'''
analyze /proc/<pid>/smaps
doc
http://liutaihua.github.io/2013/04/25/process-smaps-analysis.html
@LanderlYoung
LanderlYoung / README.md
Created October 10, 2017 05:18 — forked from zhiguangwang/README.md
Installing and running shadowsocks on Ubuntu Server

Installing and running shadowsocks on Ubuntu Server

16.10 yakkety and above

  1. Install the the shadowsocks-libev package from apt repository.

     sudo apt update
     sudo apt install shadowsocks-libev
    
  2. Save ss.json as /etc/shadowsocks-libev/config.json.

@LanderlYoung
LanderlYoung / android_dump_java_heap.sh
Created December 20, 2017 04:09
script to dump android java heap and convert use hprof-conv
ADB=${ANDROID_HOME}/platform-tools/adb
HPROF_CONV=${ANDROID_HOME}/platform-tools/hprof-conv
# customized functions
# dump droid heap
function droid_hd() {
PACKAGE_NAME=$1
TIME=$(date +"%Y%m%d_%H%M%S")
FILE_NAME="${PACKAGE_NAME}-${TIME}-heap.hprof"
@LanderlYoung
LanderlYoung / MVVM compare.kt
Last active September 24, 2021 02:23
MVVM compare
class ViewModel_1 {
val name = LiveData<String>()
val gender = LiveData<Boolean>()
val loading = LiveData<Boolean>()
val errorMessage = LiveEvent<String>()
fun follow() {
api.follow(xxx)
}
@LanderlYoung
LanderlYoung / LiveEvent.kt
Last active August 19, 2021 04:26
non sticky LiveData
sealed class LiveEvent<T> : LiveData<T>() {
private var version = 0
/**
* override hashCode and equals,
* so-that, [LiveData.removeObserver] still can work
*/
private inner class ObserverWrapper<T>(
private val other: Observer<T>
) : Observer<T> {
@LanderlYoung
LanderlYoung / javaCode.java
Last active October 23, 2020 02:26
Life without jenny
String httpGet(String url) throws IOException {
URL u = new URL(url);
URLConnection conn = u.openConnection();
InputStream input = conn.getInputStream();
byte[] buffer = new byte[1024];
int len = input.read(buffer);
input.close();
return new String(buffer, 0, len);
@LanderlYoung
LanderlYoung / WcdbSqlDriver.kt
Created January 18, 2019 06:26
This is a WCDB driver for sqldeight
/*
* Copyright (C) 2018 Square, Inc.
* Copyright (C) 2019 taylorcyang@tencent.com
* Copyright (C) 2019 landerlyoung@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
@LanderlYoung
LanderlYoung / ktd.kts
Last active September 28, 2018 13:59
Multi Thread Http Downloader implemented in kotlin script
#! /usr/bin/env kscript
@file:DependsOn("com.xenomachina:kotlin-argparser:2.0.7")
@file:DependsOn("me.tongfei:progressbar:0.7.1")
import com.xenomachina.argparser.ArgParser
import com.xenomachina.argparser.InvalidArgumentException
import com.xenomachina.argparser.SystemExitException
import com.xenomachina.argparser.default
#! /usr/bin/env bash
#--------------------
# Standard options:
export COMMON_FF_CFG_FLAGS=
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --prefix=PREFIX"
# Licensing options:
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-gpl"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-version3"