Skip to content

Instantly share code, notes, and snippets.

@amiorin
amiorin / README.md
Last active April 25, 2024 21:54
How to configure Home Row Mods with KMonad on macOS

Intro

Karabiner and KMonad are great open source software. Don't forget to support the authors and contributors.

If you want to try home row mods on OSX, don't use Karabiner but KMonad. KMonad is harder at the beginning but then it is easier than Karabiner. Creating layers in KMonad is trivial and without drawbacks, while it is impossible in Karabiner without drawbacks.

You need to compile a PR of the project. Install https://github.com/pqrs-org/Karabiner-DriverKit-VirtualHIDDevice/releases/download/v2.1.0/Karabiner-DriverKit-VirtualHIDDevice-2.1.0.pkg

@czottmann
czottmann / Format current file with swiftformat.scpt
Last active December 30, 2022 19:04
Xcode helper: SwiftFormat the currently focussed doc w/o losing undo history
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
-- # This script formats the currently open and focussed Swift file
-- # using SwiftFormat. It does so *without* resetting the editor's
-- # undo history.
-- #
-- # Version 2022-12-30.01
-- #
-- # Author: Carlo Zottmann
@Evian-Zhang
Evian-Zhang / find_sdk_root.sh
Created June 15, 2022 09:03
Proper way to handle "ld: library not found for -lSystem" in macOS
SDKROOT=`/usr/bin/xcrun --show-sdk-path -sdk macosx`
as test.s -o test.o
ld test.o -lSystem -L $(SDKROOT)/usr/lib -o test
@humblehacker
humblehacker / kotlin-inject-composable-viewmodel.md
Last active March 17, 2022 13:56
Injecting view models into Composable functions with kotlin-inject

According to the docs, the non-DI way to associate an view model with an @Composable is via the viewModel() function from androidx.lifecycle.viewmodel.compose.viewModel, like this:

@Composable
fun ProfileScreen(val viewModel: ProfileViewModel = viewModel() {
  ...

But if your view model requires dependencies, you have to pass a subclass of ViewModelProvider.Factory that holds the dependency and knows how to construct the view model for you. Like this:

@hmlongco
hmlongco / Themes.swift
Last active January 10, 2023 06:54
Themes for SwiftUI
struct Colors {
let primary: Color
}
struct Fonts {
let body: Font
}
class Theme: ObservableObject {
let color: Colors
@Amzd
Amzd / View+NSCursor.swift
Last active February 9, 2024 17:34
Set the cursor that is displayed when hovering a View. (macOS, SwiftUI)
import SwiftUI
extension View {
/// https://stackoverflow.com/a/61985678/3393964
public func cursor(_ cursor: NSCursor) -> some View {
self.onHover { inside in
if inside {
cursor.push()
} else {
NSCursor.pop()
@chriseidhof
chriseidhof / boilerplate.swift
Last active January 3, 2024 05:54
QuickMacApp
// Run any SwiftUI view as a Mac app.
import Cocoa
import SwiftUI
NSApplication.shared.run {
VStack {
Text("Hello, World")
.padding()
.background(Capsule().fill(Color.blue))
@IsaacXen
IsaacXen / README.md
Last active April 16, 2024 15:54
(Almost) Every WWDC videos download links for aria2c.
@fitomad
fitomad / KeyboardResponder.swift
Created November 22, 2019 19:23
Manage iOS keyboard presentation and dismiss with your SwiftUI views.
//
// KeyboardResponder.swift
// MoveMAD
//
// Created by Adolfo Vera Blasco on 19/11/2019.
// Copyright © 2019 desappstre {eStudio}. All rights reserved.
//
import SwiftUI
@jamesmacfie
jamesmacfie / README.md
Created October 22, 2019 02:53
iTerm 2 - script to change theme depending on Mac OS dark mode

How to use

In iTerm2, in the menu bar go to Scripts > Manage > New Python Script

Select Basic. Select Long-Running Daemon

Give the script a decent name (I chose auto_dark_mode.py)

Save and open the script in your editor of choice.