Skip to content

Instantly share code, notes, and snippets.

View m1entus's full-sized avatar

Michał Zaborowski m1entus

View GitHub Profile
#Set here your Environment.plist name
ENVIRONMENT="DEV"
#Environment.plist path
ENVIRONMENT_PLIST="$PROJECT_DIR/AppName/Environments.plist"
#Get app name from Environment.plist
APP_NAME=$(/usr/libexec/PlistBuddy -c "Print :$ENVIRONMENT:APP_NAME" "$ENVIRONMENT_PLIST")
#Get bundle identifier from Environment.plist
BUNDLE_ID=$(/usr/libexec/PlistBuddy -c "Print :$ENVIRONMENT:BUNDLE_IDENTIFIER" "$ENVIRONMENT_PLIST")
restore_derived_data_from_develop:
steps:
# We need to perform git fetch in order to find nearest develop SHA
- run:
name: Git Fetch
command: git fetch --no-tags
# This will create file with nearest develop commit SHA usually this will be point from where we stared this cranch
# We need to store it to file just to be able to use it as a key inside `restore_cache` command.
# Because it is not possible to directly embed it inside {{ }}
save_derived_data:
steps:
# This will create file with current commit SHA from develop branch
# We need to store it to file just to be able to use it as a key inside `save_cache` command.
# Because it is not possible to directly embed it inside {{ }}
- run:
name: Add current develop commit SHA environment variable
command: |
echo $(git show --format="%H" --no-patch) > /tmp/current_dev_commit_sha
@m1entus
m1entus / nearest_develop_SHA.sh
Created December 14, 2021 13:30
This will print SHA to closest develop as a parent
#!/bin/bash
# This will print SHA to closest develop as a parent
echo $(git log --decorate | grep 'commit' | grep 'origin/develop' | head -n 1 | awk '{ print $2 }' | tr -d "\n")
class SocialServiceBrowserDropboxClient: SocialServiceBrowserClient {
var serviceName: String = "Dropbox"
var filter: SocialServiceBrowserFilterType = .none
private var client: DropboxClient? {
return DropboxClientsManager.authorizedClient
}
func requestRootNode(with completion: @escaping (SocialServiceBrowserResult<SocialServiceBrowerNodeListResponse, Error>) -> Void) -> SocialServiceBrowserOperationPerformable? {
return client?.files.listFolder(path: "").response(completionHandler: { [weak self] response, error in
extension Files.Metadata: SocialServiceBrowerNode {
public var nodeId: String? {
if let file = self as? Files.FileMetadata {
return file.id
}
if let folder = self as? Files.FolderMetadata {
return folder.id
}
return nil
}
public protocol SocialServiceBrowserClient {
var serviceName: String { get }
func requestRootNode(with completion: @escaping (SocialServiceBrowserResult<SocialServiceBrowerNodeListResponse, Error>) -> Void) -> SocialServiceBrowserOperationPerformable?
func requestChildren(`for` node: SocialServiceBrowerNode, withCompletion completion: @escaping (SocialServiceBrowserResult<SocialServiceBrowerNodeListResponse, Error>) -> Void) -> SocialServiceBrowserOperationPerformable?
func requestThumbnail(`for` node: SocialServiceBrowerNode, withCompletion: @escaping (SocialServiceBrowserResult<UIImage, Error>) -> Void) -> SocialServiceBrowserOperationPerformable?
func requestData(`for` node: SocialServiceBrowerNode, withCompletion: @escaping (SocialServiceBrowserResult<URL, Error>) -> Void) -> SocialServiceBrowserOperationPerformable?
}
//...
let configuration = SocialServiceBrowserConfigurator(client: SocialServiceBrowserDropboxClient(), selectionMode: .select)
let viewController = SocialServiceBrowserViewController(configuration: configuration, uiConfiguration: configuration)
viewController.delegate = self
present(UINavigationController(rootViewController: viewController), animated: true, completion: nil)
//...
extension ViewController: SocialServiceBrowserViewControllerDelegate {
public struct CoreDataContextObserverState : OptionSetType {
static public let Inserted: ContextWatcher.CoreDataContextObserverState
static public let Updated: ContextWatcher.CoreDataContextObserverState
static public let Deleted: ContextWatcher.CoreDataContextObserverState
static public let Refreshed: ContextWatcher.CoreDataContextObserverState
static public let All: CoreDataContextObserverState
}
public typealias CoreDataContextObserverCompletionBlock = (NSManagedObject, CoreDataContextObserverState) -> ()
public class CoreDataContextObserver {
@m1entus
m1entus / CoreDataContextObserver.swift
Last active July 3, 2021 18:08
CoreDataContextObserver
//
// CoreDataContextWatcher.swift
// ContextWatcher
//
// Created by Michal Zaborowski on 10.05.2016.
// Copyright © 2016 Inspace Labs Sp z o. o. Spółka Komandytowa. All rights reserved.
//
import Foundation
import CoreData