Skip to content

Instantly share code, notes, and snippets.

View MihaelIsaev's full-sized avatar
⌨️
developing Swift for Web

Mikhail Isaev aka iMike MihaelIsaev

⌨️
developing Swift for Web
View GitHub Profile
@MihaelIsaev
MihaelIsaev / Router+AnyReponseArray.swift
Last active July 22, 2018 20:32
Attempt to handle routes with [AnyResponse] for Vapor3
extension Router {
@discardableResult
func get(_ path: PathComponentsRepresentable..., use closure: @escaping (Request) throws -> [AnyResponse]) -> Route<Responder>
{
return _on(.GET, at: path.convertToPathComponents(), use: closure)
}
@discardableResult
func post(_ path: PathComponentsRepresentable..., use closure: @escaping (Request) throws -> [AnyResponse]) -> Route<Responder>
{
CodyFire.shared.fillHeaders = {
guard let apiToken = LocalAuthStorage.savedToken else { return [:] }
return ["Authorization": "Bearer \(apiToken)"]
}
import Foundation
extension TimeZone {
func GMTOffset() -> String {
var offsetSeconds = secondsFromGMT()
var offsetString = "+00:00"
var offsetSymbol = "+"
var offsetHoursLeadString = "0"
var offsetMinutesLeadString = "0"
if offsetSeconds < 0 {
@MihaelIsaev
MihaelIsaev / ImageMagick.swift
Created February 9, 2019 17:22
Little ImageMagick wrapper for Vapor Swift
//
// ImageMagick.swift
// App
//
// Created by Mihael Isaev on 01.08.2018.
//
import Foundation
import Vapor
import Core
@MihaelIsaev
MihaelIsaev / Bindings.swift
Created June 14, 2019 02:51 — forked from AliSoftware/Bindings.swift
Re-implementation of @binding and @State (from SwiftUI) myself to better understand it
// This is a re-implementation of the @Binding and @State property wrappers from SwiftUI
// The only purpose of this code is to implement those wrappers myself just to understand how they work internally and why they are needed
// Re-implementing them myself has helped me understand the whole thing better
//: # A Binding is just something that encapsulates getter+setter to a property
@propertyDelegate
struct XBinding<Value> {
var value: Value {
get { return getValue() }
Если пробег до 200 то шкала от 0 до 200 это  100%. 
Если пробег свыше 200 то то шкала 300. 
Если свыше 300 то шкала 500. 
Если с выше 500 то шкала всегда зелёная. И значение пробега.

это есть

Принажатыми сюда в работе от автопрайса должен быть возврат в заявку( сейчас переходит на стартовую страницу так будет в программе полной )
@MihaelIsaev
MihaelIsaev / DatabaseConnection+Index.swift
Created August 7, 2019 16:05
A swift extension for `PostgreSQLConnection` for Vapor3 to have an ability to add indexes
//
// DatabaseConnection+Index.swift
// App
//
// Created by Mihael Isaev on 18.06.2018.
//
import Foundation
import Vapor
import FluentPostgreSQL
@MihaelIsaev
MihaelIsaev / Reflectable.swift
Created August 15, 2019 07:58
Vapor's reflectable realization in one file
//
// Reflectable
//
// Copied from https://github.com/vapor/core
//
import Foundation
import SwifQL
import NIO
@MihaelIsaev
MihaelIsaev / AuthMiddleware.swift
Created August 17, 2019 20:03
Simple authorization middleware for Vapor 3.
import Vapor
import SwifQL
class AuthMiddleware: Middleware {
/// Use it on your router like this
/// ```swift
/// let protectedRoute = router.grouped(AuthMiddleware())
/// ```
func respond(to request: Request, chainingTo next: Responder) throws -> Future<Response> {
return try request.requireToken().flatMap { try next.respond(to: $0) }
@MihaelIsaev
MihaelIsaev / CustomIntensityVisualEffectView.swift
Created September 29, 2019 17:02 — forked from darrarski/CustomIntensityVisualEffectView.swift
UIVisualEffectView subclass that allows to customise effect intensity
import UIKit
class CustomIntensityVisualEffectView: UIVisualEffectView {
/// Create visual effect view with given effect and its intensity
///
/// - Parameters:
/// - effect: visual effect, eg UIBlurEffect(style: .dark)
/// - intensity: custom intensity from 0.0 (no effect) to 1.0 (full effect) using linear scale
init(effect: UIVisualEffect, intensity: CGFloat) {