This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
let strs = ["hello world", "1", "hello", "world"]; | |
let mut remaining: &[&str] = &strs; | |
while let [current, tail @ ..] = remaining { | |
println!("{} - {:?}", current, tail); | |
remaining = tail; | |
} | |
println!("The real strs {:?}", strs); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
before_script: | |
- "command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )" | |
- eval $(ssh-agent -s) | |
- chmod 400 "$SSH_PRIVATE_KEY" | |
- ssh-add "$SSH_PRIVATE_KEY" | |
- mkdir -p ~/.ssh | |
- chmod 700 ~/.ssh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"hosts": ["tcp://0.0.0.0:2375", "unix:///var/run/docker.sock"], | |
"insecure-registries" : ["192.168.1.57:8004"], | |
"data-root": "/home/xfy/data/docker-var" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use axum::{ | |
async_trait, | |
extract::{rejection::FormRejection, FromRequest, Request}, | |
Form, Json, | |
}; | |
use once_cell::sync::Lazy; | |
use regex::Regex; | |
use serde::de::DeserializeOwned; | |
use validator::Validate; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::sync::OnceLock; | |
use jsonwebtoken::{DecodingKey, EncodingKey, Header}; | |
use serde::{Deserialize, Serialize}; | |
pub struct Keys { | |
pub encoding: EncodingKey, | |
pub decoding: DecodingKey, | |
} | |
impl Keys { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use anyhow::{anyhow, Context}; | |
use tokio::task; | |
use argon2::password_hash::SaltString; | |
use argon2::{password_hash, Argon2, PasswordHash, PasswordHasher, PasswordVerifier}; | |
/// 生成 hash | |
/// | |
/// ## Arguments | |
/// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::{collections::HashMap, time::Duration}; | |
use axum::{ | |
async_trait, | |
body::Bytes, | |
extract::{FromRequestParts, MatchedPath, Path, Request}, | |
http::{request::Parts, HeaderMap, StatusCode, Uri}, | |
middleware, | |
response::{IntoResponse, Response}, | |
routing::get, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 根据 key 删除 url 中 hash 中的指定 query | |
* | |
* #/?booth_id=Ep3wmDXbjk2&code=041Cax100CXyaS1mjI1005Tw1E3Cax1N | |
* | |
* @param hash url 中的 hash | |
* @param deleteKey 需要删除的 query 的 key | |
*/ | |
export function removeHash(hash: string, deleteKey: string) { | |
if (hash.length < 3) return; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 按间隔更新数字,数字增长的动画。 | |
* | |
* @param start 动画开始的值 | |
* @param end 动画最后结束的值 | |
* @param updateFn 更新值状态的方法 | |
* @param duration 动画总时长 | |
* @param setpDuration 每次更新的间隔 | |
* @param precision 数字精度 | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct ByteIter<'remainder> { | |
remainder: &'remainder [u8], | |
} | |
/* impl<'remainder> ByteIter<'remainder> { | |
fn next(&mut self) -> Option<&'remainder u8> { | |
if self.remainder.is_empty() { | |
None | |
} else { | |
let byte = &self.remainder[0]; |
NewerOlder