Skip to content

Instantly share code, notes, and snippets.

View castus's full-sized avatar

Krzysztof Romanowski castus

View GitHub Profile
@objc public class func lonelyReturnInOneLine(_ formatter: Formatter) {
formatter.forEach(.keyword) { i, token in
guard ["return"].contains(token.string),
let startOfScope = formatter.index(of: .startOfScope, before: i) else {
return
}
var hasOnlySpacesBetweenStartOfScopeAndReturn = true
for index in startOfScope + 1 ..< i {
if !formatter.tokens[index].isSpaceOrLinebreak {
@castus
castus / main.swift
Created May 1, 2018 22:06
Run SwiftFormat in Debug mode on a real file
CLI.run(in: FileManager.default.currentDirectoryPath, with: "test.swift --verbose --cache ignore")
@castus
castus / FormatRules.swift
Created May 1, 2018 22:04
Add custom rules to SwiftFormat
import Foundation
extension FormatRules {
/// Linebreak after class, extension or struct
@objc public class func ststLinebreakAfterClassExtensionStruct(_ formatter: Formatter) {
guard formatter.options.removeBlankLines else { return }
formatter.forEach(.keyword) { i, token in
guard ["class", "extension", "struct"].contains(token.string),
let startOfScopeIndex = formatter.index(of: .startOfScope, after: i),
@castus
castus / AppDelegate.swift
Created April 28, 2018 12:44
LiveSynchronizationController.swft usage
import SwiftTweaks
import FirebaseCore
import Fabric
import Crashlytics
import SwiftyUserDefaults
import UserNotifications
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
import Foundation
import AWSIoT
import SwiftyJSON
class LiveSynchronizationController {
private var connected = false
private var iotDataManager: AWSIoTDataManager!
private var iotManager: AWSIoTManager!
private var iot: AWSIoT!
- (void)viewDidLoad {
[super viewDidLoad];
User* user = [[User alloc] initWithName:@"Foo Bar" age:34];
[user hireOC];
// [user hire];
}
- (void)viewDidLoad {
[super viewDidLoad];
User* user = [[User alloc] initWithName:@"Foo Bar" age:34];
[user hireOC];
[user hire];
}
import Foundation
class User: NSObject {
let name: String
let age: Int
@objc init(name: String, age: Int) {
self.name = name
self.age = age
@castus
castus / 3.2.swift
Last active February 11, 2018 19:00
Swift 3.2 ObjC visibility
import Foundation
class User: NSObject {
let name: String
let age: Int
init(name: String, age: Int) {
self.name = name
self.age = age
@castus
castus / casper.md
Created November 7, 2017 14:39 — forked from motleytech/casper.md
Deal with casper

Unofficial Guide to JAMF Casper

This page documents the external/internal behavior of Casper.

Files

Casper installed itself into the following directories:

  • /Library/Application Support/JAMF
    • ManagementFrameworkScripts - a set of scripts that runs on certain events
      • StartupScript.sh - Activated when jamf is started
      • loginhook.sh - Activated when user login
  • logouthook.sh - Activated when user logout