Skip to content

Instantly share code, notes, and snippets.

View arashkashi's full-sized avatar
💭
Working with machines against the machine

A.K. arashkashi

💭
Working with machines against the machine
View GitHub Profile
@arashkashi
arashkashi / Network.swift
Created February 26, 2018 15:19
Minimal Network Layer
//
// Network.swift
// Kirina
//
// Created by Arash Kashi on 2017-12-11.
// Copyright © 2017 Arash Kashi. All rights reserved.
//
import Foundation
import UIKit
@arashkashi
arashkashi / MyApplication.swift
Last active February 27, 2018 14:01
capture all events in iOS app, and filter them in windows of 10 seconds.
extension Notification.Name {
public static let SentEvent = Notification.Name("SentEvent")
}
class MyApplication: UIApplication {
override func sendEvent(_ event: UIEvent) {
@arashkashi
arashkashi / userInactivityDetector.swift
Last active February 27, 2018 14:05
Detects the inactivity of a user based on a timer setup.
extension Notification.Name {
public static let ProlongedInactivity = Notification.Name("ProlongedInactivity")
}
class UserInactivityDetector {
var idleTimeAllowed: TimeInterval = 30 {
didSet {
@arashkashi
arashkashi / uniqueId.swift
Created March 15, 2018 17:48
Unique Id for any object
extension UIViewController {
var uniqueId: String {
return "\(ObjectIdentifier(self).hashValue)"
}
}
@arashkashi
arashkashi / FetchResutlControllerWithCollectionView.swift
Created April 21, 2018 16:46
automatically sync collection view with.a fetch result controller.
//
// FetchResultsControllerWithCollectionView.swift
// CoreStore
//
// Created by Arash Kashi on 2/23/17.
// Copyright © 2017 Arash K. All rights reserved.
//
import Foundation
import CoreData
import UIKit
@arashkashi
arashkashi / Script.sh
Created June 13, 2019 12:55
Xcode build script for provisioning profile
#!/bin/bash
TARGET="Your App"
CONFIGURATION="Release"
SDK="iphoneos"
PROFILE_PATH="/Users/jkp/Desktop/foo.mobileprovision"
IDENTITY="iPhone Distribution: Your Company Ltd"
KEYCHAIN="/Users/jkp/Desktop/keychain"
PASSWORD="foobar"
@arashkashi
arashkashi / OperationsPipeline.swift
Last active June 25, 2019 22:17
Pipeline operations
import UIKit
import Foundation
enum PipableOperationOutput<T> {
case success(T)
case fail(Error)
}
@arashkashi
arashkashi / Composition.swift
Created June 26, 2019 20:58
More advanced serialization operator
infix operator --> :AdditionPrecedence
enum Result<T> {
case success(T)
case fail(Error)
}
func --><InA, InAEnv,OutAEnv ,OutBEnv , OutA, OutB>
(first: @escaping ( InAEnv? , InA , @escaping (OutAEnv?, Result<OutA>) -> () ) -> (),
second: @escaping (OutAEnv? , OutA, @escaping (OutBEnv?, Result<OutB>) -> () ) -> ()) ->
@arashkashi
arashkashi / fetchcontrollerwithdatasource.swift
Created July 4, 2019 07:32
fetch controller with data source for swift
import UIKit
import CoreData
public protocol FetchedResultsDelegate {
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath, object: AnyObject) -> UITableViewCell
}
public class FetchedResultsDataSource: NSObject, UITableViewDataSource, NSFetchedResultsControllerDelegate {
public weak var tableView: UITableView?
@arashkashi
arashkashi / ShareViewcontroller.swift
Created August 20, 2019 07:34
Add share controller
//
// TestViewController.swift
// Balance
//
// Created by ArashK on 2019-08-01.
// Copyright © 2019 Congruent Tech. UG. All rights reserved.
//
import UIKit
import CloudKit