Skip to content

Instantly share code, notes, and snippets.

View MainasuK's full-sized avatar

CMK MainasuK

View GitHub Profile
@MainasuK
MainasuK / AppDelegate.swift
Created September 5, 2019 08:05
AppDelegate for iOS 13 with multiple windows supports
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Set up application here

Keybase proof

I hereby claim:

  • I am mainasuk on github.
  • I am mainasuk (https://keybase.io/mainasuk) on keybase.
  • I have a public key ASAsqiEANz0eSQXHxi1YjIBC1m9lm3k8TldYLv-HRafSHAo

To claim this, I am signing this object:

@MainasuK
MainasuK / NSViewControllerPreview.swift
Last active May 21, 2022 20:09 — forked from mattt/UIViewControllerPreview.swift
Generic structures to host previews of UIView and UIViewController subclasses. Also NSView and NSViewController
import Cocoa
#if canImport(SwiftUI) && DEBUG
import SwiftUI
struct NSViewControllerPreview<ViewController: NSViewController>: NSViewControllerRepresentable {
let viewController: ViewController
init(_ builder: @escaping () -> ViewController) {
viewController = builder()
@MainasuK
MainasuK / ScreenRecordHelper.swift
Last active January 26, 2021 06:01
Screen Record Permission Request Helper for macOS Catalina
let stream = CGDisplayStream(display: CGDirectDisplayID(), outputWidth: 1, outputHeight: 1, pixelFormat: Int32(kCVPixelFormatType_32BGRA), properties: nil, handler: { (status, time, surface, update) in
// do nothing
})
@MainasuK
MainasuK / NSTreeController+Binding.swift
Created March 14, 2020 15:18
Bind NSTreeController contentArray to model
final class ViewModel: NSObject {
@objc var tree: [Node] = []
override init() {
super.init()
}
}
@MainasuK
MainasuK / Bash.swift
Last active May 21, 2020 00:54 — forked from andreacipriani/Bash.swift
Execute shell/bash commands from Swift
#!/usr/bin/swift
import Foundation
class Bash {
static var debugEnabled = false
// save command search time
static var commandCache: [String: String] = [:]
@discardableResult
@MainasuK
MainasuK / AutoLayout.swift
Last active June 4, 2020 07:27
Xcode Code Snippets
<#subview#>.translatesAutoresizingMaskIntoConstraints = false
addSubview(<#subview#>)
NSLayoutConstraint.activate([
<#subview#>.topAnchor.constraint(equalTo: topAnchor),
<#subview#>.leadingAnchor.constraint(equalTo: leadingAnchor),
trailingAnchor.constraint(equalTo: <#subview#>.trailingAnchor),
bottomAnchor.constraint(equalTo: <#subview#>.bottomAnchor),
])
@MainasuK
MainasuK / Apple.license
Last active November 8, 2021 08:52
Apple LICENSED APPLICATION END USER LICENSE AGREEMENT
Apps made available through the App Store are licensed, not sold, to you. Your license to each App is subject to your prior acceptance of either this Licensed Application End User License Agreement (“Standard EULA”), or a custom end user license agreement between you and the Application Provider (“Custom EULA”), if one is provided. Your license to any Apple App under this Standard EULA or Custom EULA is granted by Apple, and your license to any Third Party App under this Standard EULA or Custom EULA is granted by the Application Provider of that Third Party App. Any App that is subject to this Standard EULA is referred to herein as the “Licensed Application.” The Application Provider or Apple as applicable (“Licensor”) reserves all rights in and to the Licensed Application not expressly granted to you under this Standard EULA.
a. Scope of License: Licensor grants to you a nontransferable license to use the Licensed Application on any Apple-branded products that you own or control and as permitted by the Usag
@MainasuK
MainasuK / tmux.conf
Created March 4, 2022 08:14 — forked from ronaldsuwandi/tmux.conf
Personal tmux.conf (updated for 3.2)
###########
# general #
###########
# Replace C-b prefix with Alt+Space (so it won't clash with vim)
unbind C-b
set-option -g prefix M-Space
set-window-option -g mode-keys vi
set-option -g default-shell /usr/local/bin/fish
@MainasuK
MainasuK / AppIcons.command
Created April 2, 2022 08:47 — forked from pd95/AppIcons.command
A ZSH command file to produce the various PNG files required for iOS and macOS app Icons using `sips` (scriptable image processing system) available on any macOS. The resulting PNGs in the "AppIcons" folder can then be dragged into Xcode's `Assets.xcassets` onto a placeholder for an AppIcon.
#!/bin/zsh
# Shell Script to create all relevant icons from an high resolution artwork
if [ "x$1" != "x" -a -f "$1" ] ; then
INPUT=$1
else
INPUT="Artwork.png"
fi
if [ ! -f "$INPUT" ]; then