Skip to content

Instantly share code, notes, and snippets.

rename file names with 5-digit order(index) numbers only, padded with zeros, not perserve origin name. note:
1. response the mapping result in JSON format only, no code no explain and chat content.
2. using original file names as keys and renamed file names as values.
fileNames: ["templateAnimLeftFade.zip","templateAnimRightFade.zip","templateAnimScanLine.zip"]
@zyc945
zyc945 / gist:5da658b10ec5a293243aaf9497354339
Last active February 21, 2024 17:20
a rename to digits prompt
rename file names with 5-digit order(index) numbers only, padded with zeros, not perserve origin name. note:
1. response the mapping result in JSON format only, no code no explain and chat content.
2. using original file names as keys and renamed file names as values.
@zyc945
zyc945 / shell-setup.sh
Created March 1, 2023 02:13 — forked from MartinHarding/shell-setup.sh
Setup Oh My Zsh and PowerLevel10k
#!/bin/zsh
set -e
if [ -d "$HOME/.oh-my-zsh" ]; then
echo "Oh My ZSH is installed"
else
echo "Download and install Oh My ZSH before running this script"
echo 'sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"'
exit 1
fi
@zyc945
zyc945 / gist:596190e57229a854ba34b4be34301917
Created February 3, 2021 02:45 — forked from pwlin/gist:8a0d01e6428b7a96e2eb
Android : add cert to system store
https://code.google.com/p/android/issues/detail?id=32696#c5
If you have a certificate that is not
trusted by Android, when you add it, it goes in the personal cert store.
When you add a cert in this personal cert store, the system requires a
higher security level to unlock the device. But if you manage to add your
cert to the system store then you don't have this requirement. Obviously,
root is required to add a certificate to the system store, but it is quiet
easy.
import groovy.json.JsonOutput
def android = project.extensions.android
def list = new ArrayList<>()
afterEvaluate {
android.applicationVariants.all { variant ->
def variantName = variant.name.capitalize()
def variantOutput = variant.outputs.first()
def path = variantOutput.getOutputFile().path
def flavorList = variant.productFlavors
@zyc945
zyc945 / NetStateObserver
Last active April 21, 2020 06:19
net connect state observer
package zyc.android.utils
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.net.ConnectivityManager
import android.net.ConnectivityManager.CONNECTIVITY_ACTION
import android.net.Network
import android.os.Build
@zyc945
zyc945 / gist:1953b3fe0270e531367ea2880084d1aa
Created April 21, 2020 06:07
report google play service status.
fun reportGooglePlayServiceStatus(context: Context) {
when (GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context)) {
ConnectionResult.SUCCESS -> "success"
ConnectionResult.SERVICE_MISSING -> "service_missing"
ConnectionResult.SERVICE_UPDATING -> "service_updating"
ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED -> "service_version_update_required"
ConnectionResult.SERVICE_DISABLED -> "service_disabled"
ConnectionResult.SERVICE_INVALID -> "service_invalid"
else -> "unknown"
}.let { result ->
public static boolean checkPermission(Context context, String permission) {
boolean result = false;
if (Build.VERSION.SDK_INT >= 23) {
try {
Class<?> clazz = Class.forName("android.content.Context");
Method method = clazz.getMethod("checkSelfPermission", String.class);
int rest = (Integer) method.invoke(context, permission);
if (rest == PackageManager.PERMISSION_GRANTED) {
result = true;