Skip to content

Instantly share code, notes, and snippets.

View dmiedema's full-sized avatar

Daniel Miedema dmiedema

View GitHub Profile
@dmiedema
dmiedema / file.swift
Created January 26, 2018 22:36
Swift Codable is a little weird...
import Foundation
// When using swift codable to parse JSON into a struct
let json = [
"non_accessible": true,
"index": 7
] as [String : Any]
struct Info: Codable {
let index: Int
@dmiedema
dmiedema / Dockerfile
Created November 26, 2017 00:15
Vapor/Docker Starter Template
FROM swift:latest
# Setup Prerequisits
USER root
RUN apt-get update \
&& apt-get install -y wget
RUN /bin/bash -c "$(wget -qO- https://apt.vapor.sh)"
RUN apt-get install -y vapor
~
[0] ❯ vi thing
[1] + 35001 suspended vim thing
~
[1] ❯ jobs | wc -l
1
~
@dmiedema
dmiedema / common_misspelled_words.sh
Last active April 26, 2016 21:43
Add warnings in Xcode for misspelled words.
#!/usr/bin/env bash
export COMMON_MISSPELLED_WORDS=(\
# Can be partial words
' fro ' \
' sting ' \
' teh ' \
' wer ' \
# Okay with partial word matches
@dmiedema
dmiedema / Acknowledgements.plist
Created November 12, 2015 05:43
Acknowledgements as Plist in settings bundle format
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PreferenceSpecifiers</key>
<array>
<dict>
<key>FooterText</key>
<string> LICENSE </string>
<key>Title</key>
@dmiedema
dmiedema / Info.plist
Created September 27, 2015 20:43
Make Google Analytics reporting work with iOS 9 App Transport Security. (Uses custom reporting library so mileage may vary)
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>www.google-analytics.com</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSIncludesSubdomains</key>
<true/>
#define NSHashtagLog(format, ...) NSLog(@"hashtag%@", format, __VA_ARGS__);
int main(int argc, char * argv[]) {
@autoreleasepool {
NSHashtagLog(@"DefinitelyLaunched", nil);
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
/** Console **/
@dmiedema
dmiedema / gist:6926e728a0bf9d240704
Created February 6, 2015 19:11
Something is askew between String & NSString
(lldb) po contents!.length
67734
(lldb) po countElements(String(contents!))
67734
(lldb) po String(contents!)
"MULTIPOLYGON (((-81.784076 36.705735, -81.784284 36.706001, -81.78431599999999 36.706057, -81.784342 36.706131, -81.78434999999999 36.706208, -81.78432099999999 36.706759, -81.78433 36.707046, -81.784353 36.707189, -81.784472 36.707547, -81.784477 36.707591, -81.784475 36.70819, -81.784442 36.708580999999995, -81.784367 36.708973, -81.784342 36.709036999999995, -81.784307 36.709098, -81.784249 36.709167, -81.78383 36.709472, -81.78347699999999 36.709705, -81.782803 36.71015, -81.78235 36.710449, -81.780378 36.711538, -81.779955 36.711774, -81.779403 36.712081999999995, -81.77900000000001 36.712297, -81.778905 36.712331, -81.778804 36.712351999999996, -81.778736 36.712358, -81.778638 36.712356, -81.778536 36.712340999999995, -81.778157 36.712246, -81.778003 36.712695, -81.777931 36.712942999999996, -81.77782499999999 36.713366, -81.77776899999999 36.713802, -81.777727 36.714135, -81.777723 36.714287
@dmiedema
dmiedema / macro.c
Created January 23, 2015 18:26
Wrapper around __attribute__((nonnull (...))) header macro
#define NOT_NULL(...) __attribute__((nonnull (__VA_ARGS__)))