Skip to content

Instantly share code, notes, and snippets.

Michael Schneider maicki

Block or report user

Report or block maicki

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
maicki / update-nested-objects.js
Last active Sep 20, 2017
Update nested objects via JS
View update-nested-objects.js
// Original discussion:
// Object.assign:
const newInstrument = Object.assign({}, instrument, {
row: Object.assign({}, instrument.row, {
isSelected: true
// Spread syntax:
maicki / arrays.js
Created Sep 17, 2017
Arrays in JavaScript
View arrays.js
const iterateArray = (value, array) => {
array.forEach(() => {
const N = 10;
iterateArray('a', Array(N).fill());
iterateArray('b', Array.apply(null, {length: N}));
maicki / dispatchBlockWait.m
Created May 7, 2017
Examples how to use dispatch_block_wait in Objective C and Swift
View dispatchBlockWait.m
int main(int argc, const char * argv[]) {
@autoreleasepool {
// Code with dispatch_block_wait
__auto_type a = dispatch_block_create(DISPATCH_BLOCK_INHERIT_QOS_CLASS, ^{
NSLog(@"Before Sleep 1");
NSLog(@"After Sleep 2");
dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), a);
maicki / MSAtomicFlag.h
Created May 6, 2017
Atomic Flag Helper
View MSAtomicFlag.h
#pragma once
// Automatic getter and setter
#define MISAtomicSetterDeclaration(type, name, flag)\
- (void)name:(type)value\
MIS::Atomic::setFlag(self, flag, value);\
#define MISAtomicGetterDeclaration(type, name, flag)\
maicki / stackobjects.m
Created Apr 25, 2017
Stack objects in Objective-C
View stackobjects.m
#import <Foundation/Foundation.h>
#import <objc/runtime.h>
@interface SomeClass : NSObject
@property (nonatomic, assign) NSInteger someDefaultNumber;
@property (nonatomic, assign) NSInteger someCustomNumber;
- (void)method;
maicki / weakify_strongify.m
Last active Apr 30, 2019
Weakify / Strongify dance with multiple blocks
View weakify_strongify.m
// main.m
// WeakifyStrongify
// Created by Michael Schneider on 3/20/17.
// Copyright © 2017 mischneider. All rights reserved.
#import <Foundation/Foundation.h>
maicki / MSContext.m
Created Feb 18, 2017
Thread safe KVC handling for undefined keys
View MSContext.m
#import <pthread.h>
@interface MSContext : NSObject
@implementation MSContext {
pthread_mutex_t _mutex;
maicki / ASViewControllerContainment.swift
Last active Nov 21, 2016
ASViewController Containment
View ASViewControllerContainment.swift
import UIKit
import AsyncDisplayKit
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
maicki /
Last active Sep 13, 2016
ASDK 2.0 Layout Convert 1.x to 2.0

ASDK 2.0 Layout Convert 1.x To 2.0

With 2.0 one of the goals was to simplify the layout system in ASDK. There was a lot of additional functionality introduced that where not thought through to 100%. This guide should give you a good overview what changed from ASDK 1.x to 2.0 and what you have to do in your app to

All of the example projects are updated to the latest code changes so check them out in case you would like to see examples how to use the layout API changes we did.

Introduction of new sizing properties

With ASDK 2.0 we introduced a new type that is called ASSize. ASSize has the following declaration:

typedef struct {
maicki /
Last active Sep 3, 2016
How to create snapshot tests for ASDK

How to create snapshot tests for ASDK

  • Create a subclass of ASLayoutSpecSnapshotTestCase in the AsyncDisplayKitTests/ folder and named with ...Tests.m at the end. E.g.: ASBackgroundLayoutSpecSnapshotTests.m
  • If Xcode asks you to which target it should be added, add it to the AsyncDisplayKitTests target
  • Move the header declaration from the header (.h) file in the implementation file (.m) and remove the header file
  • Import: #import "ASLayoutSpecSnapshotTestsHelper.h"
  • Setup tests: Tests always have start with the word -(void)test... e.g. - (void)testBackground {}. A test file could look like the following:
#import "ASLayoutSpecSnapshotTestsHelper.h"
You can’t perform that action at this time.