Skip to content

Instantly share code, notes, and snippets.

@amleszk
amleszk / delete-all-sims.sh
Created March 20, 2019 10:36
Delete simulators by identifier from simctl
#!/bin/bash
# Delete by finding round bracket #2
xcrun simctl list | cut -d "(" -f2 | cut -d ")" -f1 | grep -E ".+-.+-.+-.+" | grep -v "^com" | xargs xcrun simctl delete
# Delete by finding round bracket #3
xcrun simctl list | cut -d "(" -f3 | cut -d ")" -f1 | grep -E ".+-.+-.+-.+" | grep -v "^com" | xargs xcrun simctl delete
# Delete by finding round bracket #4
xcrun simctl list | cut -d "(" -f4 | cut -d ")" -f1 | grep -E ".+-.+-.+-.+" | grep -v "^com" | xargs xcrun simctl delete
[debug] [XCUITest] Executing command 'proxyReqRes'
[debug] [JSONWP Proxy] Proxying [GET /wd/hub/session/24ca4e72-1cf7-43e2-b0a3-c7975550dfbf/element/BEBB6041-774D-459F-A8FC-7D3831E4D354/displayed] to [GET http://localhost:8100/session/88E1DAFE-F86D-4B5C-9E13-1FA438A82650/element/BEBB6041-774D-459F-A8FC-7D3831E4D354/displayed] with body: {}
[debug] [JSONWP Proxy] Got response with status 200: "{\n \"value\" : true,\n \"sessionId\" : \"88E1DAFE-F86D-4B5C-9E13-1FA438A82650\",\n \"status\" : 0\n}"
[JSONWP Proxy] Replacing sessionId 88E1DAFE-F86D-4B5C-9E13-1FA438A82650 with 24ca4e72-1cf7-43e2-b0a3-c7975550dfbf
[HTTP] <-- GET /wd/hub/session/24ca4e72-1cf7-43e2-b0a3-c7975550dfbf/element/BEBB6041-774D-459F-A8FC-7D3831E4D354/displayed 200 177 ms - 76
[HTTP] --> POST /wd/hub/session/24ca4e72-1cf7-43e2-b0a3-c7975550dfbf/touch/perform {"actions":[{"action":"press","options":{"element":"BEBB6041-774D-459F-A8FC-7D3831E4D354"}},{"action":"wait","options":{"ms":2}},{"action":"release","options":{}}]}
[debug] [MJSONWP] Ca
@amleszk
amleszk / UIImageView+RestaurantWebImage.h
Created June 22, 2016 13:50
Fallback URL handling in SDWebImage
//
// UIImageView+RestaurantWebImage.h
// DinerApp
//
// Created by ALeszkiewicz on 6/21/16.
// Copyright © 2016 GrubHub Inc. All rights reserved.
//
#import <UIKit/UIKit.h>
ibrary/Caches/Snapshots
2015-06-30 17:58:50.852 <Notice> ======== HNGConfigurationService AppStore, Beta, production Hinge, 3.5.0 (10356) 2015.06.30, iPhone6,1 8.3 ========
2015-06-30 17:58:51.022 <Notice> Breadcrumb: Using configuration: Beta
2015-06-30 17:58:51.088 <Notice> Breadcrumb: begin transaction UARegistration
2015-06-30 17:58:51.414 <Error> -[DatabaseManager initialisePersistentStore] [Line 196] [NSCocoaErrorDomain(259)] The operation couldn’t be completed. (Cocoa error 259.) {
NSSQLiteErrorDomain = 11;
NSUnderlyingException = "Fatal error. The database at /var/mobile/Containers/Data/Application/DB1255CB-0CE6-4572-8130-DBD693B8AFFF/Documents/hinge330.sqlite is corrupted. SQLite error code:11, 'database disk image is malformed'";
}
2015-06-30 17:58:51.423 <Notice> Breadcrumb: logged error:The operation couldn’t be completed. (Cocoa error 259.)
2015-06-30 17:58:51.433 <Warning> --- Deleting Store: file:///var/mobile/Containers/Data/Application/DB1255CB-0CE6-4572-8130-DBD693B8AFFF/Documen
@amleszk
amleszk / run-scan-build
Created May 27, 2015 21:57
Hinge scan-build wrapper
#!/bin/sh
# run_scan_build.sh
# Hinge
#
# Created by al on 27/05/2015.
# Copyright (c) 2015 Hinge, Inc. All rights reserved.
CLANG_CHECK="Xcode"
XCODE_COMPILER_LOCATION="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
@amleszk
amleszk / gist:7f93e55e5cbbf41ec9fb
Last active August 29, 2015 14:08
Example of main thread safety for Core data
//RCCoreData helper class
+(BOOL) onMainThread:(void (^)(void))mainThreadOperation
{
BOOL isMainThread = [NSThread isMainThread];
NSAssert(isMainThread, @"Should be on main thread");
if (isMainThread) {
mainThreadOperation();
} else {
dispatch_async(dispatch_get_main_queue(), mainThreadOperation);
@amleszk
amleszk / gist:3ad63f5fd8b164fb1149
Created October 3, 2014 16:08
post_install xcode example
post_install do |installer|
project = Xcodeproj::Project.open('MeetupApp.xcodeproj')
config_mapping = {
:Debug => 'Configuration/Debug.xcconfig'
}
set_xcconfig_reference(project,'MeetupApp','Debug','Configuration/Debug.xcconfig')
end
def set_xcconfig_reference(project, target_name, config_name, xcconfig_name)
@amleszk
amleszk / gist:c79d0f6701022a91d8da
Created May 14, 2014 21:11
Adding a query string to an NSURL
#import "NSURL+MUAdditions.h"
@implementation NSURL (MUAdditions)
-(NSURL*) URLByAppendingQueryString:(NSString*)queryString
{
NSString *absoluteString = [self absoluteString];
NSInteger startOfQueryString = [absoluteString rangeOfString:@"?"].location;
NSInteger startOfFragment = [absoluteString rangeOfString:@"#"].location;
#import <XCTest/XCTest.h>
typedef id (^OperationToExchangeForClass)(void);
@interface RCTestCase : XCTestCase
- (void) exchangeClassMethodForClass:(Class)clazz selector:(SEL)selector operation:(OperationToExchangeForClass)operation;
@property (nonatomic) NSBundle *unitTestBundle;
int toIndex=0;
[self.tableView beginUpdates];
for (NSDictionary* reddit in sortedReddits) {
NSString *displayName = [reddit valueForKeyPath:@"data.display_name"];
NSUInteger fromIndex =
[_reddits indexOfObjectPassingTest:^BOOL(NSDictionary *obj, NSUInteger idx, BOOL *stop) {
if ([[obj valueForKeyPath:@"data.display_name"] isEqualToString:displayName] ) {
*stop = YES;
return YES;
}