Skip to content

Instantly share code, notes, and snippets.

View YuanLiou's full-sized avatar
:octocat:
a museum enthusiast.

Jui Yuan Liu (Ray) YuanLiou

:octocat:
a museum enthusiast.
View GitHub Profile
@YuanLiou
YuanLiou / optimizeVideo.sh
Last active September 17, 2022 12:52
FFMPEG optimize video file
# Optimize mp4
# Usage: optimizeVideo video_file
optimizeVideo() {
ffmpeg -i "${1}" -vcodec h264 -acodec mp2 "${1}".mp4
}
@YuanLiou
YuanLiou / videoToGif.sh
Created September 11, 2022 07:43
FFMPEG convert video to gif
# Convert video to gif file.
# Usage: video2gif video_file (scale) (fps)
video2gif() {
ffmpeg -y -i "${1}" -vf fps=${3:-10},scale=${2:-320}:-1:flags=lanczos,palettegen "${1}.png"
ffmpeg -i "${1}" -i "${1}.png" -filter_complex "fps=${3:-10},scale=${2:-320}:-1:flags=lanczos[x];[x][1:v]paletteuse" "${1}".gif
rm "${1}.png"
}
@YuanLiou
YuanLiou / .zshrc
Last active September 23, 2024 09:49
Ray's zsh config 1.0.2
# Function
function showLogs {
git log --pretty=format:'- %s' --since="$1" --author="$2"
}
# Convert video to gif file.
# Usage: video2gif video_file (scale) (fps)
video2gif() {
ffmpeg -y -i "${1}" -vf fps=${3:-10},scale=${2:-320}:-1:flags=lanczos,palettegen "${1}.png"
ffmpeg -i "${1}" -i "${1}.png" -filter_complex "fps=${3:-10},scale=${2:-320}:-1:flags=lanczos[x];[x][1:v]paletteuse" "${1}".gif
@YuanLiou
YuanLiou / hilt_scope_sample05.kt
Created April 28, 2022 10:52
Hilt Scope Sample 05
@InstallIn(SingletonComponent::class)
@Module
abstract class MyModule {
@Singleton
@Binds
abstract fun bindingFunction(myImpl: MyInterfaceImpl) : MyInterface
}
@YuanLiou
YuanLiou / hilt_scope_sample04.kt
Created April 28, 2022 10:51
Hilt Scope Sample 04
@Module
@InstallIn(SingletonComponent::class)
object NetworkModule {
@Provides
@Singleton
fun provideRetrofit(): Retrofit {
return Retrofit.Builder()
.baseUrl("https://sample.com")
.build()
}
@YuanLiou
YuanLiou / hilt_scope_sample03.kt
Created April 28, 2022 10:51
Hilt Scope Sample 03
@Module
@InstallIn(SingletonComponent::class)
object NetworkModule {
@Provides
fun provideRetrofit(): Retrofit {
return Retrofit.Builder()
.baseUrl("https://sample.com")
.build()
}
}
@YuanLiou
YuanLiou / hilt_scope_sample02.kt
Created April 28, 2022 10:50
Hilt scope sample 02
@Singleton
class MyCustomManager @Inject constructor() {
// 省略內容
}
@YuanLiou
YuanLiou / hilt_scope_sample.kt
Created April 28, 2022 10:49
hilt scope sample
class MyCustomManager @Inject constructor() {
// 省略內容
}
@YuanLiou
YuanLiou / .ideavimrc
Last active January 11, 2025 02:03
Ray's Ideavim Settings 1.6
let mapleader = "\<space>"
" set clipboard=unnamed
" set clipboard=unnamedplus
" set clipboard=unnamed,unnamedplus
" Plugins
set highlightedyank
set NERDTree
set surround
@YuanLiou
YuanLiou / HandleEvent.kt
Created February 2, 2021 16:18
HandleEventWithViewEffect
override fun onCreate(savedInstanceStates: Bundle?) {
viewModel.viewEffectPublisher.observe(this, Observer<Event<ViewEffect>> { event ->
event.getContentIfNotHandled()?.let {
handleViewEffects(it)
}
})
}
private fun handleViewEffects(viewEffect: ViewEffect) {
when (viewEffect) {