Skip to content

Instantly share code, notes, and snippets.

@Ashton-W
Ashton-W / .clang-format
Created April 22, 2015 07:23
my current clang format
---
Language: Cpp
BasedOnStyle: LLVM
AccessModifierOffset: -1
AlignEscapedNewlinesLeft: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortFunctionsOnASingleLine: None
AlwaysBreakTemplateDeclarations: true
AlwaysBreakBeforeMultilineStrings: true
BinPackParameters: false
@Ashton-W
Ashton-W / Breakpoints_v2.xcbkptlist
Last active January 25, 2023 09:28
My User Breakpoints_v2.xcbkptlist
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "2"
version = "2.0">
<Breakpoints>
<!-- All Exceptions -->
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.ExceptionBreakpoint">
<BreakpointContent
#!/usr/bin/env ruby
search_dir = ARGV[0] || "."
files = Dir.glob("#{search_dir}/**/*.{h,m,swift}")
if files.length > 0
puts "Found the following header or implementation files in '#{search_dir}':"
files.each do |filepath|
puts filepath
@Ashton-W
Ashton-W / gist:9622ad5b8cb3ab570dd5
Created March 3, 2015 08:10
patched xctool crash with KIF
1) -[FAILED_BEFORE TESTS_RAN] (UI Tests.xctest)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Test did not run: the test bundle stopped running or crashed before the test suite started.
2015-03-03 19:07:35.874 LinkedStoryboards[43486:23529036] KIFTester loaded
CRASH REPORT: LinkedStoryboards_2015-03-03-190737_Ashton.crash
Process: LinkedStoryboards [43486]
Path: /Users/USER/Library/Developer/CoreSimulator/Devices/E330D0BB-C864-4F9A-9E65-3C6306C6A001/data/Containers/Bundle/Application/9AF432F6-C2F8-455E-B37D-5176716BFAC3/LinkedStoryboards.app/LinkedStoryboards
@Ashton-W
Ashton-W / UIColorFromHex.m
Created January 20, 2015 06:30
nice inline function for hex to UIColor
NS_INLINE UIColor *UIColorFromHex(int hex)
{
return [UIColor colorWithRed:((CGFloat)((hex & 0xFF0000) >> 16)) / 255.0f
green:((CGFloat)((hex & 0x00FF00) >> 8)) / 255.0f
blue:((CGFloat)((hex & 0x0000FF) >> 0)) / 255.0f
alpha:1.0];
}
@Ashton-W
Ashton-W / AssertBlock.m
Created November 24, 2014 23:55
AssertBlock
// Is this a bad idea?
NSAssert(^BOOL() {
return YES;
}(), @"Assert");
@Ashton-W
Ashton-W / UIStoryboardSegue+Assignable.m
Created November 13, 2014 06:08
I'm happy with this method of moving models around in segues. For every model that might move around, a protocol is created for assignment, and a segue category method is added to assign it to destination view controllers if they conform to it. `prepareForSegue:` sends a messages for all its models to any segue.
/***
*
* Usage:
* ```
* - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
* {
* [segue prepareWithExampleModel:self.model];
* }
* ```
*/
@Ashton-W
Ashton-W / View.m
Created November 6, 2014 05:09
IBInspectable default values in Objective-C for IB_DESIGNABLE Views
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (!self) {
return nil;
}
[self inspectableDefaults];
@Ashton-W
Ashton-W / UIResponder+FirstResponder.m
Created October 1, 2014 07:46
UIResponder (FirstResponder) magic. Intercept UIControls calling `sendAction:to:from:forEvent:` and store a weak ref.
@implementation UIResponder (FirstResponder)
static __weak UIResponder *currentFirstResponder;
+ (instancetype)currentFirstResponder
{
[[UIApplication sharedApplication] sendAction:@selector(findCurrentFirstResponder:) to:nil from:self forEvent:nil];
return currentFirstResponder;
}
#! /bin/bash
# DHC - Hacked to always return a 0 code when successful.
SIM_DEVICES_FOLDER=~/Library/Developer/CoreSimulator/Devices
SIM_RUNTIME_PRFIX=com.apple.CoreSimulator.SimRuntime
function usage () {
echo "simulatorAppFolders (-s <name> | -d <device-type>) [-?] [-i <iOS version>] [-a <app-name>]"
echo "-? show help, and prints simulators currently installed"