Skip to content

Instantly share code, notes, and snippets.

View gavrilaf's full-sized avatar

Eugen gavrilaf

  • Zoolatech
  • Kiev
View GitHub Profile
let fetchOptions = PHFetchOptions()
fetchOptions.sortDescriptors = [NSSortDescriptor(key: "creationDate", ascending: false)]
fetchOptions.predicate = NSPredicate(format: "creationDate > %@ AND creationDate < %@",
Date.make(year: 2020, month: 08, day: 21, hour: 18, minute: 42)! as CVarArg,
Date.make(year: 2020, month: 08, day: 21, hour: 18, minute: 44)! as CVarArg)
fetchOptions.fetchLimit = 100
let assets = PHAsset.fetchAssets(with: .image, options: fetchOptions)
final class AppAssembly {
// private service
private lazy var healthcheckProvider: HealthcheckProvider = { HealthcheckService(executor: resolve()) }()
private lazy var authProvider: AuthProvider = { AuthService() }()
private lazy var reviewProvider: ReviewProvider = { ReviewService(executor: resolve()) }()
private lazy var followProvider: FollowProvider = { FollowService(executor: resolve()) }()
private lazy var visionProvider: VisionProvider = { VisionService() }()
private lazy var classifyingModel: ClassifyingModel = { ClassifyingModelBayes() }()
private lazy var appRouter: AppRouter = { AppRouter() }()
private lazy var userProfileProvider: ProfileProvider = { ProfileService(executor: resolve(),
protocol ServicesAssemble {
var eventBus: EventBusProvider { get }
var userSession: UserSession { get }
var appSettings: SettingsProvider { get }
var location: LocationProvider { get }
var mapImageGenerator: MapImageGenerator { get }
var profile: UserProfileProvider { get }
var chat: ChatProvider { get }
}
@gavrilaf
gavrilaf / log2.swift
Created November 29, 2020 16:12
Logging for Swift (option 2)
import Foundation
import os.log
// MARK:-
protocol LogHandler {
func debug(_ msg: String, _ params: [String: Any])
func info(_ msg: String, _ params: [String: Any])
func error(_ msg: String, _ params: [String: Any])
func fatal(_ msg: String, _ params: [String: Any])
}
@gavrilaf
gavrilaf / log.swift
Created November 29, 2020 16:08
Logging sample for Swift
import os
enum LogSubSystem {
case app
case api
case firebase
}
class AppLogs {
private static let appLog = Logger(subsystem: "com.my-app", category: "App")
@gavrilaf
gavrilaf / ingres+https.yaml
Created July 21, 2020 19:59
Ingress with https
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: api-ingress
namespace: default
annotations:
kubernetes.io/ingress.global-static-ip-name: my-ip-address
networking.gke.io/managed-certificates: my-certificate
spec:
backend:
@gavrilaf
gavrilaf / healthcheck.go
Created July 20, 2020 18:44
service healthcheck
router := gin.New()
router.GET("/", func(c *gin.Context) {
result := gin.H{
"status": "green",
}
c.JSON(http.StatusOK, result)
})
@gavrilaf
gavrilaf / nodeport+ingress.yaml
Created July 19, 2020 17:40
NodePort + Ingress sample
apiVersion: apps/v1
kind: Deployment
metadata:
name: api-deployment
spec:
selector:
matchLabels:
app: api
template:
metadata:
@gavrilaf
gavrilaf / api-load-balancer-deployment.yaml
Created July 19, 2020 10:57
Service + load balancer
apiVersion: apps/v1
kind: Deployment
metadata:
name: api-deployment
labels:
app: api
spec:
replicas: 1
selector:
matchLabels:
@gavrilaf
gavrilaf / service-cluster-ip-deployment.yaml
Last active July 19, 2020 10:55
k8 service deployment sample
apiVersion: apps/v1
kind: Deployment
metadata:
name: location-deployment
labels:
app: location
spec:
replicas: 1
selector:
matchLabels: