Skip to content

Instantly share code, notes, and snippets.

View khcrysalis's full-sized avatar
☁️
Windy

khcrysalis

☁️
Windy
View GitHub Profile
@khcrysalis
khcrysalis / programming.md
Created June 30, 2025 21:33
General Rules I Follow When Programming

There's a few rules that I follow when trying to maintain my own personal projects, these rules also expand to any future potential contributor or maintainer that help me along the way. Some rules are more specific when it comes to certain repositories, sometimes they're more lenient, but in general most these rules are just code and project formatting to begin with. If there is any rules that need to be extended due to contributors or maintainers (due to a large project) I will include a CONTRIBUTION.md file that explains more on what you should do when contributing.

Below you will find the languages I have strict rules for when it comes to my personal projects, there could be one or even many. Just know that I will try to enforce these when possible.

Languages

Swift

  • Avoid having any functions or variables at top level, for example avoid having a func example() {} in main.swift
  • Instead, you can make a static variable or function associated to an extension/class/enum to make them access
@khcrysalis
khcrysalis / onboarding.swift
Created January 23, 2025 21:33
Apple-style onboarding for applications
func showOnboarding() {
let window = NSWindow(
contentRect: NSRect(x: 0, y: 0, width: 640, height: 600),
styleMask: [.fullSizeContentView, .nonactivatingPanel],
backing: .buffered,
defer: false
)
// Replace your own view here
let onboardingWindow = NSHostingView(rootView: EmptyView())
@khcrysalis
khcrysalis / SettingsLinkWrapper.swift
Created January 8, 2025 03:37
Wrapper for various ways to access settings in SwiftUI.
{
"name": "example",
"author": "ur_mom#42069",
"theme_color_map": {
"KEYBOARD": ["#000000", "#FFFFFF"],
"BACKGROUND_PRIMARY": ["#000000", "#FFFFFF"],
"BACKGROUND_SECONDARY": ["#000000", "#FFFFFF"],
"BACKGROUND_SECONDARY_ALT": ["#000000", "#FFFFFF"],
"BACKGROUND_TERTIARY": ["#000000", "#FFFFFF"],
"BACKGROUND_ACCENT": ["#000000", "#FFFFFF"],
{
"name": "Toothpaste",
"description": "For someone special.",
"version": "0.2",
"authors": [
{
"name": "flower!",
"id": "836452332387565589"
}
],