This file contains hidden or 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
#!/bin/zsh | |
# 检查 Ollama 是否已安装 | |
if ! command -v ollama &> /dev/null; then | |
echo "错误: Ollama 未安装" | |
exit 1 | |
fi | |
# 函数:显示带颜色的消息 | |
print_message() { |
This file contains hidden or 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
#!/bin/zsh | |
# 检查是否提供了目录路径参数 | |
if [ $# -eq 0 ]; then | |
echo "用法: $0 <目录路径>" | |
exit 1 | |
fi | |
# 获取目录路径 | |
project_dir=$1 |
This file contains hidden or 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
@IBAction func printHello(_ sender: Any) { | |
// 队列,以消息绑定为例 | |
if shouldWaitSwitch.isOn { | |
while true { | |
let isSuccess = WaitingTaskQueue.append(task: "你好!") | |
if isSuccess { break } else { continue } | |
} | |
if let _ = shouldWaitSwitch.actions(forTarget: WaitingTaskQueue.self, forControlEvent: .valueChanged) { // already set | |
return |
This file contains hidden or 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
@IBAction func printHello(_ sender: Any) { | |
// 消息绑定 | |
if shouldWaitSwitch.isOn { | |
if let _ = shouldWaitSwitch.actions(forTarget: self, forControlEvent: .valueChanged) { // already set | |
return | |
} | |
shouldWaitSwitch.addTarget(self, action: #selector(printHello(_:)), for: .valueChanged) | |
} | |
else { |
This file contains hidden or 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
@IBAction func printHello(_ sender: Any) { | |
// 延迟 | |
if shouldWaitSwitch.isOn { | |
Timer.scheduledTimer(withTimeInterval: 0.5, repeats: true, block: { [unowned self] (timer) in | |
if self.shouldWaitSwitch.isOn { return } | |
print("你好!") | |
timer.invalidate() | |
}) | |
} |
This file contains hidden or 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
@IBAction func printHello(_ sender: Any) { | |
// 忙等待 | |
DispatchQueue(label: "default").async { | |
while true { | |
if self.shouldWaitSwitch.isOn { continue } | |
print("你好!") | |
break | |
} | |
} |
This file contains hidden or 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
func userDefaultsDidChange() { | |
guard let controller = tableViewController else { return } | |
let progressIndicator = { () -> NSProgressIndicator in | |
let frame = view.frame | |
let x = (frame.width - 50) / 2 | |
let y = (frame.height - 50) / 2 | |
let piFrame = NSMakeRect(x, y, 50, 50) | |
let pi = NSProgressIndicator(frame: piFrame) | |
pi.style = .spinningStyle |
This file contains hidden or 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
var rawFilenames = [String]() | |
// instance counter | |
var timer:NSTimer! = nil | |
func application(sender: NSApplication, openFiles filenames: [String]) { | |
if shouldQuitAppAfterConvert == nil { | |
shouldQuitAppAfterConvert = true | |
} | |
if timer != nil { | |
timer.invalidate() |
This file contains hidden or 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 TableViewController: NSViewController, NSTableViewDelegate { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Do view setup here. | |
run() | |
DispatchQueue.main.asyncAfter(wallDeadline: .now() + .milliseconds(100)) { [unowned self] () -> () in | |
NotificationCenter.default.post(name: TableViewControllerDidAppear, object: self) | |
} | |
} | |
NewerOlder