Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# 取得 grubby --info DEFAULT 的輸出
grubby_info=$(grubby --info DEFAULT)
# 使用 grep 和 awk 抓取 args 中的 swap 相關參數
swap_args=$(echo "$grubby_info" | grep 'args=' | awk -F'"' '{print $2}' | grep -oE 'resume=[^ ]+|rd.lvm.lv=[^ ]+/swap')
# 檢查是否找到 swap 參數
if [[ -z "$swap_args" ]]; then
@j796160836
j796160836 / kubernetes_alias.md
Created October 3, 2024 02:35
kubernetes_alias.md

Kubernetes (K8s) useful alias

alias k=kubectl
alias kd="kubectl describe "
alias kg="kubectl get "
alias kgps="kubectl get pod,svc"
alias kgpp="kubectl get pvc,pv"
@j796160836
j796160836 / upload.sh
Created May 10, 2024 07:20
Upload file to Alist
#!/bin/bash
export HTTP_PROXY=http://192.168.1.3:3128
export HTTPS_PROXY=$HTTP_PROXY
export NO_PROXY="localhost, 127.0.0.1"
domain='https://YOUR_SERVER_IP'
token='xxxxxxxxxx'
file=$1
@j796160836
j796160836 / download_docker_images.sh
Last active October 1, 2024 01:58
download all docker images from list
#!/bin/bash
docker_images=(
"nginx:latest"
)
for image in "${docker_images[@]}"; do
echo "Downloading $image ..."
echo
image_name=${image##*/}
@j796160836
j796160836 / Tree.kt
Last active December 11, 2022 13:46
Tree.kt
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Path
import androidx.compose.ui.graphics.drawscope.DrawScope
@j796160836
j796160836 / ffmpeg_mkv_mp4_conversion.md
Last active January 31, 2022 01:03 — forked from jamesmacwhite/ffmpeg_mkv_mp4_conversion.md
Easy way to convert MKV to MP4 with ffmpeg

Converting mkv to mp4 with ffmpeg

Essentially just copy the existing video and audio stream as is into a new container, no funny business!

The easiest way to "convert" MKV to MP4, is to copy the existing video and audio streams and place them into a new container. This avoids any encoding task and hence no quality will be lost, it is also a fairly quick process and requires very little CPU power. The main factor is disk read/write speed.

With ffmpeg this can be achieved with -c copy. Older examples may use -vcodec copy -acodec copy which does the same thing.

These examples assume ffmpeg is in your PATH. If not just substitute with the full path to your ffmpeg binary.

Single file conversion example

@j796160836
j796160836 / DelegateDispatcher.md
Created September 24, 2019 17:56
DelegateDispatcher

DelegateDispatcher

Create an interface to receive delegate callback and dispatch to muitpule observer instances.

Usage

For example, we create an delegate called MyClassDelegate.

protocol MyClassDelegate {
@j796160836
j796160836 / RemoveWin10PreInstallApps.ps1
Created August 7, 2019 03:34
Remove Win10 unused pre installed apps (Run it with Windows PowerShell (Admin))
# Run with Windows PowerShell (Admin)
# https://www.thewindowsclub.com/remove-built-windows-10-apps-users-using-powershell-script
Get-AppxPackage *3dbuilder* | Remove-AppxPackage
Get-AppxPackage *officehub* | Remove-AppxPackage
Get-AppxPackage *getstarted* | Remove-AppxPackage
Get-AppxPackage *skypeapp* | Remove-AppxPackage
@j796160836
j796160836 / Gatekeeper_issue.md
Last active December 3, 2018 15:38
Gatekeeper issue.md

[LockedApp] can’t be opened because it is from an unidentified developer. Your security preferences allow installation of only apps from the App Store and identified developers.

This is actually a macOS Gatekeeper issue try these steps:

To resolute Gatekeeper issues on macOS Sierra you might have to partially or completely disable Gatekeeper checks.

Option I For a certain application run in Terminal: