Skip to content

Instantly share code, notes, and snippets.

View slabko's full-sized avatar

Andrew Slabko slabko

  • ClickHouse
  • Amsterdam, The Netherlands
View GitHub Profile
@slabko
slabko / NSArray+ARLRange.h
Created February 8, 2015 16:58
NSArray from range
#import <Foundation/Foundation.h>
#define NSRangeEnumerate(i, range) for(i = range.location; i < NSMaxRange(range); ++i)
@interface NSArray (ARLRange)
- (instancetype)initWithRange:(NSRange)range;
+ (instancetype)arrayWithRange:(NSRange)range;
@end
@slabko
slabko / gist:ff557137608b97ec0c24
Created January 23, 2015 12:32
Apple Store's app Activity Indicator
UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(20, 20)
radius:10
startAngle:-2 endAngle:3
clockwise:YES];
CAShapeLayer *layer = [[CAShapeLayer alloc] init];
layer.frame = CGRectMake(0, 0, 40, 40);
layer.strokeColor = [UIColor grayColor].CGColor;
layer.fillColor = nil;
layer.lineWidth = 1;
@slabko
slabko / NSNotification+KeyboardNotifications.h
Last active August 29, 2015 14:13
NSNotification + KeyboardNotifications
#import <UIKit/UIKit.h>
@interface NSNotification (KeyboardNotifications)
- (NSTimeInterval)keyboardAnimationDuration;
- (UIViewAnimationCurve)keyboardAnimationCurve;
- (CGRect)keyboardFrame;
- (void)animateSynchronouslyWithKeyboard:(void(^)(void))animation completion:(void(^)(void))completion;
@slabko
slabko / ARLSquareButton.h
Created December 28, 2014 20:24
Square button with background animation on touch down and up (Highlight)
#import <UIKit/UIKit.h>
@interface ARLSquareButton : UIButton
@property (nonatomic, strong) IBInspectable UIColor *highlightedBackgroundColor;
@property (nonatomic, assign) IBInspectable CGFloat cornerRadius;
@end
@slabko
slabko / ARLMarginLabel.h
Created December 28, 2014 19:01
UILabel with margins
#import <UIKit/UIKit.h>
@interface ARLMarginLabel : UILabel
@property (nonatomic, assign) UIEdgeInsets margins;
// For IB
@property (nonatomic, assign) IBInspectable CGFloat topMargin;
@property (nonatomic, assign) IBInspectable CGFloat rightMargin;
@property (nonatomic, assign) IBInspectable CGFloat bottomMargin;
@slabko
slabko / gist:ed5ab9bc5bd5485cf022
Last active August 29, 2015 14:10
[Build] Check if there is more that one provisioning profile with the given name
#!/bin/bash
PROFILE_NAME='iOSTeam Provisioning Profile: Andrew Slabko'
ARRAY=()
DIR="/Users/slabko/Library/MobileDevice/Provisioning Profiles"
for f in "$DIR"/*.mobileprovision
do
NAME=`security cms -D -i "$f" > tmp.plist && /usr/libexec/PlistBuddy -c 'Print :Name' tmp.plist`
if [ "$NAME" = "$PROFILE_NAME" ]; then
echo "$f created `security cms -D -i "$f" > tmp.plist && /usr/libexec/PlistBuddy -c 'Print :CreationDate' tmp.plist`"
ARRAY+=("$f")
@slabko
slabko / gist:ce11d99bb59bcfdfd427
Last active August 16, 2018 15:04
[Cocoapods] Add preprocessor macros for pod project
platform :ios, '6.0'
pod 'ALibrary'
post_install do |installer_representation|
installer_representation.project.targets.each do |target|
if target.name == 'Pods-ALibrary'
target.build_configurations.each do |config|
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)']
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << 'VERY_IMPORTANT_MACROS=1'