Skip to content

Instantly share code, notes, and snippets.

@ssebi
ssebi / docker-commands.md
Last active September 23, 2019 11:24
Most used docker commands

🐳 Most Used Docker Commands

Image commands

build from local Dockerfile:

docker build -t TAG . 

List:

docker image ls or docker images
@ssebi
ssebi / Vapor-install-readme.md
Last active August 30, 2019 09:32
Vapor Install

Requirements

To use Vapor on macOS, you just need to have Xcode 9.3 or greater installed

Install Homebrew

Install Homebrew if you haven't done that already

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 

Install Vapor Toolbox

@ssebi
ssebi / .swift
Last active August 13, 2019 08:12
Cocoapods version issue
/*
*
* If you're having version problems with cocoapods
*
* Run this command to see all your cocoapods installed versions
*
*/
gem list --local | grep cocoapods
@ssebi
ssebi / .swift
Last active August 6, 2019 14:00
Diagnose RxSwift
/*
* In order to diagnose Rx and see the number of resources your project uses there are a couple
* of steps you need to take
*
* 1)
* Add this line of code somewhere in your project, for example in AppDelegate
*
*/
_ = Observable<Int>.interval(.seconds(1), scheduler: MainScheduler.instance)
.subscribe(onNext: { _ in
@ssebi
ssebi / UIFont.swift
Created July 29, 2019 12:25
Enable dynamic font with custom weight
extension UIFont {
@available(iOS 11.0, *)
static func preferredFont(for style: TextStyle, weight: Weight) -> UIFont {
let metrics = UIFontMetrics(forTextStyle: style)
let desc = UIFontDescriptor.preferredFontDescriptor(withTextStyle: style)
let font = UIFont.systemFont(ofSize: desc.pointSize, weight: weight)
return metrics.scaledFont(for: font)
}
@ssebi
ssebi / UITextField+Extensions.swift
Last active June 7, 2019 07:45
Extension to connect more UITextFields together and enable "Next" keyboard button to cycle through them. When reaching the last one button becomes "Done" and keyboard is dismissed
//
// UITextField.swift
// MasjidLink
//
// Created by Sebastian Vidrea on 07/06/2019.
// Copyright © 2019 Sebastian Vidrea. All rights reserved.
//
import Foundation
import UIKit
@ssebi
ssebi / UIViewController+Extensions.swift
Last active June 7, 2019 07:40
Extension to hide the keyboard when tapping around
//
// ViewController.swift
// MasjidLink
//
// Created by Sebastian Vidrea on 08/04/2019.
// Copyright © 2019 Sebastian Vidrea. All rights reserved.
//
import UIKit
@ssebi
ssebi / UIScrollView.swift
Last active July 2, 2019 06:24
Extension to scroll a UIScrollView to the bottom
extension UIScrollView {
func scrollToBottom() {
let bottomOffset = CGPoint(x: 0,
y: contentSize.height - bounds.size.height + contentInset.bottom)
if(bottomOffset.y > 0) {
setContentOffset(bottomOffset, animated: true)
}
}
@ssebi
ssebi / ScrollView.swift
Last active July 2, 2019 06:25
Extension to scroll a UIScrollView to any other view, leaving that view on top of the screen after scrolling.
extension UIScrollView {
func scrollToView(view:UIView, animated: Bool) {
if let origin = view.superview {
let childStartPoint = origin.convert(view.frame.origin, to: self)
self.scrollRectToVisible(CGRect(x: 0.0,
y: childStartPoint.y,
width: 1.0,
height: self.frame.height),
animated: animated)
@ssebi
ssebi / ScrollView.swift
Last active July 2, 2019 06:26
Extension to scroll a UIScrollView to top
extension UIScrollView {
func scrollToTop(animated: Bool) {
let topOffset = CGPoint(x: 0, y: -contentInset.top)
setContentOffset(topOffset, animated: animated)
}
}