Skip to content

Instantly share code, notes, and snippets.

View narciszait's full-sized avatar

Narcis narciszait

  • App developer
  • Copenhagen, Denmark
View GitHub Profile
@helje5
helje5 / Tows.swift
Last active June 12, 2022 06:33
An 82-liner SwiftUI script similar to CodeCows 🐮
import SwiftUI
import cows // @AlwaysRightInstitute
struct ContentView: View {
@State var searchString = ""
@State var matches = allCows
@State var selectedCow : String?
let font = Font(NSFont
@zhuowei
zhuowei / Ensemble.plist
Last active September 18, 2023 06:26
Put this file as /Library/Preferences/FeatureFlags/Domain/Ensemble.plist and reboot to (hopefully) turn on Universal Control on macOS 12
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<!-- not sure which one it is, so set both -->
<key>Ensemble</key>
<dict>
<key>Enabled</key>
<true/>
</dict>
@getflourish
getflourish / ContentView.swift
Last active November 24, 2023 19:45
SwiftUI WebView
import SwiftUI
@available(OSX 11.0, *)
struct ContentView: View {
private var url: URL? = URL(string: "https://apple.com")
init() {
print("Hello World")
//------------------------------------------------------------------------
// Author: The SwiftUI Lab
// Post: Advanced SwiftUI Animations - Part 4
// Link: https://swiftui-lab.com/swiftui-animations-part4 (TimelineView)
//
import SwiftUI
struct ContentView: View {
var body: some View {
@denisenepraunig
denisenepraunig / BreathAnimation.swift
Last active November 26, 2024 20:55
Apple Watch Breath Animation in SwiftUI - modified pink edition
//
// BreathAnimation.swift
// breathing-animation
//
// Created by Denise Nepraunig on 17.05.21.
//
// Code is based on this tutorial:
// https://www.youtube.com/watch?v=KUvkJOhpB9A
// Thanks Adam :-)
@steipete
steipete / TouchBarSwiftUIHack.swift
Created April 19, 2021 15:17
Your SwiftUI app crashes in *** Assertion failure in -[NSTouchBarLayout setLeadingWidgetWidth:], NSTouchBarLayout.m:78 ? Use this hack to work around the problem!
import Foundation
import InterposeKit
import OSLog
/// Hack tow work around Assertion failure in -[NSTouchBarLayout setLeadingWidgetWidth:], NSTouchBarLayout.m:78
/// This sometimes happens when macOS restores a window.
/// This even runs if there is no OS-level touch bar.
class MacOSWorkarounds {
static let logger = Logger(category: "MacOSWorkarounds")
@steipete
steipete / RandomColor.swift
Created April 6, 2021 17:20
Random Color for SwiftUI
extension Color {
/// Return a random color
static var random: Color {
return Color(
red: .random(in: 0...1),
green: .random(in: 0...1),
blue: .random(in: 0...1)
)
}
}
@nathaniel11
nathaniel11 / Extensions.swift
Created March 21, 2021 22:54
UItableView helpful extensions
extension UIView {
class var reuseIdentifier: String {
return String(describing: self)
}
}
extension UITableView {
func dequeueReusableCell<T: UITableViewCell>(for indexPath: IndexPath) -> T? {
guard let cell = dequeueReusableCell(withIdentifier: T.reuseIdentifier, for: indexPath) as? T else {
assertionFailure("Unable to dequeue cell with identifier: \(T.reuseIdentifierString)")
@ouchadam
ouchadam / upload.sh
Last active February 20, 2023 15:02
Upload APK to appcenter app=my-cool-app owner=owner-in-appcenter file=path/to/file token=1234-api-token destination_name=group-to-apply
#!/bin/bash
set -e
CONFIG=$@
for line in $CONFIG; do
eval "$line"
done
AUTH="X-API-Token: $token"
CONTENT_TYPE=application/vnd.android.package-archive