Skip to content

Instantly share code, notes, and snippets.

View tw-Frey's full-sized avatar

Frey tw-Frey

  • Taipei, Taiwan
View GitHub Profile
@tw-Frey
tw-Frey / jQuery.getScript.Cached.md
Last active September 8, 2022 22:01 — forked from steveosoule/README.md
jQuery.getScript Cached

jquery.getScriptCached.js

jQuery's $.getScript function is a quick and easy way to include external JavaScript files into a website. However, its default implimentation will not cache the script file for the client.

The following information describes how you can itilize cached versions of $.getScript

Usage

  1. Include jquery, if it's not already.
@tw-Frey
tw-Frey / CertPathValidatorException.md
Created August 26, 2022 04:21
Trust Anchor not found for Android SSL Connection

The certificate is not signed by a trusted authority (checking against Mozilla's root store). If you bought the certificate from a trusted authority, you probably just need to install one or more Intermediate certificates. Contact your certificate provider for assistance doing this for your server platform.

Stevie answer in StackOverflow


验证服务器证书时的常见问题 出现这种情况的原因有很多,其中包括:

  1. 颁发服务器证书的 CA 未知 >2. 服务器证书不是 CA 签名的,而是自签名的
@tw-Frey
tw-Frey / Editable_to_Gson.md
Created July 21, 2022 23:05
Android TextView 的 Editable 輸出給 Gson 時,must do toString(),不然會以 SpannableString 轉 Json,這樣會有問題

Android TextView 的 Editable 輸出給 Gson 時,must do toString(),不然會以 SpannableString 轉 Json,這樣會有問題

@tw-Frey
tw-Frey / kotlin_same_name.md
Created July 14, 2022 08:58
Kotlin 同名接口 的真相
@tw-Frey
tw-Frey / git-cherry-pick.md
Created July 11, 2022 14:43
git cherry-pick 保留 origin commit date

git cherry-pick 保留 origin commit date

@setlocal
@if not [%1]==[] (
	(git show -s --format=%%ci %1 & echo.)>cherry.log & (set /p GIT_COMMITTER_DATE=)<cherry.log
	git cherry-pick %1
)
@tw-Frey
tw-Frey / git_show_echo_set_variable.md
Created July 11, 2022 14:22
Set output of a command as a variable (with pipes)

我想要

git show -s --format=%ci abcde12344

結果塞入 set variable

因為 command 裡有 %

@tw-Frey
tw-Frey / Draw_Text_in_Deep.md
Created July 11, 2022 12:41
Draw Text in Deep (作者: xuyisheng)

文本测量

文本的测量是非常复杂,因为要适配全球几百种语言不同的排版,除了前面提到的FontMetrics,Android的渲染API还提供了很多测量文本的API。

getFontSpacing()

这个API用于获取推荐的行距。即两行文字间的baseline的距离。

这个值是系统根据文本的字体和字号自动计算的。当你使用drawText一行行绘制文字的时候,可以在换行的时候获取下一行的baseline坐标。

@tw-Frey
tw-Frey / ulmp.md
Created June 29, 2022 04:10
Unified layout margins and padding

Android 8.0 (API level 26) makes it easier for you to specify situations where opposite sides of a View element use the same margin or padding. Specifically, you can now use the following attributes in your layout XML files:

  • layout_marginVertical, which defines layout_marginTop and [layout_marginBottom] at the same time.
  • layout_marginHorizontal, which defines [layout_marginLeft] and [layout_marginRight] at the same time.
  • [paddingVertical], which defines [paddingTop] and [paddingBottom] at the same time.
  • [paddingHorizontal], which defines [paddingLeft] and [paddingRight] at the same time.
@tw-Frey
tw-Frey / applymapping_dontshrink.md
Created June 22, 2022 22:50
當開啟 Proguard/R8 時, 會發生 Android Instrumented Test 無法通過甚至無法執行

問題

當開啟 Proguard/R8 時, 會發生 Android Instrumented Test 無法通過甚至無法執行

解決方案之一

就是在 android buildType debug 裡, 新增以下 Proguard Rule:

-dontshrink