Skip to content

Instantly share code, notes, and snippets.

View hoishing's full-sized avatar
🚀

Kelvin Ng hoishing

🚀
View GitHub Profile
@hoishing
hoishing / get-finder-items.applescript
Last active March 18, 2024 04:57
Raycast Scripts
#!/usr/bin/osascript
tell application "Finder"
set selectedItems to selection
set itemList to ""
repeat with anItem in selectedItems
set itemList to itemList & POSIX path of (anItem as alias) & "\n"
end repeat
return itemList
end tell
@hoishing
hoishing / HowTo.md
Last active June 18, 2024 20:44
VSCode keybindings for Xcode

VSCode keybindings for Xcode

  • copy VSCode.idekeybindings to ~/Library/Developer/Xcode/UserData/KeyBindings
  • in Xcode preferences -> key bindings, select VSCode
@hoishing
hoishing / index.html
Last active November 12, 2021 12:07
TradingView_figures
<!-- TradingView Widget BEGIN -->
<div class="tradingview-widget-container">
<div id="tradingview_01ba8"></div>
<div class="tradingview-widget-copyright"><a href="https://www.tradingview.com/symbols/BINANCE-ATOMUSDT/" rel="noopener" target="_blank"><span class="blue-text">ATOMUSDT Chart</span></a> by TradingView</div>
<script type="text/javascript" src="https://s3.tradingview.com/tv.js"></script>
<script type="text/javascript">
new TradingView.widget(
{
"autosize": true,
"symbol": "BINANCE:ATOMUSDT",
@hoishing
hoishing / blog.md
Last active November 26, 2022 13:20
Using Javascript with WKWebView

Using Javascript with WKWebView

Harnessing The Power of Both Languages in Your Apps

WebKit allows us to use javascript along side with the native swift code. On one hand, we could call the javascript statements in swift. On the other hand, javascript from web view could be able to trigger a delegate method defined in swift code. This gives us a two way communication between the native swift code and javascript used by a web view.

Basic Setup

Here we have a window with a WKWebView showing some text. It has 2 buttons inside. One for showing the text and triggering a swift handler, the other for hiding the text. Also, we have a native button that triggers a javascript function to hide the text.

@hoishing
hoishing / sample.swift
Last active November 26, 2022 13:23
Adding Login Items for macOS
func applicationDidFinishLaunching(_ aNotification: Notification) {
let runningApps = NSWorkspace.shared.runningApplications
let isRunning = runningApps.contains {
$0.bundleIdentifier == "your.domain.TestAutoLaunch"
}
if !isRunning {
var path = Bundle.main.bundlePath as NSString
for _ in 1...4 {
path = path.deletingLastPathComponent as NSString
@hoishing
hoishing / menuBarApps.swift
Last active November 26, 2022 13:22
Menu Bar Apps
//strong reference to retain the status bar item object
var statusItem: NSStatusItem?
func applicationDidFinishLaunching(_ aNotification: Notification) {
statusItem = NSStatusBar.system().statusItem(withLength: -1)
guard let button = statusItem?.button else {
print("status bar item failed. Try removing some menu bar item.")
NSApp.terminate(nil)
return