Skip to content

Instantly share code, notes, and snippets.

View nickdowell's full-sized avatar

Nick Dowell nickdowell

  • UK
View GitHub Profile
#include <unordered_map>
class avg_timer
{
public:
avg_timer(const char *name, int batch = 120) : name_(name), batch_(batch) {}
avg_timer(const scope_timer &) = delete;
~avg_timer() noexcept
{
auto elapsed = std::chrono::steady_clock::now() - start_;
10.4 3.1.3
10.13 3.19.3 2017-06-27 16:48:08 2b0954060fe10d6de6d479287dd88890f1bef6cc1beca11bc6cdb79f72e2377b
12.6.8 3.37.0 2021-12-09 01:34:53 9ff244ce0739f8ee52a3e9671adb4ee54c83c640b02e3f9d185fd2f9a179aapl
13.5 3.42.0 2023-05-16 12:36:15 831d0fb2836b71c9bc51067c49fee4b8f18047814f2ff22d817d25195cf350b0
@nickdowell
nickdowell / gist:b446a3f987c8b6e16d2abc6e67b4b7a3
Created November 28, 2022 08:09
Predefined preprocessor macros (clang)
$ clang -dM -E -x c++ /dev/null
#define _LP64 1
#define __AARCH64EL__ 1
#define __AARCH64_CMODEL_SMALL__ 1
#define __AARCH64_SIMD__ 1
#define __APPLE_CC__ 6000
#define __APPLE__ 1
#define __ARM64_ARCH_8__ 1
#define __ARM_64BIT_STATE 1
#!/bin/zsh
set -euxo pipefail
sdk_path=`xcrun -f --sdk iphoneos --show-sdk-path`
plat_path=`xcrun -f --sdk iphoneos --show-sdk-platform-path`
$CLANG_TIDY \
Sources/MyLibrary/**/*.mm -- \
-ISources/MyLibrary/include \
CLANG_WARN__DUPLICATE_METHOD_MATCH
37a38
> -Wduplicate-method-match
CLANG_WARN__EXIT_TIME_DESTRUCTORS
37c37
< -Wno-exit-time-destructors
---
> -Wexit-time-destructors

Keybase proof

I hereby claim:

  • I am nickdowell on github.
  • I am nickdowell (https://keybase.io/nickdowell) on keybase.
  • I have a public key ASCVNmhBpxVhpMEx_FXUvs5_LQy5W9TLiiE3gNjGFzB1lQo

To claim this, I am signing this object:

- (NSURLRequest *)connection:(NSURLConnection *)connection willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)response
{
if (response != nil) {
[[self client] URLProtocol:self wasRedirectedToRequest:request redirectResponse:response];
}
return request;
}
NSString *getApsEnvironment()
{
NSString *provisioningPath = [[NSBundle mainBundle] pathForResource:@"embedded" ofType:@"mobileprovision"];
if (!provisioningPath)
return (NSString *)nil;
// NSISOLatin1 keeps the binary wrapper from being parsed as unicode and dropped as invalid
NSScanner *scanner = [NSScanner scannerWithString:[NSString stringWithContentsOfFile:provisioningPath encoding:NSISOLatin1StringEncoding error:NULL]];
if (![scanner scanUpToString:@"<plist" intoString:nil])
return (NSString *)nil;
void UIViewRecurse(UIView *view, void (^ apply)(UIView *subview))
{
static void (^ recurse)(UIView *subview, void (^ apply)(UIView *subview)) = nil;
if (recurse == nil)
recurse = ^(UIView *subview, void (^ apply)(UIView *subview)){
apply(subview);
for (UIView *v in subview.subviews)
recurse(v, apply);
};
recurse(view, apply);