Skip to content

Instantly share code, notes, and snippets.

View drrost's full-sized avatar

Rostyslav Druzhchenko drrost

  • Kharkiv, Ukraine
View GitHub Profile
@drrost
drrost / AuthenticationService.swift
Created October 13, 2019 20:34
AuthenticationService dummy
import Foundation
public class AuthenticationService {
public init() {
}
public func login(_ username: String, _ password: String) -> String {
return UUID().uuidString
}
@drrost
drrost / ViewController.swift
Last active October 15, 2019 08:09
ViewController with library call import
import UIKit
import Networking // 1
class ViewController: UIViewController {
let authService = AuthenticationService() // 2
override func viewDidLoad() {
super.viewDidLoad()
let token = authService.login("user", "S7eo#0-2K&b") // 3
print("token: \(token)") // 4
}
@drrost
drrost / BasicAuth.swift
Created October 21, 2019 09:50
Swift basic auth
#!/usr/bin/swift
import Foundation
func basicAuth(_ username: String, _ password: String) -> String {
let auth = username + ":" + password
let authData = auth.data(using: .utf8)!
return authData.base64EncodedString()
}
#!/bin/bash
set -e
defaults write com.apple.dt.Xcode DVTTextEditorTrimTrailingWhitespace -bool YES
defaults write com.apple.dt.Xcode DVTTextEditorTrimWhitespaceOnlyLines -bool YES
defaults write com.apple.dt.Xcode DVTTextIndentTabWidth -int 4
defaults write com.apple.dt.Xcode DVTTextIndentWidth -int 4
@drrost
drrost / BuildUniversalLib.sh
Last active November 10, 2019 10:27
Bash script to build a universal library from Xcode
# Created by: Rostyslav Druzhchenko
#
# 1: Declare variables
RESULT_DIR="libUniversal"
BUILD_DIR_SIMULATOR="Debug-iphonesimulator"
BUILD_DIR_DEVICE="Debug-iphoneos"
LIB_NAME="Networking"
@drrost
drrost / RunSwiftlintOnlyForChangedFiles.sh
Created November 3, 2019 15:48
Runs Swiftlint only for changed files - Xcode run script
# Created by: Rostyslav Druzhchenko
#
# Get current time
#
START_DATE=$(date +"%s")
# Save Swiftlint full path to a local variable
#
SWIFT_LINT=/usr/local/bin/swiftlint

Delete the last commit locally and remotely

git reset HEAD^ --hard
git push origin -f
@drrost
drrost / duplicate_line_xcode.md
Created December 2, 2019 13:52 — forked from emotality/duplicate_line_xcode.md
Xcode - Duplicate Line key binding

Xcode line duplicate

Bind keys to duplicate lines in Xcode

  1. Open below directory in Finder with Cmnd + Shift + G
/Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Versions/A/Resources/
#!/usr/bin/env swift
import Foundation
@discardableResult
func shell(_ args: String...) -> Int32 {
let task = Process()
task.launchPath = "/usr/bin/env"
task.arguments = args
task.launch()
import Foundation
func readVariable(_ name: String) -> String {
if let value = ProcessInfo.processInfo.environment[name] {
return value
}
return ""
}
let homePath = readVariable("HOME")