Skip to content

Instantly share code, notes, and snippets.

@shaobin0604
shaobin0604 / popup_animation.xml
Created April 29, 2020 08:53
游戏计次次数变化动画
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true"
android:fillBefore="true"
android:interpolator="@android:interpolator/linear"
android:shareInterpolator="true">
<alpha
android:duration="250"
android:fromAlpha="0.0"
android:startOffset="0"
@shaobin0604
shaobin0604 / buildRawMediaSource.java
Last active April 16, 2020 17:05
exoplayer play video files in resource/raw
private MediaSource buildRawMediaSource() throws RawResourceDataSource.RawResourceDataSourceException {
RawResourceDataSource rawDataSource = new RawResourceDataSource(this);
// open the /raw resource file
rawDataSource.open(new DataSpec(RawResourceDataSource.buildRawResourceUri(R.raw.test11_rotate_270)));
return new ProgressiveMediaSource.Factory(new DefaultDataSourceFactory(this, "ExoTest")).createMediaSource(rawDataSource.getUri());
}
@shaobin0604
shaobin0604 / git-hist
Created March 27, 2020 02:43 — forked from isaldin/git-hist
git hist alias
git config --global alias.hist "log --pretty=format:'%C(yellow)[%ad]%C(reset) %C(green)[%h]%C(reset) | %C(red)%s %C(bold red){{%an}}%C(reset) %C(blue)%d%C(reset)' --graph --date=short"
@shaobin0604
shaobin0604 / find_middle_node_in_linked_list.java
Created February 18, 2020 03:56
链表快慢指针找中间节点
ListNode slow = head;
ListNode fast = head.next;
// 奇数链表,slow 位于中间节点
// 偶数链表,slow 位于左边节点
while (slow.next != null && fast.next != null) {
slow = slow.next;
fast = fast.next;
}
// 后半部分头节点
@shaobin0604
shaobin0604 / alias.zsh
Created September 3, 2019 02:26
zsh alias
fix_sdk='echo "sdk.dir=`echo $ANDROID_SDK_HOME`" > local.properties; echo ndk.dir=`echo $ANDROID_NDK_HOME` >> local.properties'
tcpdump_start_n='adb shell /data/local/tmp/tcpdump -vv -s 0 -w /sdcard/tcp.cap'
tcpdump_pull='adb pull /sdcard/tcp.cap'
tcpdump_start='adb shell tcpdump -vv -s 0 -w /sdcard/tcp.cap'
pm_clear='adb shell pm clear'
@shaobin0604
shaobin0604 / android-aar-maven-local.sh
Created June 14, 2019 06:05 — forked from mpurbo/android-aar-maven-local.sh
Installing Facebook SDK as aar to local maven repository
export ANDROID_HOME=/Applications/Android\ Studio.app/sdk/
cd facebook-android-sdk-3.14
gradle facebook:build
mv facebook/build/libs/facebook.aar facebook/build/libs/facebook-3.14.aar
mvn install:install-file -Dfile=facebook/build/libs/facebook-3.14.aar -DgroupId=com.facebook -DartifactId=android-sdk -Dversion=3.14 -Dpackaging=aar
@shaobin0604
shaobin0604 / SafeToast.java
Created June 10, 2019 03:09
Safe Toast to resolve BadTokenException on Android 7.x
package com.tmall.android.toast;
import android.content.Context;
import android.os.Handler;
import android.os.Message;
import android.support.annotation.StringRes;
import android.widget.Toast;
import java.lang.reflect.Field;
@shaobin0604
shaobin0604 / README-Template.md
Created August 31, 2018 03:46 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@shaobin0604
shaobin0604 / shell_string_operation.sh
Last active August 3, 2018 07:14
shell 字符串处理
file_name="com.wlqq.phantom.plugin.ymm.cargo_1.5.15.apk"
base_name=${file_name/.apk/}
package_name=`echo $base_name | cut -d"_" -f 1`
version_name=`echo $base_name | cut -d"_" -f 2`
echo $package_name # com.wlqq.phantom.plugin.ymm.cargo
echo $version_name # 1.5.15
@shaobin0604
shaobin0604 / RuntimeSettingPage.java
Created June 12, 2018 12:20
RuntimeSettingPage from AndPermission
/*
* Copyright 2018 Yan Zhenjie
*
* 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
*
* Unless required by applicable law or agreed to in writing, software