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
1 |
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
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] |
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
- (NSData *)generateWavHeader:(NSUInteger)waveLength { | |
// 定义 WAV 文件的参数 | |
NSUInteger sampleRate = 16000; // 采样率 | |
NSUInteger bitsPerSample = 16; // 采样位数 | |
NSUInteger numChannels = 1; // 声道数(单声道) | |
// 计算数据长度(不包括 WAV 文件头) | |
NSUInteger dataLength = waveLength; // 数据长度(根据实际情况赋值) | |
// 计算文件总长度(包括 WAV 文件头) |
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
// 假设有一个名为 "floatArray" 的 float 数组和 "arrayLength" 表示数组长度 | |
NSString *filePath = @"/path/to/file.wav"; // 指定保存 WAV 文件的路径 | |
// 打开文件用于写入 | |
NSOutputStream *outputStream = [NSOutputStream outputStreamToFileAtPath:filePath append:NO]; | |
[outputStream open]; | |
// 构建 WAV 文件头信息 | |
// WAV 文件头的具体格式请根据需要进行调整,以下示例仅提供基本结构 |
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
extension Sequence where Element: Hashable { | |
func uniqued() -> [Element] { | |
var set = Set<Element>() | |
return filter { set.insert($0).inserted } | |
} | |
} |
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
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, |