Skip to content

Instantly share code, notes, and snippets.

@TBXark
TBXark / update-ui.py
Created May 14, 2024 07:20
Update PVE UI
#!/usr/bin/env python3
import os
import datetime
backup_folder = "/root/backup"
def read_file(file_path):
try:
with open(file_path, 'r') as file:
@TBXark
TBXark / 伪元素.md
Created November 28, 2023 06:32
CSS笔记
伪元素 作用 使用场景 示例
::after 在元素内容之后插入内容 添加装饰性内容,如图标、边框 p::after { content: "★"; }
::before 在元素内容之前插入内容 添加装饰性内容,如图标、边框 p::before { content: "★"; }
::first-letter 选择第一个字母 首字下沉,字体样式变化 p::first-letter { font-size: 200%; }
::first-line 选择第一行文本 改变段落的第一行文本样式 p::first-line { color: blue; }
::selection 定制用户选中文本的样式 更改选中文本的颜色和背景 p::selection { color: white; background: black; }
::placeholder 定制输入字段的占位符文本样式 改变输入框占位符的样式 input::placeholder { color: grey; }
::marker 定制列表项标记的样式 改变列表项目符号的样式 li::marker { color: red; }
@TBXark
TBXark / jsdoc.js
Created May 12, 2023 09:00
JSdoc生成器
function generateJSDoc(obj, prefix = '') {
const jsdocComment = (name, type) => {
return ` * @property {${type}} ${name}`;
};
const walkObj = (childObj, childPrefix) => {
let jsdocStr = '';
for (let key in childObj) {
if (!Object.prototype.hasOwnProperty.call(childObj, key)) {
continue;
@TBXark
TBXark / init.sh
Last active May 5, 2023 07:00
SDWebUI
#wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
#sh Miniconda3-latest-Linux-x86_64.sh
#source .bashrc
#export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CONDA_PREFIX/lib/
conda create -n sbweb python=3.10
conda activate sbweb
apt install nvidia-cuda-toolkit
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
cd stable-diffusion-webui/
git clone https://github.com/camenduru/sd-civitai-browser ./extensions/sd-civitai-browser
/// https://developers.cloudflare.com/workers/
addEventListener("fetch", event => {
event.respondWith(handleRequest(event.request))
})
async function handleRequest(request) {
// https://example.com/author/repo/name.podspec?xxx=xxx
const url = new URL(request.url)
const [, author, repo, name] = url.pathname.split(/[\./]/g)
@TBXark
TBXark / goroutine.go
Created November 6, 2021 08:37
Safe goroutine
func Go(f func()) {
go func() {
defer func() {
if err := recover(); err != nil {
fmt.Println("Recover:", err)
}
}()
f()
}()
}
@TBXark
TBXark / try.go
Last active January 25, 2021 07:35
try.go
package tryCatch
//https://www.cnblogs.com/beiluowuzheng/p/10263724.html
import (
"reflect"
)
type CatchHandler interface {
Catch(e error, handler func(err error)) CatchHandler
@TBXark
TBXark / CenterAlignmentFlowLayout.swift
Created August 21, 2017 04:29
CenterAlignmentFlowLayout
//
// CenterAlignmentFlowLayout.swift
// Play
//
// Created by Tbxark on 15/12/28.
// Copyright © 2015年 TBXark. All rights reserved.
//
import UIKit
@TBXark
TBXark / Find all locations of substring in NSString
Last active November 20, 2016 16:14
Find all locations of substring in NSString
extension NSString {
func rangesOfSubString(_ string: String) -> [NSRange] {
var searchRange = NSMakeRange(0, length)
var searchResult = [NSRange]()
while searchRange.location < length {
searchRange.length = length - searchRange.location
let foundRange = range(of: string, options: [], range: searchRange)
if foundRange.location != NSNotFound {
searchResult.append(foundRange)
searchRange.location = foundRange.location+foundRange.length