Skip to content

Instantly share code, notes, and snippets.

Michał Zaborowski m1entus

Block or report user

Report or block m1entus

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
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 {
@m1entus
m1entus / CoreDataContextObserver.swift
Last active Jul 17, 2019
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);
@m1entus
m1entus / gist:e52386c9b3d1ff7307d9
Last active Dec 3, 2015 — forked from zetachang/gist:4111314
Instruction on adding a Acknowledgements Settings.bundle
View gist:e52386c9b3d1ff7307d9
  • To add Settings.bundle in Xcode. Command N and in Resource, choose Settings Bundle .
  • Open Root.plist in source code, paste the code below to replace it,
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>PreferenceSpecifiers</key>
	<array>
View create_dmg.sh
set -ex
[ "$ACTION" = build ] || exit 0
[ "$BUILD_VARIANTS" = "normal" ] || exit 0
[ "$CONFIGURATION" = "Release" ] || exit 0
dir="$TEMP_FILES_DIR/disk"
dmg="$HOME/Desktop/$PROJECT_NAME.dmg"
rm -rf "$dir"
@m1entus
m1entus / aes128.m
Created Sep 19, 2014
AES128 endryption
View aes128.m
- (NSData *)AES128EncryptWithData:(NSData *)data {
NSUInteger dataLength = [self length];
//See the doc: For block ciphers, the output size will always be less than or
//equal to the input size plus the size of one block.
//That's why we need to add the size of one block here
size_t bufferSize = dataLength + kCCBlockSizeAES128;
void *buffer = malloc(bufferSize);
You can’t perform that action at this time.