Skip to content

Instantly share code, notes, and snippets.

View siavashalipour's full-sized avatar

Siavash siavashalipour

View GitHub Profile
@siavashalipour
siavashalipour / UIViewCropped.swift
Created September 30, 2019 02:13
Swift crop a whole inside Blurred UIView
func createOverlay(frame: CGRect,
xOffset: CGFloat,
yOffset: CGFloat,
radius: CGFloat) -> UIView {
// Step 1
// let overlayView = UIView(frame: frame)
// overlayView.backgroundColor = UIColor.black.withAlphaComponent(0.6)
let blur = UIBlurEffect(style: .regular)
let blurViewTop = UIVisualEffectView(effect: blur)
blurViewTop.frame = view.bounds//CGRect(x: 0, y: 0, width: view.bounds.width, height: (view.bounds.height / 2) - 64)
@siavashalipour
siavashalipour / Application1.swift
Created April 10, 2018 23:13
ServerSideSwift - First part of Application.swift
func postInit() throws {
// Endpoints
initializeHealthRoutes(app: self)
let dbServiceCollection = dbService.getCollection()
// register
router.all("/register", middleware: BodyParser())
router.post("/register") { request, response, next in
guard let parsedBody = request.body else {
next()
@siavashalipour
siavashalipour / MongoDataBaseService.swift
Created April 10, 2018 23:07
ServerSideSwift - MongoDataBaseService
//
// MongoDBService.swift
// UserAPI
//
// Created by Siavash on 9/4/18.
//
import MongoKitten
struct MongoDataBaseService {
@siavashalipour
siavashalipour / Package.swift
Created April 10, 2018 23:03
ServerSideSwift - Package.swift file
// swift-tools-version:4.0
import PackageDescription
let package = Package(
name: "UserAPI",
dependencies: [
.package(url: "https://github.com/IBM-Swift/Kitura.git", .upToNextMinor(from: "2.2.0")),
.package(url: "https://github.com/IBM-Swift/HeliumLogger.git", .upToNextMinor(from: "1.7.1")),
.package(url: "https://github.com/IBM-Swift/CloudEnvironment.git", from: "6.1.0"),
.package(url: "https://github.com/RuntimeTools/SwiftMetrics.git", from: "2.0.0"),
@siavashalipour
siavashalipour / main.swift
Created November 18, 2016 23:41
End-to-end Swift Solution with IBM Bluemix Part one - 3
import Foundation
import Kitura
import LoggerAPI
import HeliumLogger
import CloudFoundryEnv
import CloudFoundryDeploymentTracker
do {
 // HeliumLogger disables all buffering on stdout
 HeliumLogger.use(LoggerMessageType.info)
 let controller = try Controller()
@siavashalipour
siavashalipour / Controller.swift
Created November 18, 2016 23:40
End-to-end Swift Solution with IBM Bluemix Part one - 2
//
// Controller.swift
// Microservice1
//
// Created by Siavash on 26/9/16.
//
//
import Foundation
import Kitura
import SwiftyJSON
@siavashalipour
siavashalipour / package.swift
Created November 18, 2016 23:39
End-to-end Swift Solution with IBM Bluemix Part one - 1
import PackageDescription
let package = Package(
name: “Microservice1”,
targets: [
Target(name: “Microservice1”, dependencies: [])
],
dependencies: [
.Package(url: “https://github.com/IBM-Swift/Kitura.git", majorVersion: 1, minor: 0),
.Package(url: “https://github.com/IBM-Swift/HeliumLogger.git", majorVersion: 1, minor: 0),
.Package(url: “https://github.com/IBM-Swift/Swift-cfenv.git", majorVersion: 1, minor: 7),
@siavashalipour
siavashalipour / makefile
Created November 18, 2016 23:36
End-to-end Swift Solution with IBM Bluemix Part two - 1
# Copyright IBM Corporation 2016
#
# Licensed under the Apache License, Version 2.0 (the “License”);
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an “AS IS” BASIS,
@siavashalipour
siavashalipour / Controller.swift
Last active November 18, 2016 23:20
End-to-end Swift Solution with IBM Bluemix Part three - 2
//
// Controller.swift
// Microservice2
//
// Created by Siavash on 26/9/16.
//
//
import Foundation
import Kitura
import SwiftyJSON
@siavashalipour
siavashalipour / package.swift
Created November 18, 2016 23:17
End-to-end Swift Solution with IBM Bluemix Part three - 1
import PackageDescription
let package = Package(
 name: “Microservice2”,
 targets: [
 Target(name: “Microservice2”, dependencies: [])
 ],
 dependencies: [
 .Package(url: “https://github.com/IBM-Swift/Kitura.git", majorVersion: 1, minor: 0),
 .Package(url: “https://github.com/IBM-Swift/HeliumLogger.git", majorVersion: 1, minor: 0),
  .Package(url: “https://github.com/IBM-Swift/Swift-cfenv.git", majorVersion: 1, minor: 7),