Skip to content

Instantly share code, notes, and snippets.

@seyhagithub
seyhagithub / nestTree.js
Created February 3, 2022 14:39
Traversal Object Tree
function traverse(data: any) {
const results: any[] = []
// let identifer = nanoid()
const recursive = (obj: any, pre: any = {}) => {
_.forIn(obj, function (val, key) {
// base case
if (key.toLowerCase().indexOf('remark') > 0) {
pre = {key, val}
}
@seyhagithub
seyhagithub / Tim Video using AVFounation Swift 4.swift
Last active December 13, 2018 03:42 — forked from acj/TrimVideo.swift
Trim video using AVFoundation in Swift
Swift 4 version:
import AVFoundation
import Foundation
import UIKit
class VideoTrimmer {
typealias TrimCompletion = (Error?) -> ()
typealias TrimPoints = [(CMTime, CMTime)]
@seyhagithub
seyhagithub / CodeSampleDIP.swift
Created October 1, 2018 10:05
Dependency Inversion Principle
protocol NetworkLayerType {
func request() -> [String]
}
class ViewController {
var models: [String]!
let networkLayer: NetworkLayerType
init(networkLayer: NetworkLayerType) {
self.networkLayer = networkLayer
@seyhagithub
seyhagithub / CodeSample.swift
Created October 1, 2018 06:29
Dependency Injection
import Foundation
class ViewController {
var models: [String]!
let networkLayer: NetworkLayer
init(networkLayer: NetworkLayer) {
self.networkLayer = networkLayer
}
func viewDidLoad() {