Skip to content

Instantly share code, notes, and snippets.

CATransaction.begin()
CATransaction.setCompletionBlock({
// Every animation added to this transaction is now finished
})
UIView.animateWithDuration(0.5, delay: 0.5, options: [], animations: {
view1.alpha = 1.0
}, completion: { finished in
self.addSeveralLayerAnimations()
})
@hfossli
hfossli / RACSignalTest.m
Created September 23, 2016 19:54
Improving setNameWithFormat: in RAC
#import <XCTest/XCTest.h>
@interface RACSignal : NSObject
- (instancetype)someOperatorWithObject:(NSObject *)object;
- (NSString *)name;
@end
@hfossli
hfossli / RACSignalTest.m
Last active September 23, 2016 20:06
Improving setNameWithFormat: in RAC
#import <XCTest/XCTest.h>
#define RACNameBlockFromFormat(...) (^NSString *{\
return [NSString stringWithFormat:__VA_ARGS__]; \
})
@interface RACSignal : NSObject
- (instancetype)someOperatorWithObject:(NSObject *)object;
@hfossli
hfossli / RACSignalTest.m
Created September 26, 2016 12:59
Improving setNameWithFormat: in RAC
#import <XCTest/XCTest.h>
@interface RACSignal : NSObject
- (instancetype)someOperatorWithObject:(NSObject *)object;
- (NSString *)name;
@end
@hfossli
hfossli / Fastfile
Last active October 24, 2016 13:36
Remove duplicate .mobileprovision files locally on your machine
# If you prefer to have this in yor fastfile
fastlane_version "1.90.0"
default_platform :ios
platform :ios do
lane :duplicates do |options|
remove_local_duplicate_profiles
end
@hfossli
hfossli / UIScrollView+ScrollsToTop.h
Last active December 27, 2016 22:17
A simple way to make sure there is only one scrollview which is able to scroll to top at a time
#import <UIKit/UIKit.h>
@interface UIScrollView (ScrollsToTop)
+ (void)forceNewViewsDefaultValueForScrollsToTop;
+ (void)makeOnlyThisScrollViewScrollToTopOnStatusBarTap:(UIScrollView *)scrollView;
- (void)makeOnlyThisScrollViewScrollToTopOnStatusBarTap;
@end
@hfossli
hfossli / gist:5130975
Last active July 21, 2017 10:48
Tests
CGPoint CGPointApplyCATransform3D(CGPoint point, CATransform3D transform, CGPoint anchorPoint, CATransform3D parentSublayerTransform)
{
static CALayer *sublayer, *layer;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sublayer = [CALayer layer];
layer = [CALayer layer];
[layer addSublayer:sublayer];
});
@hfossli
hfossli / RxSwift+Optional.swift
Last active January 4, 2018 15:21
RxSwift + optional
// MIT License
//
// Copyright (c) 2016 Thane Gill <me@thanegill.com>
// Copyright (c) 2014-2017 Art.sy, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
// of the Software, and to permit persons to whom the Software is furnished to do
@hfossli
hfossli / gist:7562257
Last active June 27, 2018 04:56
A bash script for fetching all branches and tags of a git project as snapshots into separate folders
#!/bin/bash
# Created by Håvard Fossli <hfossli@gmail.com> in 2013
# This is free and unencumbered software released into the public domain.
# For more information, please refer to <http://unlicense.org/>
#
# Description
# A bash script for fetching all branches and tags of a git project as snapshots into separate folders
#
# Keywords
@hfossli
hfossli / build.sh
Created April 23, 2018 21:11
Script for building dynamic framework
#!/bin/bash
BASEDIR="$( cd "$(dirname "$0/")" ; pwd -P )"
BUILD_DIR="$BASEDIR/Builds"
PROJECT_FILE="Butterfly.xcodeproj"
PRODUCT_NAME="Butterfly"
TARGET_NAME="Butterfly-iOS"
CONFIGURATION="Release"
CLEAR='\033[0m'