Skip to content

Instantly share code, notes, and snippets.

View moh-abk's full-sized avatar
💭
Accelerating DevOps & Cloud Adoption 🚀

Mohammed Abubakar moh-abk

💭
Accelerating DevOps & Cloud Adoption 🚀
View GitHub Profile
@ks2211
ks2211 / ent-gosqlmock.go
Created July 7, 2022 20:08
ent-gosqlmock
import (
"database/sql"
"github.com/DATA-DOG/go-sqlmock"
"context"
"database/sql"
"fmt"
entsql "entgo.io/ent/dialect/sql"
"yourproject.com/project/ent"
@Nomad-Go
Nomad-Go / Uploads.swift
Last active November 1, 2022 03:07
Combine S3 Uploads
/// Function that will take an Array of `[S3Uploadable]` objects and returns a publisher that will complete once all uploads are done.
/// - Parameter objects: An array of `S3Uploadable` objects
/// - Returns: An `AnyPublisher` that will publish the array of objects you passed in and a faileur type of `Never`
public func upload(uploadableObjects objects: [S3Uploadable]) -> AnyPublisher<[S3Uploadable], Error> {
//We will collect some Futures into an array
var futures: [Future<S3Uploadable, Error>] = []
//Collect the futures
for object in objects {
let future = self.upload(objectToUpload: object)
@SupaHam
SupaHam / mongo_registry.go
Created November 6, 2020 23:17
mongo-go-driver UUID decoder & encoder for Golang
// This is a value (de|en)coder for the github.com/google/uuid UUID type. For best experience, register
// mongoRegistry to mongo client instance via options, e.g.
// clientOptions := options.Client().SetRegistry(mongoRegistry)
//
// Only BSON binary subtype 0x04 is supported.
//
// Use as you please
package repository
import (
@mobilinked
mobilinked / gist:9b6086b3760bcf1e5432932dad0813c0
Last active February 9, 2024 13:03
SwiftUI - prevent auto dismiss the sheet by drag down
//
// Created by https://quickplan.app on 2020/11/8.
//
import SwiftUI
/// Control if allow to dismiss the sheet by the user actions
/// - Drag down on the sheet on iPhone and iPad
/// - Tap outside the sheet on iPad
/// No impact to dismiss programatically (by calling "presentationMode.wrappedValue.dismiss()")
@YusukeHosonuma
YusukeHosonuma / Example.swift
Created August 15, 2020 02:07
NWPathMonitor を Combine の Publisher として扱えるようにする拡張
import SwiftUI
import Network
final class ViewModel: ObservableObject {
@Published var status: NWPath.Status = .satisfied
init() {
NWPathMonitor()
.publisher()
.map { $0.status }
@netgfx
netgfx / UIViewExtension.swift
Created July 24, 2020 13:17
UIViewExtension.swift
//
// UIViewExtensions.swift
//
//
import Foundation
import UIKit
extension UIView {
@susilolab
susilolab / main.rs
Created July 10, 2020 23:59
Demo sqlx
/* Cargo.toml
[package]
name = "sqlxx"
version = "0.1.0"
authors = ["Agus Susilo <smartgdi@gmail.com>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
@frankfka
frankfka / iOSCustomSegmentedControlSwiftUI.swift
Created May 17, 2020 16:47
Custom Segmented Picker / Segmented Control in SwiftUI
import SwiftUI
extension View {
func eraseToAnyView() -> AnyView {
AnyView(self)
}
}
struct SizePreferenceKey: PreferenceKey {
typealias Value = CGSize
@markiv
markiv / FloatingTextField2.swift
Created May 16, 2020 16:35
FloatingTextField2.swift
struct FloatingTextField: View {
let title: String
let text: Binding<String>
var body: some View {
VStack(alignment: .leading, spacing: 2) {
Text(title)
.font(.caption)
.foregroundColor(Color(.placeholderText))
.opacity(text.wrappedValue.isEmpty ? 0 : 1)
import SwiftUI
import WebKit
struct ContentView: View {
@ObservedObject var webViewStateModel: WebViewStateModel = WebViewStateModel()
var body: some View {
NavigationView {
LoadingView(isShowing: .constant(webViewStateModel.loading)) { //loading logic taken from https://stackoverflow.com/a/56496896/9838937
//Add onNavigationAction if callback needed