Skip to content

Instantly share code, notes, and snippets.

Vadim Shpakovski shpakovski

Block or report user

Report or block shpakovski

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 Publisher+WeakAssign.swift
import Combine
extension Publisher where Self.Failure == Never {
/// Assigns each element from a Publisher to a property on an object if it still exists.
/// - Parameter keyPath: The key path of the property to assign.
/// - Parameter object: The object on which to assign the value, using a weak reference.
/// - Returns: A cancellable instance; used when you end assignment of the received value. Deallocation of the result will tear down the subscription stream.
/// - Note: Inspired by [OpenCombine](https://github.com/broadwaylamb/OpenCombine).
func weakAssign<Root: AnyObject>(to keyPath: ReferenceWritableKeyPath<Root, Output>, on object: Root?) -> AnyCancellable {
@shpakovski
shpakovski / SignIn.msd
Last active Mar 7, 2019
Sequence Diagram: NativeConnect Sign In
View SignIn.msd
#//# --------------------------------------------------------------------------------------
#//# Created using Sequence Diagram for Mac
#//# https://www.macsequencediagram.com
#//# https://itunes.apple.com/gb/app/sequence-diagram/id1195426709?mt=12
#//# --------------------------------------------------------------------------------------
participant SignInGroup
participant SaveAppleID
participant SignInProcedure
participant AuthConfigProcedure
@shpakovski
shpakovski / 005-hof.md
Last active Feb 18, 2019
Episode #5: Higher-Order Functions
@shpakovski
shpakovski / 004-adt.md
Last active Feb 9, 2019
Episode #4: Algebraic Data Types
View 004-adt.md

Question: What algebraic operation does the function type (A) -> B correspond to? Try explicitly enumerating all the values of some small cases like (Bool) -> Bool, (Unit) -> Bool, (Bool) -> Three and (Three) -> Bool to get some intuition.

Suggestion: Rather than list all possible unique input/output pairs, try defining every unique function for a given signature.

Answer: B ** A.

Bool ** Bool = 2 ** 2 = 4:
func f(_ b: Bool) -> Bool { return true }
func f(_ b: Bool) -> Bool { return false }
@shpakovski
shpakovski / Makefile
Created Dec 12, 2018
Mac app notarization from the command line
View Makefile
.PHONY: notarize
SIGNING_CERTIFICATE := $(shell security find-certificate -Z -c "Developer ID Application:" | grep "SHA-1" | awk 'NF { print $$NF }')
TEAM_ID := $(shell security find-certificate -c "Developer ID Application:" | grep "alis" | awk 'NF { print $$NF }' | tr -d \(\)\")
EXPORT_PATH := $(XCS_ARCHIVE)/Submissions
BUNDLE_APP := $(EXPORT_PATH)/NewMacApp.app
BUNDLE_ZIP := $(EXPORT_PATH)/NewMacApp.zip
UPLOAD_INFO_PLIST := $(EXPORT_PATH)/UploadInfo.plist
REQUEST_INFO_PLIST := $(EXPORT_PATH)/RequestInfo.plist
AUDIT_INFO_JSON := $(EXPORT_PATH)/AuditInfo.json
@shpakovski
shpakovski / README.md
Last active Dec 3, 2018
How to delete multiple integrations in Xcode?
View README.md

Problem

Xcode does not allow to edit multiple integrations at once, so we should select and delete them one by one. Such a terrible experience.

Solution

Fortunately, an Xcode Server can be accessed via an API. For example, let’s imagine that your Xcode server is running locally and is logged into macOS as vadim. Run the following command in Terminal:

curl -u vadim -ki https://localhost:20343/api/integrations
@shpakovski
shpakovski / Extra Logging for My Great App.mobileconfig
Created Sep 11, 2016 — forked from zwaldowski/Extra Logging for My Great App.mobileconfig
Apple Configuration Profile for Logging in iOS 10 and macOS Sierra
View Extra Logging for My Great App.mobileconfig
<?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">
<!-- iOS 10, macOS Sierra, and friends bring a new logging subsystem that's
supposed to scale from the kernel, up to frameworks, and up to apps. It defaults
to a more regimented, privacy-focused approach that large apps and complex
systems need.
It, along with Activity Tracing introduced in iOS 8 and macOS Yosemite and the
Console app in macOS Sierra, hope to help you graduate from caveman debugging to
View Playground.swift
protocol Value /* : Equatable */ { } // Uncomment results in compiler error
struct Foo: Value { }
func ==(lhs: Foo, rhs: Foo) -> Bool { return true }
struct Bar: Value { }
func ==(lhs: Bar, rhs: Bar) -> Bool { return true }
protocol Smashable {
func valueBySmashing​OtherValue(value: Value) -> Value
@shpakovski
shpakovski / AppDelegate.m
Last active Aug 29, 2015
Custom window with re-activation gesture to show the Tweaks panel
View AppDelegate.m
#if FB_TWEAK_ENABLED
#import "CustomTweakWindow.h"
#endif
- (UIWindow *)newRootWindow
{
#if FB_TWEAK_ENABLED
NSString *windowClassName = @"CustomTweakWindow";
#else
NSString *windowClassName = @"UIWindow";
@shpakovski
shpakovski / Parameters
Created Jun 9, 2014
Default parameters for UINavigationController in iOS 7.
View Parameters
seconds: 0.5
dumping: 10.0
velocity: 0.0
You can’t perform that action at this time.