Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# Ensure DIR is set
if [ -z "$1" ]; then
echo "Error: No directory path provided."
exit 1
fi
TARGET_PATH="$1"
@zty5678
zty5678 / page.tsx
Created February 22, 2025 07:26
nextjs grid demo
import Head from 'next/head'
import React from 'react';
const StaggeredGrid = () => {
const items = Array(8).fill(null);
return (
<div className="w-full max-w-6xl mx-auto">
<div className="grid grid-cols-4 gap-10">
@zty5678
zty5678 / demo_new_version_card.dart
Created September 12, 2024 18:13
flutter new version card demo
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
/// ui design from: https://x.com/vgruev/status/1833163266974961999
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@zty5678
zty5678 / SnackbarController.kt
Created August 5, 2024 02:34 — forked from krizzu/SnackbarController.kt
Hassle-free Snackbar in Jetpack Compose - article at https://www.kborowy.com/blog/easy-compose-snackbar/
import androidx.compose.material3.SnackbarDuration
import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.SnackbarResult
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.Immutable
import androidx.compose.runtime.ReadOnlyComposable
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
@zty5678
zty5678 / clean_zip_file.sh
Created July 2, 2024 14:10
clean .DS_Store and __MACOSX in zip file on Mac
#!/bin/bash
for f in "$@"
do
# 获取文件类型,以确保是 Zip 压缩文件
fileType=$(file -bI "$f")
echo "fileType= $fileType"
if [[ $fileType =~ application/zip.* ]]; then
# 删除 __MACOSX 与 .DS_Store 文件
zip -d "$f" \*__MACOSX\* || true
@zty5678
zty5678 / jetpack compose common import.kt
Created April 19, 2024 03:20
jetpack compose common import statements
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.graphics.drawscope.*
import androidx.compose.animation.core.*
import androidx.compose.foundation.*
import androidx.compose.foundation.gestures.*
import androidx.compose.foundation.interaction.*
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.*
import androidx.compose.foundation.lazy.grid.*
import androidx.compose.foundation.shape.*
@zty5678
zty5678 / DemoKMPBlur
Created April 10, 2024 15:23
A demo of blur for Jetpack Compose Desktop
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.GenericShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
@zty5678
zty5678 / rust_log_utils_demo.rs
Last active March 23, 2024 07:39
Rust Log Utils, use to print line number in console output. (Only tested in RustRover )
mod utils_log;
fn main() {
utils_log::log("hello world");
}
@zty5678
zty5678 / DuolingoButton.kt
Last active March 26, 2024 15:48
compose实现Duolingo按钮效果
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.collectIsPressedAsState
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Surface
@zty5678
zty5678 / Mac 编译 java 版本 gdal 3.8.3.txt
Last active May 13, 2025 03:19
Mac 编译 java 版本 gdal 3.8.3
参考博客:https://www.cnblogs.com/echohye/p/17580078.html
1. 下载源码
version=3.8.3
wget http://download.osgeo.org/gdal/$version/gdal-$version.tar.xz
2. 编译。解压,执行:
cmake -S . -B build \
-DCMAKE_INSTALL_RPATH=/opt/gdal \