Skip to content

Instantly share code, notes, and snippets.

@icai
icai / CuSwitch.kt
Last active May 22, 2024 15:16
CuSwitch.kt
@Composable
private fun CuSwitch(
modifier: Modifier = Modifier,
checked: MutableState<Boolean> = remember { mutableStateOf(false) },
onCheckedChange: (Boolean) -> Unit = {}
) {
val width = 34.dp
val height = 19.dp
val gapBetweenThumbAndTrackEdge = 2.dp
#!/bin/bash
branch=$(git rev-parse --abbrev-ref HEAD)
# echo "Enter the first commit hash:"
# read commit1
# echo "Enter the second commit hash:"
# read commit2
@icai
icai / appx-web-view-format.js
Last active April 12, 2024 06:23
支付宝 appx/web-view.js 源代码
/*!
*
* ap/v1.25.9
* Mon Jun 20 2022 08:37:45 GMT+0000 (Coordinated Universal Time)
*
*/
var myApp = (function (modules) {
var moduleCache = {};
function require(moduleId) {
@icai
icai / readDir.js
Created March 20, 2024 03:48
scan directory and show list
const fs = require('fs')
const path = require('path')
function readDir(dir, extFilter) {
let fileList = []
// Function to recursively read directories
function readDirectoryRecursive(directory) {
// Read the directory
fs.readdir(directory, (err, files) => {
@icai
icai / diff-branch.sh
Created January 10, 2024 04:05
git diff two branches change
#!/bin/bash
max_log_entries=30
# Get the list of branches
branches=$(git for-each-ref --sort='-committerdate:iso8601' --format '%(refname:short)' refs/heads/)
# Display branch list for user selection
PS3="Select two branches for file changes: "
@icai
icai / diff.sh
Created January 9, 2024 13:10
Git File Diff Script
#!/bin/bash
branch=$(git rev-parse --abbrev-ref HEAD)
# echo "Enter the first commit hash:"
# read commit1
# echo "Enter the second commit hash:"
# read commit2
@icai
icai / cloudflare-ddns-update.sh
Created January 5, 2024 12:18 — forked from Tras2/cloudflare-ddns-update.sh
A bash script to update a Cloudflare DNS A record with the external IP of the source machine
#!/bin/bash
# A bash script to update a Cloudflare DNS A record with the external IP of the source machine
# Used to provide DDNS service for my home
# Needs the DNS record pre-creating on Cloudflare
# Proxy - uncomment and provide details if using a proxy
#export https_proxy=http://<proxyuser>:<proxypassword>@<proxyip>:<proxyport>
# Cloudflare zone is the zone which holds the record
@icai
icai / fetch.js
Created September 14, 2023 12:38
fetch file content to local
const fs = require('fs')
const path = require('path')
const https = require('https')
const url = require('url')
// Function to fetch a file from a server and save it locally
async function fetchAndSaveFile(url, localFilePath) {
// mkdir -p localFilePath
const dirname = path.dirname(localFilePath)
if (!fs.existsSync(dirname)) {
@icai
icai / translate.js
Created March 7, 2023 02:50
chatgpt GPT3 Translates Text.
const axios = require('axios');
class Base {
constructor(key, language, apiBase = null) {
this.key = key;
this.language = language;
this.currentKeyIndex = 0;
}
getKey(keyStr) {
@icai
icai / tree.js
Last active September 15, 2023 03:57
miniprogram pages csv with title
// out put current directory tree
const fs = require('fs')
const path = require('path')
function outPageTitle() {
const appjson = fs.readFileSync('./app.json', 'utf8')
const appjsonObj = JSON.parse(appjson)
const pages = appjsonObj.pages.concat(
...appjsonObj.subPackages.map((item) => {