Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 23, 2016 19:54
Improving setNameWithFormat: in RAC
#import <XCTest/XCTest.h>
@interface RACSignal : NSObject
- (instancetype)someOperatorWithObject:(NSObject *)object;
- (NSString *)name;
@end
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()
})

Keybase proof

I hereby claim:

  • I am hfossli on github.
  • I am hfossli (https://keybase.io/hfossli) on keybase.
  • I have a public key ASC8OY-Dk5-RXJKmdCOJ9oHOaBh-LqGHRgg_HoBM4kb6Two

To claim this, I am signing this object:

@hfossli
hfossli / NodeTask.swift
Last active January 2, 2024 00:27
Start a node.js server using NSTask in Swift.
import Foundation
import Cocoa
class NodeTask: NSObject {
private let processIdentifier = NSProcessInfo.processInfo().processIdentifier
private let nodeTask = NSTask()
private let readPipe = NSPipe()
private let errorPipe = NSPipe()
private let queue = dispatch_queue_create("NodeTask.output.queue", DISPATCH_QUEUE_SERIAL)
#import <libkern/OSAtomic.h>
BOOL ale_dispatch_is_on_queue(dispatch_queue_t queue)
{
int key;
static int32_t incrementer;
CFNumberRef value = CFBridgingRetain(@(OSAtomicIncrement32(&incrementer)));
dispatch_queue_set_specific(queue, &key, value, nil);
BOOL result = dispatch_get_specific(&key) == value;
dispatch_queue_set_specific(queue, &key, nil, nil);
#import "ViewController.h"
@interface Scroll : UIScrollView
@end
@implementation Scroll
- (void)setNeedsLayout
{
@hfossli
hfossli / code
Last active September 23, 2015 06:51
{
NSString *string = @"123-456-7890";
NSArray *components = [string componentsSeparatedByString:@"-"];
NSLog(@"Components: (%i) %@", (int)components.count, components);
}
{
NSString *string = @"-123-456-7890";
NSArray *components = [string componentsSeparatedByString:@"-"];
NSLog(@"Components: (%i) %@", (int)components.count, components);
}