Skip to content

Instantly share code, notes, and snippets.

View RockinPaul's full-sized avatar
🐢

Paul Zarudnev RockinPaul

🐢
  • Amsterdam, Netherlands
View GitHub Profile
#!/bin/bash
killall Xcode
xcrun -k
xcodebuild -alltargets clean
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang/ModuleCache"
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang.$(whoami)/ModuleCache"
rm -rf ~/Library/Developer/Xcode/DerivedData/*
rm -rf ~/Library/Caches/com.apple.dt.Xcode/*
open /Applications/Xcode.app
@RockinPaul
RockinPaul / KeyboardMove.swift
Last active March 21, 2018 17:50
Move view with keyboard. Swift 3/4 version.
override func viewDidLoad() {
NotificationCenter.default.addObserver(self, selector: #selector(LoginViewController.keyboardWillShow),
name: NSNotification.Name.UIKeyboardWillShow,
object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(LoginViewController.keyboardWillHide),
name: NSNotification.Name.UIKeyboardWillHide,
object: nil)
}
func keyboardWillShow(notification: NSNotification) {
let alert = UIAlertController(title: "Some title", message: "Some message", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "Yes", style: .default, handler: { (_) in
print("Do some staff")
}))
alert.addAction(UIAlertAction(title: "No", style: .default, handler: nil))
self.present(alert, animated: true, completion: nil)
fileprivate var activityIndicator : UIImageView! = UIImageView(image: UIImage.gif(name:"load")) // load.gif file
override func viewDidLoad() {
super.viewDidLoad()
self.activityIndicator.frame = CGRect(x: 0, y: 0, width: 50, height: 50)
self.activityIndicator.contentMode = .scaleAspectFit
self.activityIndicator.backgroundColor = UIColor.clear
}
@RockinPaul
RockinPaul / sourceTree_device_not_configured.txt
Last active April 15, 2024 18:35
SourceTree: Device not configured (on MacOS)
In console:
git config credential.helper
You will see: osxkeychain
git config credential.helper sourcetree
Then if you perform git config credential.helper again
You will see: sourcetree
@RockinPaul
RockinPaul / CGPoint+CGSize+CGRect_to_NSValue.m
Created May 2, 2018 19:22
Storing CGPoint, CGSize and CGRect in Collections using NSValue
// CGPoint converted to NSValue
CGPoint point = CGPointMake(9, 9);
NSValue *pointObj = [NSValue valueWithCGPoint:point];
// CGSize converted to NSValue
CGSize size = CGSizeMake(100, 100);
NSValue *sizeObj = [NSValue valueWithCGSize:size];
// CGRect from CGPoint and CGSize converted to NSValue
CGRect rect = CGRectMake(point.x, point.y, size.width, size.height);
@RockinPaul
RockinPaul / UITextField+Padding.swift
Last active May 17, 2018 13:09
UITextField padding
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var textField: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
let paddingView = UIView(frame: CGRect(x: 0, y: 0, width: 15, height: textField.frame.height))
var btShop = UIButton()
let attributedString = NSAttributedString(
string: NSLocalizedString(“Buy”, comment: “”),
attributes:[
NSFontAttributeName :UIFont.systemFontOfSize(16.0),
NSForegroundColorAttributeName : UIColor.grayColor(),
NSUnderlineStyleAttributeName:1.0
])
btShop.setAttributedTitle(attributedString, forState: .normal)
@RockinPaul
RockinPaul / DismissKeyboard.swift
Created May 22, 2018 13:51
Dismiss keyboard on tap in UIView
override func viewDidLoad() {
super.viewDidLoad()
let tap = UITapGestureRecognizer(target: self, action: #selector(self.dismissKeyboard))
tap.cancelsTouchesInView = false
self.view.addGestureRecognizer(tap) // Dismiss keyboard
}
func dismissKeyboard(gestureReconizer: UITapGestureRecognizer) {
self.view.endEditing(true)
@RockinPaul
RockinPaul / SwiftBuildWhenSomethingIsWrong.sh
Last active January 16, 2019 06:16
sudo xcode-select --reset swift build
sudo xcode-select --reset
swift build
// The whole process
swift package init --type executable
swift build
swift run <app-name>