Skip to content

Instantly share code, notes, and snippets.

Avatar

Alistair amleszk

View GitHub Profile
@amleszk
amleszk / delete-all-sims.sh
Created Mar 20, 2019
Delete simulators by identifier from simctl
View delete-all-sims.sh
#!/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
View gist:1c4ef4c75227f23b3cbee7ba4865b6ca
[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 Jun 22, 2016
Fallback URL handling in SDWebImage
View UIImageView+RestaurantWebImage.h
//
// UIImageView+RestaurantWebImage.h
// DinerApp
//
// Created by ALeszkiewicz on 6/21/16.
// Copyright © 2016 GrubHub Inc. All rights reserved.
//
#import <UIKit/UIKit.h>
View gist:85e4caabd68b93e5c398
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
Hinge scan-build wrapper
View run-scan-build
#!/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 Aug 29, 2015
Example of main thread safety for Core data
View gist:7f93e55e5cbbf41ec9fb
//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 Oct 3, 2014
post_install xcode example
View gist:3ad63f5fd8b164fb1149
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
Adding a query string to an NSURL
View gist:c79d0f6701022a91d8da
#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;
View RCTestCase.h
#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;
View gist:5279693
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;
}
You can’t perform that action at this time.