Skip to content

Instantly share code, notes, and snippets.

View kaaaaai's full-sized avatar
🎯
Focus on technology and love

Kaaaaai kaaaaai

🎯
Focus on technology and love
View GitHub Profile
@kaaaaai
kaaaaai / gist:7e2532e6db0add49911736afa32e29e0
Created July 4, 2024 11:13
🗓 Weekly development breakdown
1
@kaaaaai
kaaaaai / mask_email.dart
Created April 15, 2024 07:39 — forked from roipeker/mask_email.dart
Mask Email RegExp for Dart
import 'dart:math';
void testMaskEmail() {
final emails = [
'[email protected]',
// output: a****[email protected]
'[email protected]',
// output: a****[email protected]
'[email protected]',
// output: a****[email protected]
@kaaaaai
kaaaaai / WaveHeaderGenerator.m
Created August 14, 2023 12:43
wave 文件头创建
- (NSData *)generateWavHeader:(NSUInteger)waveLength {
// 定义 WAV 文件的参数
NSUInteger sampleRate = 16000; // 采样率
NSUInteger bitsPerSample = 16; // 采样位数
NSUInteger numChannels = 1; // 声道数(单声道)
// 计算数据长度(不包括 WAV 文件头)
NSUInteger dataLength = waveLength; // 数据长度(根据实际情况赋值)
// 计算文件总长度(包括 WAV 文件头)
// 假设有一个名为 "floatArray" 的 float 数组和 "arrayLength" 表示数组长度
NSString *filePath = @"/path/to/file.wav"; // 指定保存 WAV 文件的路径
// 打开文件用于写入
NSOutputStream *outputStream = [NSOutputStream outputStreamToFileAtPath:filePath append:NO];
[outputStream open];
// 构建 WAV 文件头信息
// WAV 文件头的具体格式请根据需要进行调整,以下示例仅提供基本结构
@kaaaaai
kaaaaai / gist:b4b6c36e9c2177511999431c4b1e5a74
Created November 4, 2021 07:30
swift.extension.数组去重
extension Sequence where Element: Hashable {
func uniqued() -> [Element] {
var set = Set<Element>()
return filter { set.insert($0).inserted }
}
}
@kaaaaai
kaaaaai / keyboardObserve.swift
Last active August 14, 2023 06:44
swift.UI.监听键盘高度变化
class MyViewController: UIViewController {
// This constraint ties an element at zero points from the bottom layout guide
@IBOutlet var keyboardHeightLayoutConstraint: NSLayoutConstraint?
override func viewDidLoad() {
super.viewDidLoad()
NotificationCenter.default.addObserver(self,
selector: #selector(self.keyboardNotification(notification:)),
name: UIResponder.keyboardWillChangeFrameNotification,