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 / versionName
Created December 4, 2017 02:55
自己習慣的 versionName 格式
versionName String.format("%.0f.%d", versionCode / 16 + 0.49, (versionCode + 15) % 16)
在 String.format 的 %.0f 會把 1.5 四捨五入 為 2.0
(但 17/16+0.4 轉 %.0f 還是 1 ?!)
P.S. 17/16 = 1.0625
@tw-Frey
tw-Frey / outputFileName
Created December 4, 2017 18:11
Use static build config values with your debug build
/*
Ref:
https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html#variant_output
https://developer.android.com/studio/build/optimize-your-build.html#use_static_build_properties
*/
android {
// If you use each() to iterate through the variant objects,
// you need to start using all(). That's because each() iterates
// through only the objects that already exist during configuration time—
// but those object don't exist at configuration time with the new model.
@tw-Frey
tw-Frey / layoutFlag
Created December 10, 2017 20:32
各種樣式 Flag 的使用記錄
1. default
/* 系統預設樣式 */
2. use SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN|SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
/* 在 Android 5.x 切換 theme 可能會有殘影 */
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
);
@tw-Frey
tw-Frey / jquery-ajax-blob-arraybuffer.js
Created July 5, 2018 22:36 — forked from SaneMethod/jquery-ajax-blob-arraybuffer.js
Ajax transports to allow the sending/receiving of blobs and array buffers via the familiar jquery ajax function.To send, set data to the blob or arraybuffer to be sent, and add 'processData:false' to the ajax options.To receive, specify the 'dataType' as blob or arraybuffer in the ajax options.
(function($){
/**
* Register ajax transports for blob send/recieve and array buffer send/receive via XMLHttpRequest Level 2
* within the comfortable framework of the jquery ajax request, with full support for promises.
*
* Notice the +* in the dataType string? The + indicates we want this transport to be prepended to the list
* of potential transports (so it gets first dibs if the request passes the conditions within to provide the
* ajax transport, preventing the standard transport from hogging the request), and the * indicates that
* potentially any request with any dataType might want to use the transports provided herein.
*
@tw-Frey
tw-Frey / ffmpeg_slideshow
Created July 9, 2018 03:20
FFMpeg do SlideShow
原始影片→每5秒小圖(160x90)
ffmpeg -i 影片檔名.mp4 -vf "fps=1/5,scale=160:90" preview%04d.jpg
眾小圖→slideshow video
ffmpeg -framerate 1 -i preview%04d.jpg -vf fps=1 -x264-params keyint=1:min-keyint=1:scenecut=-1 preview.mp4
@tw-Frey
tw-Frey / Git Cache Strategies
Created July 11, 2018 06:23
Git Cache Strategies
Glide 3.x & 4.x: DiskCacheStrategy.NONE caches nothing
Glide 4.x: DiskCacheStrategy.DATA, Glide 3.x: DiskCacheStrategy.SOURCE caches only the original full-resolution image.
Glide 4.x: DiskCacheStrategy.RESOURCE Glide 3.x: DiskCacheStrategy.RESULT caches only the final image, after reducing the resolution (and possibly transformations) (default behavior of Glide 3.x)
Glide 4.x only: DiskCacheStrategy.AUTOMATIC intelligently chooses a cache strategy based on the resource (default behavior of Glide 4.x)
Glide 3.x & 4.x: DiskCacheStrategy.ALL caches all versions of the image
Further Read:
https://futurestud.io/tutorials/glide-caching-basics
@tw-Frey
tw-Frey / Name-Deprecated-Gradle-5.0
Created July 31, 2018 11:52
The project name contains at least one of the following characters: [ , /, \, :, <, >, ", ?, *, |]. This has been deprecated and is scheduled to be removed in Gradle 5.0.
The project name contains at least one of the following characters: [ , /, \, :, <, >, ", ?, *, |].
This has been deprecated and is scheduled to be removed in Gradle 5.0. Set the 'rootProject.name' or
adjust the 'include' statement.
see for more details:
https://docs.gradle.org/4.4/dsl/org.gradle.api.initialization.Settings.html#org.gradle.api.initialization.Settings:include(java.lang.String[])
@tw-Frey
tw-Frey / .gitignore
Last active October 12, 2018 09:45
習慣的 .gitignore
# Created by .ignore support plugin (hsz.mobi)
### Android Studio ################################################################################
captures
### Eclipse template ##############################################################################
*.pydevproject
.metadata
.gradle
bin/
tmp/
@tw-Frey
tw-Frey / $DFD_Observer.js
Created November 9, 2018 07:46
私作 Deferred 功能
const $DFD_Observer = (($, START_CALLBACK, FINISH_CALLBACK) => {
let Func_Faked = func => () => typeof (func) == "function" && func() || true;
let $DFD_Faked = $.Deferred().resolve()
let $DFD_Array = [];
return $dfd => {
$DFD_Array = $DFD_Array.filter($item => $item.state && $item.state() == "pending").concat($dfd || $DFD_Faked);
$.when($.Deferred(Func_Faked(START_CALLBACK)).resolve(), ...$DFD_Array)
.always(() => $DFD_Array.length <= 1 && $DFD_Array[0] == $DFD_Faked && Func_Faked(FINISH_CALLBACK)() || $DFD_Observer());
return $dfd;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.