This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // TODO: greater than, less than, multipliers, constants | |
| import Foundation | |
| let input = "[container.trailingAnchor constraintEqualToAnchor:childView.trailingAnchor]" | |
| func attribute(fromAnchor anchor: String) -> String { | |
| if let range = anchor.rangeOfString("Anchor") { | |
| var s = anchor.substringToIndex(range.startIndex) | |
| let firstChar = s.removeAtIndex(s.startIndex) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # coding: utf-8 | |
| import os | |
| import sys | |
| # Make source code files in a directory all begin with consistent preamble, which is: | |
| # // | |
| # // <filename> | |
| # | |
| # This code is very rough and could be better in lots of ways. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python | |
| #coding: utf-8 | |
| import json | |
| import subprocess | |
| def delete_all_simulators(): | |
| devices_json = subprocess.check_output(["xcrun", "simctl", "list", "--json", "devices"]) | |
| devices_by_runtime = json.loads(devices_json)["devices"] | |
| for runtime, devices in devices_by_runtime.iteritems(): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // This is more hacky than it should be! | |
| - (UIModalPresentationStyle)pspdf_currentPresentationStyle { | |
| UIViewController *vc = self.presentedViewController.presentingViewController; | |
| if ([self respondsToSelector:@selector(adaptivePresentationStyleForTraitCollection:)]) { | |
| UIModalPresentationStyle const style = [self adaptivePresentationStyleForTraitCollection:vc.traitCollection]; | |
| return (style == UIModalPresentationNone) ? self.presentationStyle : style; | |
| } | |
| // Before iOS 8.3 we have to fall back on assuming adaptivity is only possible for horizontally compact environments. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // It isn’t immediately obvious how to enable secure decoding with NSKeyedUnarchiver. | |
| // NSKeyedUnarchiver has a read-write requiresSecureCoding property, but we normally use: | |
| id decodedObject = [NSKeyedUnarchiver unarchiveObjectWithData:archive]; | |
| // so never see an instance to be able to set this property. | |
| // However, it is quite simple. The critical part is that we use the | |
| // normal decodeObject… methods, passing the key of the root object. | |
| NSData *archive; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @import Foundation; | |
| @interface ContravariantCollection<__contravariant ObjectType> : NSObject | |
| @end | |
| @implementation ContravariantCollection | |
| @end | |
| void stringSetThing(NSSet<NSString *> *set) { | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| AccessModifierOffset: -2 | |
| AlignAfterOpenBracket: true | |
| AlignEscapedNewlinesLeft: false | |
| AlignOperands: true | |
| AlignTrailingComments: true | |
| AllowAllParametersOfDeclarationOnNextLine: true | |
| AllowShortBlocksOnASingleLine: false | |
| AllowShortCaseLabelsOnASingleLine: true | |
| AllowShortFunctionsOnASingleLine: All |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // xcrun -sdk macosx clang non-square-problem.c -framework Accelerate && ./a.out | |
| // Douglas Hill, April 2015 | |
| // This demonstrates a problem discussed in Apple bug report 20428946. | |
| // Using LinearAlgebra’s la_solve with a non-square matrix results in an error instead of the expected output. | |
| #import <Accelerate/Accelerate.h> | |
| static void solveUsingLinearAlgebra(float *Adata, float *bdata, int numObservations); | |
| static void solveUsingLAPACK(float *Adata, float *bdata, int numObservations); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @implementation NSFileManager (DHRemoveFile) | |
| - (BOOL)dh_removeItemIfExistsAtURL:(NSURL *)URL error:(NSError **)out_error | |
| { | |
| NSError *error; // We need this in case out_error is NULL. | |
| if ([self removeItemAtURL:URL error:&error]) { | |
| return YES; | |
| } | |