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 / gist:4015acb7d9e3a937f4ad4c420c50d24f
Created February 2, 2020 23:22 — forked from v-thomp4/gist:951b333a37ee2adb0d3ac557bd75aba4
nginx universal links apple-app-site-association
location = /apple-app-site-association {
proxy_pass http://static.example.com/apple-app-site-association;
proxy_hide_header Content-Type;
add_header Content-Type "application/json";
}
or
location = apple-app-site-association {
default_type application/json;
@MihaelIsaev
MihaelIsaev / multiple_ssh_setting.md
Created January 21, 2020 21:14 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "[email protected]"
@MihaelIsaev
MihaelIsaev / Postgres+Transaction.swift
Last active January 16, 2020 01:34
Postgres transaction extension for Vapor4 and Fluent4
//
// Postgres+Transaction.swift
//
// Created by Mihael Isaev on 14.01.2020.
//
import Vapor
import FluentKit
import PostgresKit
// Enum Protocol
public protocol PostgresEnum: RawRepresentable, Codable, CaseIterable, PostgresDataConvertible {
static var name: String { get }
}
extension PostgresEnum {
static var name: String { String(describing: self).lowercased() }
}
import FluentKit
import Vapor
final class Todo: Model, Content {
static let schema = "todos"
@iID(key: "id", .uuid, .identifier(auto: false))
var id: UUID?
@iField(key: "title", .string, .required)
@MihaelIsaev
MihaelIsaev / fluent4+automigration.swift
Last active January 16, 2020 01:11
Fluent4 model with automigration example (automigration like in Fluent3)
// configure.swift
func configure(_ app: Application) throws {
app.migrations.add(Todo(), to: .psql)
try app.migrator.setupIfNeeded().wait()
try app.migrator.prepareBatch().wait()
}
// Todo.swift
final class Todo: Model, Content {
@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) {
@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 / 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 / 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