Skip to content

Instantly share code, notes, and snippets.

View karenxpn's full-sized avatar
:octocat:
Buggy Codes

Karen Mirakyan karenxpn

:octocat:
Buggy Codes
View GitHub Profile
# list all folders
layerList=$(find -name 'flayer')
curDir=$(pwd)
echo executing $layerList
echo curdir is $curDir
# loop though each path
for path in $layerList
do
echo $path
import Foundation
import AVKit
import SwiftUI
import AVFoundation
import Combine
class AudioPlayViewModel: ObservableObject {
private var timer: Timer?
import Foundation
import SwiftUI
struct AudioPreviewModel: Hashable {
var magnitude: Float
var color: Color
}
import Foundation
import Combine
import Alamofire
import AVFoundation
protocol ServiceProtocol {
func buffer(url: URL, samplesCount: Int, completion: @escaping([AudioPreviewModel]) -> ())
}
@karenxpn
karenxpn / ContentView.swift
Created May 19, 2022 22:02
Simple usage of CameraXPN
//
// ContentView.swift
// CustomCameraApp
//
// Created by Karen Mirakyan on 09.05.22.
//
import SwiftUI
import CameraXPN
@karenxpn
karenxpn / AlertViewModel.swift
Created December 5, 2021 02:20
Alert View Model Log Out example
import Foundation
import SwiftUI
class AlertViewModel {
@AppStorage("token") private var token: String = ""
func makeAlert(with error: NetworkError, message: inout String, alert: inout Bool ) {
if error.initialError.responseCode == 401 {
@karenxpn
karenxpn / ContentView.swift
Created March 24, 2021 10:45
View to present our chat List
import SwiftUI
struct ContentView: View {
@ObservedObject var viewModel = ViewModel()
var body: some View {
ScrollView {
LazyVStack {
ForEach(viewModel.chats, id: \.id) { chat in
@karenxpn
karenxpn / ViewModel.swift
Last active March 23, 2021 23:16
Chat ViewModel that will give us the list
import Foundation
import Combine
class ViewModel: ObservableObject {
@Published var chats = [ChatModel]()
@Published var chatListLoadingError: String = ""
@Published var showAlert: Bool = false
private var cancellableSet: Set<AnyCancellable> = []
var dataManager: ServiceProtocol
@karenxpn
karenxpn / Service.swift
Last active March 23, 2021 23:16
Our service to fetch server response and parse it
import Foundation
import Combine
import Alamofire
protocol ServiceProtocol {
func fetchChats() -> AnyPublisher<DataResponse<ChatListModel, NetworkError>, Never>
}
class Service {
@karenxpn
karenxpn / ChatModel.swift
Last active March 23, 2021 23:17
Chat List that we should get
import Foundation
struct ChatListModel: Codable {
var chats: [ChatModel]
}
struct ChatModel: Identifiable, Codable {
var id: Int
var chatName: String
var image: String
var message: ChatPreveiwMessage?