Skip to content

Instantly share code, notes, and snippets.

Avatar

Michał Zaborowski m1entus

View GitHub Profile
View medium_restore_derived_data.yml
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 {{ }}
View medium_save_derived_data.yml
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 Dec 14, 2021
This will print SHA to closest develop as a parent
View nearest_develop_SHA.sh
#!/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")
View SocialServiceBrowser-4.swift
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
View SocialServiceBrowser-3.swift
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
}
View SocialServiceBrowser-2.swift
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?
}
View SocialServiceBrowser-1.swift
//...
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 {
View CoreDataContextObserver-Interface.swift
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 {
View CoreDataContextObserver.swift
//
// 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
@m1entus
m1entus / gist:8d56b4d272fb0d13750e
Created Mar 11, 2016 — forked from justinHowlett/gist:4611988
Determine if a UIImage is generally dark or generally light
View gist:8d56b4d272fb0d13750e
BOOL isDarkImage(UIImage* inputImage){
BOOL isDark = FALSE;
CFDataRef imageData = CGDataProviderCopyData(CGImageGetDataProvider(inputImage.CGImage));
const UInt8 *pixels = CFDataGetBytePtr(imageData);
int darkPixels = 0;
int length = CFDataGetLength(imageData);