<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Mick F</title><description>Notes for myself and fellow programmers, with a focus on iOS, Swift and web frontend development. Since 2009.</description><link>https://www.mickf.net/tech/</link><item><title>Generating JWT Tokens in Swift for the App Store Connect API</title><link>https://www.mickf.net/tech/jwt-tokens-app-store-connect-api-swift/</link><guid isPermaLink="true">https://www.mickf.net/tech/jwt-tokens-app-store-connect-api-swift/</guid><description>Learn how to generate JWT tokens in Swift to authorize requests to the App Store Connect API. This guide covers creating payloads, signing tokens with JWTKit, managing secrets securely, and integrating the process into your macOS and iOS apps.</description><pubDate>Mon, 25 Nov 2024 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Using the &lt;a href=&quot;https://developer.apple.com/documentation/appstoreconnectapi&quot;&gt;App Store Connect API&lt;/a&gt; can significantly streamline workflows. For
example, I use it to onboard new TestFlight testers for my apps much faster than
through &lt;code&gt;appstoreconnect.apple.com&lt;/code&gt;. While Apple provides a &lt;a href=&quot;https://developer.apple.com/documentation/appstoreconnectapi/generating-tokens-for-api-requests&quot;&gt;&lt;em&gt;Generating Tokens
for API Requests&lt;/em&gt;&lt;/a&gt; guide, this post shows how to create such tokens in Swift.&lt;/p&gt;
&lt;h2 id=&quot;generating-jwt-tokens-with-jwtkit&quot;&gt;Generating JWT Tokens with JWTKit&lt;/h2&gt;
&lt;p&gt;The first step in using the API is to create JWT tokens. For this, I’ve used
&lt;a href=&quot;https://github.com/vapor/jwt-kit&quot;&gt;&lt;code&gt;vapor/jwt-kit&lt;/code&gt;&lt;/a&gt;&lt;sup&gt;&lt;a href=&quot;#user-content-fn-2&quot; id=&quot;user-content-fnref-2&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;
&lt;h3 id=&quot;step-1-define-the-payload&quot;&gt;Step 1: Define the Payload&lt;/h3&gt;
&lt;p&gt;Start by defining the payload structure expected by Apple:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;/// A JWT payload structure for App Store Connect APIs.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; struct&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; AppStoreConnectPayload&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;JWTPayload &lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    public&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; iss: IssuerClaim&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    public&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; iat: IssuedAtClaim&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    public&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; exp: ExpirationClaim&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    public&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; aud: AudienceClaim&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    public&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; scope: [&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;?&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;    /// Creates a new payload for App Store Connect.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    public&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; init&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;iss&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;iat&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: Date, &lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;exp&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: Date, &lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;aud&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: [&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;], &lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;scope&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: [&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;?&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; nil&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;        self&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.iss &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; IssuerClaim&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: iss)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;        self&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.iat &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; IssuedAtClaim&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: iat)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;        self&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.exp &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; ExpirationClaim&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: exp)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;        self&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.aud &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; AudienceClaim&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: aud)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;        self&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.scope &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; scope&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;    /// Verifies that the payload is valid and not expired.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;    /// - Throws: An error if the payload is invalid or expired.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    public&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; func&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; verify&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; _: &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;some&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; JWTAlgorithm) &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;throws&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        try&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; exp.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;verifyNotExpired&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;step-2-generate-the-token&quot;&gt;Step 2: Generate the Token&lt;/h3&gt;
&lt;p&gt;Once the payload is ready, create the token. Below is an example using sample
data (based on Apple’s guide) and a dummy private key. Be sure to replace these
with your actual values:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; pem &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;&quot;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;    -----BEGIN PRIVATE KEY-----&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;    MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgqIuh45D/4x9KGZ9v&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;    …&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;    uJcVQDj14FbV2QLpTbrNtk82W6ZMJT+FAZaJsx5Xiu9u83rbeICgZy3G&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;    -----END PRIVATE KEY-----&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;    &quot;&quot;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; keys &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; JWTKeyCollection&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; kid &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; JWKIdentifier&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;2X9R4HXF34&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; key &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; try&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; ES256PrivateKey&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;pem&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: pem)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;await&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; keys.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;add&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;ecdsa&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: key, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;kid&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: kid)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; token &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; try&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; await&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; keys.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;sign&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    payload,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;    kid&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: .&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;init&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: keyIdentifier),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;    header&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: [&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;typ&quot;&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;JWT&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You now have a JWT token! 🎉&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;using-the-code-as-a-dependency&quot;&gt;Using the Code as a Dependency&lt;/h2&gt;
&lt;p&gt;If you prefer not to write your own implementation, you can use the
&lt;a href=&quot;https://github.com/dirtyhenry/swift-hoods&quot;&gt;&lt;code&gt;dirtyhenry/swift-hoods&lt;/code&gt;&lt;/a&gt; package I created. It provides a &lt;code&gt;jwtFactory&lt;/code&gt;
dependency, compatible with &lt;a href=&quot;https://github.com/pointfreeco/swift-dependencies&quot;&gt;&lt;code&gt;pointfreeco/swift-dependencies&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Here’s how to integrate it:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;@Dependency&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(\.jwtFactory) &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;var&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; jwtFactory&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And in your application’s single entry-point:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; jwtFactory &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;  try&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; LiveJWTFactory&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;try&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; await&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; jwtFactory.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;addES256Key&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;pem&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: privateKey, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;keyIdentifier&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: keyIdentifier)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; newTransport &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; try&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; withDependencies&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;    $0&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.jwtFactory &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; jwtFactory&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;} &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;operation&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    return&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; AppStoreConnectAPIAuthorizationTransport&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;additional-tips&quot;&gt;Additional Tips&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Managing Secrets.&lt;/strong&gt; Storing private keys and secrets securely is crucial.
Check out the &lt;a href=&quot;https://github.com/dirtyhenry/swift-blocks/blob/main/Sources/Blocks/Security/GenericPasswordKeychainItem.swift&quot;&gt;&lt;code&gt;GenericPasswordKeychainItem&lt;/code&gt;&lt;/a&gt; class for handling keychain
data on iOS and macOS.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Request Integration.&lt;/strong&gt; To include the token with every API request, consider
using &lt;a href=&quot;https://swiftpackageindex.com/dirtyhenry/swift-blocks/main/documentation/blocks/transport#Transports-Toolbox&quot;&gt;a dedicated &lt;code&gt;Transport&lt;/code&gt;&lt;/a&gt;. This makes it easy to compose behaviors
around a &lt;code&gt;URLSession&lt;/code&gt; instance.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Testing Tokens.&lt;/strong&gt; Use the &lt;code&gt;date&lt;/code&gt; dependency from
&lt;a href=&quot;https://github.com/pointfreeco/swift-dependencies&quot;&gt;&lt;code&gt;pointfreeco/swift-dependencies&lt;/code&gt;&lt;/a&gt; to simulate different expiration
scenarios when testing token verification&lt;sup&gt;&lt;a href=&quot;#user-content-fn-1&quot; id=&quot;user-content-fnref-1&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;With these steps, you can efficiently generate JWT tokens in Swift and
streamline your use of the App Store Connect API. Happy coding!&lt;/p&gt;
&lt;section data-footnotes class=&quot;footnotes&quot;&gt;&lt;h2 class=&quot;sr-only&quot; id=&quot;footnote-label&quot;&gt;Footnotes&lt;/h2&gt;
&lt;ol&gt;
&lt;li id=&quot;user-content-fn-2&quot;&gt;
&lt;p&gt;One day, I would love to get rid of that dependency and use only &lt;code&gt;CryptoKit&lt;/code&gt;
to generate tokens. If you could help, let me know. &lt;a href=&quot;#user-content-fnref-2&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 1&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-1&quot;&gt;
&lt;p&gt;Check out &lt;a href=&quot;https://github.com/dirtyhenry/swift-hoods/blob/main/Tests/HoodsTests/JWTFactoryTests.swift&quot;&gt;&lt;code&gt;JWTFactoryTests&lt;/code&gt; in &lt;code&gt;dirtyhenry/swift-hoods&lt;/code&gt;&lt;/a&gt; to see those
tests. &lt;a href=&quot;#user-content-fnref-1&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 2&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;
</content:encoded><category>Swift</category><category>JSON Web Tokens</category><category>Open Source</category><category>iOS</category></item><item><title>Slugify in Swift with applyingTransform</title><link>https://www.mickf.net/tech/slugify-in-swift/</link><guid isPermaLink="true">https://www.mickf.net/tech/slugify-in-swift/</guid><description>Foundation&apos;s `applyingTransform` function can help create slugs in Swift without external dependencies. Here&apos;s how.</description><pubDate>Wed, 03 Jul 2024 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;I’ve recently added a function to my &lt;a href=&quot;https://github.com/dirtyhenry/swift-blocks&quot;&gt;Blocks&lt;/a&gt; library that allows you to
slugify any string.&lt;/p&gt;
&lt;h2 id=&quot;what-is-a-slug&quot;&gt;What is a slug&lt;/h2&gt;
&lt;p&gt;A &lt;em&gt;slug&lt;/em&gt; is the part of a URL that identifies a specific page on a website in a
readable and concise way. For example, in the URL &lt;code&gt;www.example.com/about-us&lt;/code&gt;,
the slug is “about-us.”&lt;/p&gt;
&lt;p&gt;Slugs have various other uses: you can use them to create file names in your
file system, as Git branch names for issues you’re working on, and more.&lt;/p&gt;
&lt;h2 id=&quot;what-we-need&quot;&gt;What we need&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Essentials.&lt;/strong&gt; Slugs should only contain &lt;code&gt;[a-z0-9-]&lt;/code&gt; characters ie no spaces,
tabs, or underscores. Just letters, digits, and hyphens.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Accents removal.&lt;/strong&gt; We want to remove accents from languages that use the Latin
alphabet. This means characters like &lt;code&gt;è&lt;/code&gt;, &lt;code&gt;é&lt;/code&gt;, &lt;code&gt;ê&lt;/code&gt;, &lt;code&gt;ë&lt;/code&gt;, &lt;code&gt;ě&lt;/code&gt;, &lt;code&gt;ẽ&lt;/code&gt;, &lt;code&gt;ē&lt;/code&gt;, &lt;code&gt;ė&lt;/code&gt;, and
&lt;code&gt;ę&lt;/code&gt; should all be transformed to &lt;code&gt;e&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Support for more alphabets.&lt;/strong&gt; Strings written in alphabets other than Latin
should be romanized as accurately as possible.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Basic emoji support.&lt;/strong&gt; Emojis should be removed from the slug, &lt;strong&gt;except&lt;/strong&gt; when
the string consists solely of emojis.&lt;/p&gt;
&lt;p&gt;We aim to achieve this without relying on external dependencies. Just Swift and
Foundation.&lt;/p&gt;
&lt;h2 id=&quot;the-magic-of-applyingtransform&quot;&gt;The magic of &lt;code&gt;applyingTransform&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;StringProtocol&lt;/code&gt; protocol provides a powerful function called
&lt;a href=&quot;https://developer.apple.com/documentation/swift/stringprotocol/applyingtransform(_:reverse:)/&quot;&gt;&lt;code&gt;applyingTransform&lt;/code&gt;&lt;/a&gt; that performs most of these transformations. By
applying a series of transformations, you can create an effective &lt;code&gt;slugify&lt;/code&gt;
function. The ones I used include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;.toLatin&lt;/code&gt;: Transliterates a string from any script to the Latin script;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;.stripDiacritics&lt;/code&gt;: Removes diacritics from a string;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;.stripCombiningMarks&lt;/code&gt;: Removes combining marks from a string;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;.toUnicodeName&lt;/code&gt;: Converts characters to their Unicode names.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;examples&quot;&gt;Examples&lt;/h2&gt;
&lt;p&gt;Here are some examples of what &lt;code&gt;.slugify()&lt;/code&gt; does:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Hello Luka Dončić&lt;/code&gt; → &lt;code&gt;hello-luka-doncic&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;😀 LOL&lt;/code&gt; → &lt;code&gt;lol&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;😀&lt;/code&gt; → &lt;code&gt;grinning-face&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;🎸&lt;/code&gt; → &lt;code&gt;guitar&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;สวัสดีชาวโลก&lt;/code&gt; → &lt;code&gt;swasdi-chaw-lok&lt;/code&gt; (Thai for “Hello World”)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;the-code&quot;&gt;The code&lt;/h2&gt;
&lt;p&gt;You can check out &lt;a href=&quot;https://github.com/dirtyhenry/swift-blocks/blob/main/Sources/Blocks/Extensions/StringProtocol.swift&quot;&gt;an up-to-date version of slugify on GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Here’s the current implementation:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; extension&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; StringProtocol&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    func&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; slugify&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;() &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; String&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        var&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; slug &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; lowercased&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        slug &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; slug.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;applyingTransform&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(.toLatin, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;reverse&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;??&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; slug&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        slug &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; slug.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;applyingTransform&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(.stripDiacritics, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;reverse&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;??&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; slug&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        slug &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; slug.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;applyingTransform&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(.stripCombiningMarks, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;reverse&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;??&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; slug&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        slug &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; slug.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;replacingOccurrences&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;of&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;[^a-z0-9]+&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;with&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;-&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;options&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: .regularExpression)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        slug &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; slug.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;trimmingCharacters&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;CharacterSet&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;charactersIn&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;-&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        if&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; !&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;isEmpty, slug.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;isEmpty&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;            if&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; extendedSelf &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; applyingTransform&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(.toUnicodeName, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;reverse&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;?&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;                .&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;replacingOccurrences&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;of&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;\\&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;N&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;with&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; !=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; extendedSelf {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;                return&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; extendedSelf.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;slugify&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;            }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        return&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; slug&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
</content:encoded><category>Swift</category><category>Open Source</category></item><item><title>Final notes on migrating from SPIP to Jekyll</title><link>https://www.mickf.net/tech/migration-from-spip-to-jekyll/</link><guid isPermaLink="true">https://www.mickf.net/tech/migration-from-spip-to-jekyll/</guid><description>Memories from 2 things that helped me: a simple Docker Compose MySQL stack and a Ruby script to migrate database entries to Markdown files</description><pubDate>Thu, 04 Apr 2024 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;About 4 years ago, &lt;a href=&quot;https://www.deadrooster.org/renaissance-du-phoenix/&quot;&gt;my long-running server died&lt;/a&gt;. Its main job was hosting
&lt;a href=&quot;https://www.deadrooster.org/&quot;&gt;deadrooster.org&lt;/a&gt;, my website about pop culture — mostly written in French —
via &lt;a href=&quot;https://www.spip.net/&quot;&gt;SPIP&lt;/a&gt;, a publishing system.&lt;/p&gt;
&lt;p&gt;Today, I can finally say that I completed the migration from SPIP to Jekyll.&lt;/p&gt;
&lt;p&gt;Yes, it took me about 4 years to migrate. Of course, it was not a full-time job,
and Dead Rooster remains mostly unnoticed. But still, I wanted to recover as
much as I could.&lt;/p&gt;
&lt;p&gt;This post is to archive the tools I wrote to achieve this goal, ie:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;A temporary stack to host a MySQL database;&lt;/li&gt;
&lt;li&gt;A script to automate as much as possible the storage of the posts from
database entries to Markdown files with front matters.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;an-easy-way-to-run-a-mysql-stack&quot;&gt;An easy way to run a MySQL stack&lt;/h2&gt;
&lt;p&gt;Using &lt;a href=&quot;https://docs.docker.com/compose/&quot;&gt;Docker Compose&lt;/a&gt;, it was as simple as having a &lt;code&gt;compose.yml&lt;/code&gt; with the
following:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;yaml&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;# Use root/example as user/password credentials&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#85E89D&quot;&gt;version&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;3.1&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#85E89D&quot;&gt;services&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#85E89D&quot;&gt;  db&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#85E89D&quot;&gt;    image&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;mysql&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#85E89D&quot;&gt;    command&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;--default-authentication-plugin=mysql_native_password&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#85E89D&quot;&gt;    restart&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;always&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#85E89D&quot;&gt;    ports&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;      - &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;12345:3306&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#85E89D&quot;&gt;    environment&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#85E89D&quot;&gt;      MYSQL_ROOT_PASSWORD&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;example&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#85E89D&quot;&gt;  adminer&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#85E89D&quot;&gt;    image&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;adminer&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#85E89D&quot;&gt;    restart&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;always&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#85E89D&quot;&gt;    ports&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;      - &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;8080:8080&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and then run:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sh&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;docker-compose&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; -f&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; compose.yml&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; up&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and, finally, connect to &lt;code&gt;http://localhost:8080/&lt;/code&gt; via a browser.&lt;/p&gt;
&lt;h2 id=&quot;a-basic-script-to-convert-spip-contents-to-markdown&quot;&gt;A basic script to convert SPIP contents to Markdown&lt;/h2&gt;
&lt;p&gt;I &lt;a href=&quot;https://github.com/dirtyhenry/jekyll-import/tree/spip-import&quot;&gt;forked&lt;/a&gt; &lt;a href=&quot;https://github.com/jekyll/jekyll-import&quot;&gt;&lt;code&gt;jekyll-import&lt;/code&gt;&lt;/a&gt; and created a SPIP impoter. It is pretty
hacky and definitely not a candidate for a pull request on the upstream
repository, but it could maybe help people out there. Here it is:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;ruby&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;# frozen_string_literal: false&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;require&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &apos;active_support&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;module&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; JekyllImport&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;  module&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; Importers&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    class&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; Spip&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; &amp;lt; &lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;Importer&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;      def&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; self.require_deps&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;        JekyllImport&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;require_with_fallback&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;%w(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;          rubygems&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;          sequel&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;          fileutils&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;          safe_yaml&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;          unidecode&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;          active_support&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;          active_support/core_ext/string&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;        )&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;      end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;      def&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; self.specify_options&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(c)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        c.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;option&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;dbname&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,         &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;--dbname DB&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,           &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;Database name (default: &apos;&apos;)&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        c.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;option&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;socket&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,         &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;--socket SOCKET&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,       &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;Database socket (default: &apos;&apos;)&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        c.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;option&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;user&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,           &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;--user USER&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,           &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;Database user name (default: &apos;&apos;)&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        c.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;option&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;password&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,       &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;--password PW&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,         &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;Database user&apos;s password (default: &apos;&apos;)&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        c.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;option&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;host&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,           &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;--host HOST&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,           &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;Database host name (default: &apos;localhost&apos;)&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        c.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;option&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;port&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,           &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;--port PORT&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,           &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;Database port number (default: &apos;&apos;)&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        c.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;option&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;table_prefix&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,   &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;--table_prefix PREFIX&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;Table prefix name (default: &apos;wp_&apos;)&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        c.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;option&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;site_prefix&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,    &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;--site_prefix PREFIX&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,  &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;Site prefix name (default: &apos;&apos;)&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        c.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;option&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;clean_entities&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;--clean_entities&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,      &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;Whether to clean entities (default: true)&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        c.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;option&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;comments&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,       &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;--comments&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,            &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;Whether to import comments (default: true)&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        c.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;option&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;categories&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,     &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;--categories&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,          &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;Whether to import categories (default: true)&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        c.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;option&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;tags&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,           &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;--tags&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,                &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;Whether to import tags (default: true)&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        c.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;option&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;more_excerpt&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,   &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;--more_excerpt&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,        &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;Whether to use more excerpt (default: true)&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        c.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;option&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;more_anchor&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,    &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;--more_anchor&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,         &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;Whether to use more anchor (default: true)&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        c.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;option&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;status&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,         &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;--status STATUS,STATUS2&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;Array&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;                 &quot;Array of allowed statuses (default: [&apos;publish&apos;], other options: &apos;draft&apos;, &apos;private&apos;, &apos;revision&apos;)&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;      end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;      def&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; self.process&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(opts)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FFAB70&quot;&gt;        options&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;          :user&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;           =&amp;gt; opts.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;fetch&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;user&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;          :pass&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;           =&amp;gt; opts.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;fetch&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;password&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;          :host&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;           =&amp;gt; opts.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;fetch&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;host&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;localhost&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;          :port&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;           =&amp;gt; opts.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;fetch&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;port&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;3306&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;          :socket&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;         =&amp;gt; opts.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;fetch&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;socket&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;nil&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;          :dbname&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;         =&amp;gt; opts.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;fetch&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;dbname&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;          :table_prefix&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;   =&amp;gt; opts.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;fetch&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;table_prefix&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;spip_&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;          :site_prefix&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    =&amp;gt; opts.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;fetch&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;site_prefix&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;nil&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;          :clean_entities&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; =&amp;gt; opts.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;fetch&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;clean_entities&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;          :comments&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;       =&amp;gt; opts.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;fetch&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;comments&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;          :categories&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;     =&amp;gt; opts.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;fetch&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;categories&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;          :tags&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;           =&amp;gt; opts.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;fetch&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;tags&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;          :more_excerpt&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;   =&amp;gt; opts.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;fetch&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;more_excerpt&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;          :more_anchor&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    =&amp;gt; opts.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;fetch&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;more_anchor&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;          :extension&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;      =&amp;gt; opts.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;fetch&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;extension&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;html&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;          :status&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;         =&amp;gt; opts.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;fetch&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;status&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, [&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;publish&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;]).&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;map&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:to_sym&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;# :draft, :private, :revision&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        if&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; options[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:clean_entities&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;          begin&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;            require&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;htmlentities&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;          rescue&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; LoadError&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;            STDERR&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;puts&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;Could not require &apos;htmlentities&apos;, so the &quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;                        &quot;:clean_entities option is now disabled.&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;            options[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:clean_entities&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; false&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;          end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;        FileUtils&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;mkdir_p&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;_posts&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;        FileUtils&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;mkdir_p&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;_drafts&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; options[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:status&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;].&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;include?&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; :draft&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FFAB70&quot;&gt;        db&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; Sequel&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;mysql2&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(options[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:dbname&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;                           :user&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;     =&amp;gt; options[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:user&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;                           :password&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; =&amp;gt; options[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:pass&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;                           :socket&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;   =&amp;gt; options[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:socket&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;                           :host&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;     =&amp;gt; options[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:host&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;                           :port&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;     =&amp;gt; options[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:port&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;                           :encoding&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; =&amp;gt; &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;utf8&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FFAB70&quot;&gt;        px&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; options[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:table_prefix&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FFAB70&quot;&gt;        sx&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; options[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:site_prefix&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FFAB70&quot;&gt;        page_name_list&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FFAB70&quot;&gt;        page_name_query&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;           SELECT&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;             posts.id_article  AS `id`,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;             posts.titre       AS `title`,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;             posts.id_rubrique AS `category_id`&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;           FROM &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;#{px}#{sx}&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;articles AS `posts`&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        db[page_name_query].&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;each&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; do&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; |page|&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;          page[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:slug&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; sluggify&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(page[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:title&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;])&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;          page_name_list[ page[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:id&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;] ] &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;            :slug&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;   =&amp;gt; page[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:slug&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;            :parent&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; =&amp;gt; page[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:parent&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;          }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FFAB70&quot;&gt;        posts_query&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;           SELECT&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;             posts.id_article    AS `id`,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;             posts.titre         AS `title`,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;             posts.soustitre     AS `subtitle`,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;             posts.descriptif    AS `post_description`,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;             posts.chapo         AS `lead`,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;             posts.texte         AS `content`,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;             posts.date          AS `date`,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;             posts.lang          AS `lang`,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;             users.nom           AS `author`,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;             users.login         AS `author_login`,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;             users.email         AS `author_email`&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;           FROM &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;#{px}#{sx}&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;articles AS `posts`&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;             LEFT JOIN &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;#{px}#{sx}&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;auteurs_liens AS `temp`&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;               ON posts.id_article = temp.id_objet&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;             LEFT JOIN &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;#{px}#{sx}&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;auteurs AS `users`&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;               ON temp.id_auteur = users.id_auteur&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        if&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; options[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:status&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; !&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;options[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:status&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;].&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;empty?&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FFAB70&quot;&gt;          status&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; options[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:status&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;][&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;          posts_query &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;           WHERE posts.statut = &apos;&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;#{status}&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&apos;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;          options[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:status&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;][&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;..&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;].&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;each&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; do&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; |post_status|&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;            posts_query &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot; OR&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;             posts.statut = &apos;&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;#{post_status}&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&apos;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;          end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        db[posts_query].&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;each&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; do&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; |post|&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;          process_post&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(post, db, options, page_name_list)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FFAB70&quot;&gt;        assets_query&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;           SELECT&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;             id_document    AS `id`,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;             extension      AS `extension`,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;             fichier        AS `path`&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;           FROM &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;#{px}#{sx}&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;documents&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;        File&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;open&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;asset_download_script.sh&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;w&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;do&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; |f|&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;          f.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;puts&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;#!/usr/bin/env bash -x&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;          f.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;puts&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;          f.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;puts&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;SITE_BASE_URL=TO_COMPLETE&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;          f.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;puts&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;          f.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;puts&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;mkdir _assets&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;          db[assets_query].&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;each&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; do&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; |asset|&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;            f.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;puts&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;curl $SITE_BASE_URL/&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;#{asset[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:path&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;]}&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; -o _assets/&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;#{asset[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:id&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;]}&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;#{&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;File&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;basename&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;(asset[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:path&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;])}&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;          end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;      end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;      def&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; self.process_post&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(post, db, options, page_name_list)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FFAB70&quot;&gt;        px&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; options[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:table_prefix&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FFAB70&quot;&gt;        sx&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; options[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:site_prefix&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FFAB70&quot;&gt;        extension&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; options[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:extension&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FFAB70&quot;&gt;        title&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; post[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:title&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FFAB70&quot;&gt;        title&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; clean_entities&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(title) &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; options[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:clean_entities&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FFAB70&quot;&gt;        slug&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; post[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:slug&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FFAB70&quot;&gt;        slug&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; sluggify&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(title) &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; !&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;slug &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;||&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; slug.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;empty?&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FFAB70&quot;&gt;        date&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; post[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:date&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;||&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; Time&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;now&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FFAB70&quot;&gt;        name&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; format&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;%02d-%02d-%02d-%s.%s&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, date.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;year&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, date.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;month&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, date.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;day&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, slug, extension)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FFAB70&quot;&gt;        content&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; post[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:content&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;].&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;to_s&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FFAB70&quot;&gt;        excerpt&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; post[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:excerpt&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;].&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;to_s&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FFAB70&quot;&gt;        categories&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; []&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FFAB70&quot;&gt;        tags&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; []&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        if&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; options[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:categories&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;||&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; options[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:tags&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FFAB70&quot;&gt;          cquery&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;            &quot;SELECT&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;               terms.titre AS `name`,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;               terms.type AS `type`&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;             FROM&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;               #{px}#{sx}&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;mots AS `terms`,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;               #{px}#{sx}&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;mots_liens AS `trels`&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;             WHERE&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;               trels.id_objet = &apos;&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;#{post[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:id&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;]}&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&apos; AND&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;               trels.id_mot = terms.id_mot&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;          db[cquery].&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;each&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; do&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; |term|&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;            if&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; options[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:categories&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FFAB70&quot;&gt;              new_category&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; options[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:clean_entities&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;?&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; clean_entities&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(term[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:type&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;]) : term[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:type&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;              unless&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; categories.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;include?&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; new_category&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;                categories &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; new_category&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;              end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;            end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;            if&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; options[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:tags&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FFAB70&quot;&gt;              new_tag&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; options[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:clean_entities&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;?&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; clean_entities&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(term[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:name&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;]) : term[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:name&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;              unless&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; tags.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;include?&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; new_tag&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;                tags &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; new_tag&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;              end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;            end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;          end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FFAB70&quot;&gt;        comments&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; []&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        if&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; options[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:comments&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FFAB70&quot;&gt;          cquery&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;            &quot;SELECT&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;               auteur         AS `author`,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;               email_auteur   AS `author_email`,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;               date_heure     AS `date`,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;               titre          AS `title`,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;               texte          AS `content`&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;             FROM &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;#{px}#{sx}&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;forum&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;             WHERE&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;               id_objet = &apos;&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;#{post[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:id&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;]}&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&apos; AND&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;               statut = &apos;publie&apos;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;          db[cquery].&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;each&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; do&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; |comment|&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FFAB70&quot;&gt;            comcontenttitle&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; comment[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:title&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;].&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;to_s&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;            comcontenttitle.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;force_encoding&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;UTF-8&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; comcontenttitle.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;respond_to?&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:force_encoding&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FFAB70&quot;&gt;            comcontenttitle&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; clean_entities&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(comcontent) &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; options[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:clean_entities&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FFAB70&quot;&gt;            comcontent&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; comment[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:content&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;].&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;to_s&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;            comcontent.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;force_encoding&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;UTF-8&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; comcontent.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;respond_to?&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:force_encoding&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FFAB70&quot;&gt;            comcontent&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; clean_entities&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(comcontent) &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; options[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:clean_entities&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FFAB70&quot;&gt;            comauthor&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; comment[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:author&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;].&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;to_s&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FFAB70&quot;&gt;            comauthor&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; clean_entities&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(comauthor) &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; options[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:clean_entities&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;            comments &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;              &quot;author&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;       =&amp;gt; comauthor,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;              &quot;author_email&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; =&amp;gt; comment[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:author_email&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;].&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;to_s&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;              &quot;date&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;         =&amp;gt; comment[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:date&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;].&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;to_s&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;              &quot;title&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        =&amp;gt; comcontenttitle,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;              &quot;content&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;      =&amp;gt; comcontent,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;            }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;          end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;          comments.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;sort!&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; { |a, b| a[&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;date&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;&amp;lt;=&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; b[&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;date&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;] }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;        # Get the relevant fields as a hash, delete empty fields and&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;        # convert to YAML for the header.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FFAB70&quot;&gt;        data&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;          &quot;layout&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        =&amp;gt; post[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:type&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;].&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;to_s&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;          &quot;status&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        =&amp;gt; post[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:status&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;].&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;to_s&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;          &quot;published&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;     =&amp;gt; post[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:status&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;].&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;to_s&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; ==&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;draft&quot;&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; ?&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; nil&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; : (post[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:status&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;].&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;to_s&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; ==&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;publish&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;          &quot;title&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;         =&amp;gt; title.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;to_s&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;          &quot;author&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        =&amp;gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;            &quot;display_name&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; =&amp;gt; post[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:author&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;].&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;to_s&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;            &quot;login&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        =&amp;gt; post[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:author_login&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;].&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;to_s&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;            &quot;email&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        =&amp;gt; post[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:author_email&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;].&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;to_s&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;            &quot;url&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;          =&amp;gt; post[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:author_url&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;].&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;to_s&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;          },&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;          &quot;author_login&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;  =&amp;gt; post[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:author_login&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;].&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;to_s&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;          &quot;author_email&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;  =&amp;gt; post[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:author_email&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;].&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;to_s&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;          &quot;author_url&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    =&amp;gt; post[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:author_url&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;].&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;to_s&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;          &quot;excerpt&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;       =&amp;gt; excerpt,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;          &quot;wordpress_id&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;  =&amp;gt; post[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:id&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;          &quot;wordpress_url&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; =&amp;gt; post[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:guid&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;].&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;to_s&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;          &quot;date&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;          =&amp;gt; date.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;to_s&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;          &quot;date_gmt&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;      =&amp;gt; post[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:date_gmt&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;].&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;to_s&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;          &quot;categories&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    =&amp;gt; options[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:categories&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;?&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; categories : &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;nil&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;          &quot;tags&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;          =&amp;gt; options[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:tags&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;?&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; tags : &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;nil&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;          &quot;comments&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;      =&amp;gt; options[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:comments&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;?&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; comments : &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;nil&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        }.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;delete_if&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; { |_k, v| v.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;nil?&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; ||&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; v &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; }.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;to_yaml&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        if&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; post[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:type&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;page&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FFAB70&quot;&gt;          filename&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; page_path&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(post[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:id&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;], page_name_list) &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;index.&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;#{extension}&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;          FileUtils&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;mkdir_p&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;File&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;dirname&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(filename))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        elsif&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; post[&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:status&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;draft&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FFAB70&quot;&gt;          filename&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;_drafts/&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;#{slug}&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;.md&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        else&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FFAB70&quot;&gt;          filename&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;_posts/&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;#{name}&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;        # Write out the data and content to file&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;        File&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;open&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(filename, &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;w&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;do&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; |f|&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;          f.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;puts&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; data&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;          f.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;puts&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;---&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;          f.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;puts&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; content&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;      end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;      def&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; self.clean_entities&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(text)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        text.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;force_encoding&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;UTF-8&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; text.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;respond_to?&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:force_encoding&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FFAB70&quot;&gt;        text&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; HTMLEntities&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;encode&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(text, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:named&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;        # We don&apos;t want to convert these, it would break all&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;        # HTML tags in the post and comments.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        text.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;gsub!&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;&amp;amp;amp;&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;&amp;amp;&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        text.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;gsub!&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;&amp;amp;lt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;&amp;lt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        text.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;gsub!&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;&amp;amp;gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;&amp;gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        text.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;gsub!&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;&amp;amp;quot;&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&apos;&quot;&apos;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        text.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;gsub!&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;&amp;amp;apos;&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;&apos;&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        text.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;gsub!&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;&amp;amp;#47;&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;/&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        text&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;      end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;      def&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; self.sluggify&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(title)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        title&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;      end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;      def&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; self.page_path&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(page_id, page_name_list)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        if&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; page_name_list.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;key?&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(page_id)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;          [&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;            page_path&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(page_name_list[page_id][&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:parent&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;], page_name_list),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;            page_name_list[page_id][&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;:slug&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;            &quot;/&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;          ].&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;join&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        else&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;          &quot;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;      end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;  end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And calling the importer looked like this:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sh&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;jekyll&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; import&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; spip&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;    --dbname&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; deadrooster&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;    --user&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; root&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;    --password&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; example&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;    --host&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; 127.0.0.1&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;    --port&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; 12345&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;final-note&quot;&gt;Final note&lt;/h2&gt;
&lt;p&gt;The sad truth is that, today, I already feel like Jekyll is dying, and it might
be time to migrate to something else. Again. Isn’t it a waste of time to keep
migrating things over and over again? Maybe.&lt;/p&gt;
&lt;p&gt;But is it fun? Definitely.&lt;/p&gt;
</content:encoded><category>SPIP</category><category>Jekyll</category><category>Docker</category><category>Web Publishing</category></item><item><title>xcrun simctl list devices: Picking a Simulator for CI</title><link>https://www.mickf.net/tech/finding-ios-simulators-identifiers/</link><guid isPermaLink="true">https://www.mickf.net/tech/finding-ios-simulators-identifiers/</guid><description>&quot;Tests must be run on a concrete device&quot;: xcodebuild test on CI needs a simulator ID. Three ways to get one: Fastlane, Point-Free, and a Swift script.</description><pubDate>Fri, 29 Mar 2024 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;GitHub Actions are powerful tools and a great complement to Xcode Cloud for
Swift projects’ continuous integration.&lt;/p&gt;
&lt;p&gt;However, I encountered an issue: when using &lt;code&gt;xcodebuild test&lt;/code&gt; for iOS, a
&lt;em&gt;concrete device&lt;/em&gt; is required:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sh&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;Cannot&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; test&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; target&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; “FooTests”&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; on&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; “Any&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; iOS&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; Device”:&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; Tests&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; must&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; be&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; run&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; on&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; a&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; concrete&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; device&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The challenge then arose: how to identify the simulator identifiers suitable for
the intended device?&lt;/p&gt;
&lt;p&gt;Of course, Apple provides a command for this:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sh&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;xcrun&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; simctl&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; list&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; devices&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; available&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But then CI requires parsing and filtering on this command’s output. Here are 3
solutions to do so.&lt;/p&gt;
&lt;h2 id=&quot;fastlane-era&quot;&gt;Fastlane era&lt;/h2&gt;
&lt;p&gt;Fastlane provides a &lt;code&gt;FastlaneCore::DeviceManager&lt;/code&gt; that greatly assists in
inspecting available devices.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;ruby&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;require&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &apos;fastlane_core/device_manager&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;# Usage: latest_simulator_with_name(&apos;iPhone Xʀ&apos;).udid&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; latest_simulator_with_name&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(device_name)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FFAB70&quot;&gt;  result&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;    FastlaneCore&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;DeviceManager&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;simulators&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;                               .&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;select&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; { |s| s.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; ==&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; device_name }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;                               .&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;max_by&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; { |s| &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;Gem&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;Version&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;create&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(s.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;os_version&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;) }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;  return&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; result &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;unless&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; result.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;nil?&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;  FastlaneCore&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;UI&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;error&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;#{device_name}&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; missing. Please select one of the following:&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;  FastlaneCore&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;DeviceManager&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;simulators&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;                             .&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;each&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; { |s| &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;FastlaneCore&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;UI&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;message&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;#{s.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;#{s.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;os_version&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;)&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;  raise&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;Device with name &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;#{device_name}&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; cannot be found. Please install it.&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Despite my extensive use of Fastlane, I’m starting to perceive a decline in its
relevance with the emergence of Xcode Cloud.&lt;/p&gt;
&lt;h2 id=&quot;exploring-the-point-free-approach&quot;&gt;Exploring the Point-Free Approach&lt;/h2&gt;
&lt;p&gt;As an admirer of the Point-Free team’s work, I investigated their methods and
discovered &lt;a href=&quot;https://github.com/pointfreeco/swift-composable-architecture/blob/2722a3466b78860ebf493103fc82ac85b076e1bd/Makefile&quot;&gt;a useful yet succinct shell command&lt;/a&gt;.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;makefile&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;PLATFORM_IOS = iOS Simulator,id=&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;$(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;call&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; udid_for,iOS 17.2,iPhone \d\+ Pro [^M])&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;…&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;define&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; udid_for&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;$(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;shell&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; xcrun simctl list devices available &apos;$(&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;)&apos; | grep &apos;$(&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;)&apos; | sort -r | head -1 | awk -F &apos;[()]&apos; &apos;{ print &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;$$&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;(NF-3) }&apos;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;endef&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;While efficient, it lacks readability.&lt;/p&gt;
&lt;h2 id=&quot;implementing-a-swift-solution&quot;&gt;Implementing a Swift Solution&lt;/h2&gt;
&lt;p&gt;To address this challenge, I developed a Swift script to obtain the necessary
information. You can find &lt;a href=&quot;https://github.com/dirtyhenry/swift-blocks/blob/main/Scripts/ListDevices.swift&quot;&gt;the script on the Scripts section of my Blocks
project&lt;/a&gt; or as &lt;a href=&quot;https://github.com/dirtyhenry/swift-blocks/blob/main/Examples/BlocksCLI/Sources/BlocksCLI/DevTools/ListDevicesCommand.swift&quot;&gt;a command of the CLI&lt;/a&gt; that I provide with this tool.&lt;/p&gt;
&lt;p&gt;To use it in continuous integration (CI), follow these steps:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;shell&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;# Download the script and make it executable&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;curl&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; -sSL&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; https://raw.githubusercontent.com/dirtyhenry/swift-blocks/main/Scripts/ListDevices.swift&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;  -o&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; findDevice&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;chmod&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; +x&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; findDevice&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;# Find the device identifier&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;DEVICE_ID&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;$(&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;./findDevice&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;$TEST_IOS_VERSION&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;$TEST_IOS_SIMULATOR_MODEL&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;# Run the test&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;set&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; -o&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; pipefail&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; &amp;amp;&amp;amp; &lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;xcodebuild&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; test&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;    -skipMacroValidation&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; -skipPackagePluginValidation&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;    -workspace&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; foo.xcworkspace&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;    -scheme&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;bar&quot;&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;    -destination&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; platform=&quot;iOS Simulator,id=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;$DEVICE_ID&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    |&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; xcpretty&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;💡 I recommend setting &lt;code&gt;TEST_IOS_VERSION&lt;/code&gt; and &lt;code&gt;TEST_IOS_SIMULATOR_MODEL&lt;/code&gt; as
environment variables so that failures after Xcode updates can be resolved
without changing the code.&lt;/p&gt;
</content:encoded><category>iOS</category><category>GitHub Actions</category><category>Continuous integration</category><category>Open Source</category></item><item><title>My Mission Statement as a Programmer</title><link>https://www.mickf.net/tech/developer-mission-statement/</link><guid isPermaLink="true">https://www.mickf.net/tech/developer-mission-statement/</guid><description>Climate Friendliness, Human Friendliness, Mastery, IndieWeb Friendliness, Big Corporation Cautiousness, Durability &amp; Sustainability serves as a guiding compass in my journey as a programmer</description><pubDate>Sat, 06 Jan 2024 00:00:00 GMT</pubDate><content:encoded>&lt;h2 id=&quot;tldr&quot;&gt;tl;dr&lt;/h2&gt;
&lt;p&gt;As a programmer, I create eco-conscious software with user-friendly design,
embracing IndieWeb principles. I’m cautious with big corporations, upholding
ethics and user rights. My goal is to produce durable and sustainable code,
prioritizing maintainability and developer well-being. I respond swiftly to
evolving challenges for impactful work in a changing tech landscape.&lt;/p&gt;
&lt;h2 id=&quot;a-longer-version&quot;&gt;A longer version&lt;/h2&gt;
&lt;p&gt;Let me explain. There is a sense of uneasiness with the state of the world these
days. After having the privilege to spend a fun and peaceful holiday season, I
wanted to do a headcheck on where I stand with my role as a programmer and if I
am aligned with my aspirations and values. So I decided to write my mission
statement. I will develop each of its components with an example of how I think
I apply it.&lt;/p&gt;
&lt;h3 id=&quot;-climate-friendliness&quot;&gt;🌍 Climate Friendliness&lt;/h3&gt;
&lt;p&gt;I need to consider all environmental impacts of the code I write: the hardware
it runs on, the energy it requires, its purpose for the people running it.&lt;/p&gt;
&lt;p&gt;Example. I work for &lt;a href=&quot;https://memo.bank/&quot;&gt;Memo Bank&lt;/a&gt;, a bank for small and medium-sized
companies, that &lt;a href=&quot;https://memo.bank/nos-engagements/&quot;&gt;prioritizes in a no bull-shit way&lt;/a&gt; the transition to a low
carbon economy. It has been recognised as such by &lt;a href=&quot;https://reclaimfinance.org/site/&quot;&gt;Reclaim Finance&lt;/a&gt;, and is
one of the recommended banks on their website &lt;a href=&quot;https://change-de-banque.org/&quot;&gt;Change de banque&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&quot;-human-friendliness&quot;&gt;🤝 Human Friendliness&lt;/h3&gt;
&lt;p&gt;I prioritise security and user experience, in that order, to promote the
well-being of end-users. It involves creating software that is intuitive,
inclusive, and positively impacts users’ lives.&lt;/p&gt;
&lt;p&gt;Example. I feel that it was my main motivations to start running the &lt;a href=&quot;https://www.statium.app/newsletter&quot;&gt;Statium
Newsletter&lt;/a&gt;, a minimalistic soccer newsletter written in French that focuses
solely on the game. It filters out the noise from meaningless controversies,
&lt;a href=&quot;https://www.statium.app/newsletter/posts/newsletter-222&quot;&gt;poor journalistic practices&lt;/a&gt;, invasive advertisement and poor user
experience of alternative sources. As of today, &lt;a href=&quot;https://www.statium.app/&quot;&gt;statium.app&lt;/a&gt; has a perfect
score of 100 in Performance, Accessibility, Best Practices and SEO with
Lighthouse.&lt;/p&gt;
&lt;h3 id=&quot;-mastery&quot;&gt;⚡ Mastery&lt;/h3&gt;
&lt;p&gt;I want to continuously get better at my craft. Software is never “done”. A
skillset is never complete. I want to keep engaging on how to be a better
programmer, a better team member, and a better person.&lt;/p&gt;
&lt;p&gt;Example. I think a good practice of mastery is balancing being very curious with
just what it needs of focus. I wrote about &lt;a href=&quot;https://www.mickf.net/tech/side-projects-2022/&quot;&gt;why side-projects are so important
to me&lt;/a&gt; in the past: my curiosity is satisfied and the new things I learn have
many positive impacts on my job at Memo Bank.&lt;/p&gt;
&lt;h3 id=&quot;-indieweb-friendliness&quot;&gt;🌐 IndieWeb Friendliness&lt;/h3&gt;
&lt;p&gt;I support decentralised and people-focused technologies and products that help
individuals to have greater control over their online presence and their data.&lt;/p&gt;
&lt;p&gt;Example. I use RSS daily, I &lt;a href=&quot;https://indieweb.org/POSSE&quot;&gt;POSSE&lt;/a&gt;, I run a newsletter using
&lt;a href=&quot;https://buttondown.email/&quot;&gt;Buttondown&lt;/a&gt;, my microblogging platform of choice is &lt;a href=&quot;https://micro.blog/&quot;&gt;micro.blog&lt;/a&gt;, I
favor community-run or independant sources when I use links in my blog posts
(examples: &lt;a href=&quot;https://www.themoviedb.org/about&quot;&gt;TMDB&lt;/a&gt;, &lt;a href=&quot;https://www.discogs.com/about&quot;&gt;Discogs&lt;/a&gt;, &lt;a href=&quot;https://www.sports-reference.com/&quot;&gt;Sports Reference&lt;/a&gt;, etc.). I make &lt;a href=&quot;https://www.mickf.net/default-apps&quot;&gt;my
default apps&lt;/a&gt; public.&lt;/p&gt;
&lt;h3 id=&quot;️️-big-corporation-cautiousness&quot;&gt;🕵️‍♂️ Big Corporation Cautiousness&lt;/h3&gt;
&lt;p&gt;I am curious of the ethical considerations of big companies when engaging with
their products and technologies. I avoid those that compromise user privacy or
promote monopolistic behavior.&lt;/p&gt;
&lt;p&gt;Example. I stopped using Gmail, I don’t actively use Meta products or X. I am
wary of AI products and try to use them as sparingly and ethically as possible.&lt;/p&gt;
&lt;h3 id=&quot;-durability--sustainability&quot;&gt;🌱 Durability &amp;amp; Sustainability&lt;/h3&gt;
&lt;p&gt;I focus on the longevity and sustainability of the software I write. I want my
code to run for a long time, I want my mind and body to remain healthy for as
long as possible, and I want my online presence to live long.&lt;/p&gt;
&lt;p&gt;Example. I pick dependencies to rely on very carefully and sparingly, I express
&lt;a href=&quot;https://micro.mickf.net/2023/10/31/144426.html&quot;&gt;gratitude towards Open-Source developers&lt;/a&gt;, I avoid and fix
&lt;a href=&quot;https://micro.mickf.net/2023/03/08/every-month-or.html&quot;&gt;dead-links&lt;/a&gt;, I maintain &lt;a href=&quot;https://micro.mickf.net/2023/12/26/good-old-fashioned.html&quot;&gt;a good work-life balance&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;This mission statement serves as a guiding compass in my journey as a
programmer, reminding me of the values and principles I hold dear. It is a
commitment to creating software that not only meets the needs of the present but
also contributes positively to the future.&lt;/p&gt;
</content:encoded><category>IndieWeb</category></item><item><title>From block party to ’hood party</title><link>https://www.mickf.net/tech/blocks-and-hoods/</link><guid isPermaLink="true">https://www.mickf.net/tech/blocks-and-hoods/</guid><description>In 2023, I consolidated a dependency-free `swift-blocks` package, and I started working on a bigger `swift-hoods` package that builds upon my favorite dependencies.</description><pubDate>Sun, 24 Dec 2023 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Last year, I wrote about &lt;a href=&quot;https://www.mickf.net/tech/side-projects-2022/&quot;&gt;the joy sparked by side projects&lt;/a&gt;. This year, I
wanted to write another small recap of what I have accomplished in 2023. I kept
iterating on my projects but, more importantly, I kept consolidating the
packages that I use to share code between projects: &lt;a href=&quot;https://github.com/dirtyhenry/swift-blocks&quot;&gt;&lt;code&gt;swift-blocks&lt;/code&gt;&lt;/a&gt; and
&lt;a href=&quot;https://github.com/dirtyhenry/swift-hoods&quot;&gt;&lt;code&gt;swift-hoods&lt;/code&gt;&lt;/a&gt;. They are open-sourced and I wanted to formally introduce
them to the world. Here we are.&lt;/p&gt;
&lt;h2 id=&quot;-welcome-to-my-blocks&quot;&gt;🧱 Welcome to my blocks&lt;/h2&gt;
&lt;p&gt;For the last 2 years, I have been building &lt;code&gt;swift-blocks&lt;/code&gt;, a &lt;strong&gt;dependency-free&lt;/strong&gt;
library of tools and patterns I use repeatedly on all my Swift projects.&lt;/p&gt;
&lt;p&gt;It is not my first attempt to build such a library but it is the first time I
feel really satisfied about its usefulness. What was different this time? Two
factors:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;For one, Swift Package Manager provides a much more convenient way to share
code between projects than anything else in the past (Cocoapods, static
libraries, etc.);&lt;/li&gt;
&lt;li&gt;And then, I had a much better discipline to be consistent about
using/iterating/adding things to the library over time.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Today, I released version &lt;a href=&quot;https://github.com/dirtyhenry/swift-blocks/releases/tag/0.2.0&quot;&gt;0.2.0&lt;/a&gt; of the library. Here are the release notes.
Help yourself.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://swiftpackageindex.com/dirtyhenry/swift-blocks/0.2.0/documentation/blocks/networking&quot;&gt;&lt;strong&gt;🌐 Transport.&lt;/strong&gt;&lt;/a&gt; Added a tinier version of objcio’s
&lt;a href=&quot;https://github.com/objcio/tiny-networking&quot;&gt;&lt;code&gt;tiny-networking&lt;/code&gt;&lt;/a&gt; for concise
endpoint description, combining URL requests and response parsing. Introduced
&lt;a href=&quot;https://swiftpackageindex.com/dirtyhenry/swift-blocks/0.2.0/documentation/blocks/urlrequestheaderitem&quot;&gt;&lt;code&gt;URLRequestHeaderItem&lt;/code&gt;&lt;/a&gt;
struct mimicking Foundation’s &lt;code&gt;URLQueryItem&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://swiftpackageindex.com/dirtyhenry/swift-blocks/0.2.0/documentation/blocks/calendar&quot;&gt;&lt;strong&gt;📅 Calendar.&lt;/strong&gt;&lt;/a&gt; Improved internal architecture and developer experience
using &lt;em&gt;result builders&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;🔐 Security.&lt;/strong&gt; Introduced support for PKCE and associated helpers.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;🛟 Error Management.&lt;/strong&gt; Introduced
&lt;a href=&quot;https://swiftpackageindex.com/dirtyhenry/swift-blocks/0.2.0/documentation/blocks/simplemessageerror&quot;&gt;&lt;code&gt;SimpleMessageError&lt;/code&gt;&lt;/a&gt;
for convenient error handling, eliminating the need for forced unwrapping.
Ideal for scenarios where a full error domain is not necessary.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;🎨 SwiftUI.&lt;/strong&gt; Introduced
&lt;a href=&quot;https://swiftpackageindex.com/dirtyhenry/swift-blocks/0.2.0/documentation/blocks/taskstatebutton&quot;&gt;&lt;code&gt;TaskStateButton&lt;/code&gt;&lt;/a&gt;
interface components, for representing asynchronous
&lt;a href=&quot;https://swiftpackageindex.com/dirtyhenry/swift-blocks/0.2.0/documentation/blocks/taskstate&quot;&gt;task states&lt;/a&gt;.
Supports four states: not started, running, completed (success), or failed.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The &lt;a href=&quot;https://swiftpackageindex.com/&quot;&gt;documentation for this package&lt;/a&gt; is now hosted on the Swift Package
Index.&lt;/p&gt;
&lt;h2 id=&quot;️-welcome-to-my-hood&quot;&gt;🏘️ Welcome to my ’hood&lt;/h2&gt;
&lt;p&gt;In 2023 though, I have been using
&lt;a href=&quot;https://github.com/pointfreeco/swift-composable-architecture&quot;&gt;The Composable Architecture&lt;/a&gt;
a lot. And I built things that were depending on it. So in addition to
&lt;code&gt;swift-blocks&lt;/code&gt;, I started building another library, &lt;code&gt;swift-hoods&lt;/code&gt;&lt;sup&gt;&lt;a href=&quot;#user-content-fn-1&quot; id=&quot;user-content-fnref-1&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;, which has
a slightly bigger footprint in a project but is starting to turn out very useful
as well.&lt;/p&gt;
&lt;p&gt;Today, it is still in the early stages, but it already provides two useful
items:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A keychain TCA dependency for easy testing of code that uses keychain items;&lt;/li&gt;
&lt;li&gt;A processor for markdown files that include YAML front-matters.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I will detail how these work in the future.&lt;/p&gt;
&lt;p&gt;🎄 Have a happy holiday and happy new year 🥂.&lt;/p&gt;
&lt;section data-footnotes class=&quot;footnotes&quot;&gt;&lt;h2 class=&quot;sr-only&quot; id=&quot;footnote-label&quot;&gt;Footnotes&lt;/h2&gt;
&lt;ol&gt;
&lt;li id=&quot;user-content-fn-1&quot;&gt;
&lt;p&gt;Hood standing for neighborhood… ie a larger version of a block. Get it?
Kudos to my lovely wife for helping me find a good name. &lt;a href=&quot;#user-content-fnref-1&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 1&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;
</content:encoded><category>Swift</category><category>iOS</category><category>Open Source</category></item><item><title>From the start, get rid of types you don&apos;t control: a lesson (re)learned, Rolling Stones Edition</title><link>https://www.mickf.net/tech/keep-control-of-types/</link><guid isPermaLink="true">https://www.mickf.net/tech/keep-control-of-types/</guid><description>With my special sauce to future-proof your API and boost testability!</description><pubDate>Thu, 09 Nov 2023 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;In recent weeks, I’ve been reminded of a crucial lesson: “Do not use the objects
that are used by an API&lt;sup&gt;&lt;a href=&quot;#user-content-fn-1&quot; id=&quot;user-content-fnref-1&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; outside of the network layer of your application.”&lt;/p&gt;
&lt;p&gt;While this might seem like common sense in a technical job interview, the
real-world scenario brings its own challenges, especially when dealing with (a)
an in-house designed API&lt;sup&gt;&lt;a href=&quot;#user-content-fn-2&quot; id=&quot;user-content-fnref-2&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;, (b) budget constraints, and (c) the task of
writing boilerplate to convert DTO into model objects. It’s surprisingly easy to
give in to the temptation.&lt;/p&gt;
&lt;p&gt;I’m writing this post to emphasize that the effort is always worth it. To drive
this point home, I’ll provide real-life examples to illustrate why.&lt;/p&gt;
&lt;h2 id=&quot;example-1-future-proofing-an-api&quot;&gt;Example 1: Future-proofing an API&lt;/h2&gt;
&lt;p&gt;Let’s delve into an API where a payload includes the name of a member of the
Rolling Stones. And just for the heck of it, you decide to write an enum to
represent this value. Because… why not?&lt;/p&gt;
&lt;p&gt;Here’s the enum to kick things off:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;/// 👅 Members of the Rolling Stones&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;enum&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; RollingStone&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    case&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; mick&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;Mick Jagger&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    case&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; keith&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;Keith Richards&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    case&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; bill&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;Bill Wyman&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    case&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; charlie&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;Charlie Watts&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    case&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; brian&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;Brian Jones&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now, imagine using a DTO as a model:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;struct&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; DTOAsModel&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;Codable &lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; rollingStone: RollingStone&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;extension&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; RollingStone&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;Codable &lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;{}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And this works fine!&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;do&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; member1 &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; try&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; JSONDecoder&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;().&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;decode&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        DTOAsModel.&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;        from&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;        { &quot;rollingStone&quot;: &quot;Mick Jagger&quot; }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;        &quot;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;data&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: .&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;utf8&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;!&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    )&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;} &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;catch&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;    print&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(error)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But what if the backend adds “&lt;a href=&quot;https://en.wikipedia.org/wiki/Mick_Taylor&quot;&gt;Mick Taylor&lt;/a&gt;” as a new possible value that
your Swift code has no idea about?&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;do&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; member2 &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; try&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; JSONDecoder&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;().&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;decode&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        DTOAsModel.&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;        from&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;        { &quot;rollingStone&quot;: &quot;Mick Taylor&quot; }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;        &quot;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;data&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: .&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;utf8&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;!&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    )&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;} &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;catch&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;    print&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(error)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Oops, we crash.&lt;/p&gt;
&lt;p&gt;There’s a quick and dirty way to fix this, and I’ll admit, I’ve been guilty of
doing it. What if we changed &lt;code&gt;rollingStone&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;diff&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;  struct DTOAsModel2: Codable {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FDAEB7&quot;&gt;&lt;span style=&quot;user-select: none;&quot;&gt;-&lt;/span&gt;      let rollingStone: RollingStone&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#85E89D&quot;&gt;&lt;span style=&quot;user-select: none;&quot;&gt;+&lt;/span&gt;      let rollingStone: String&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#85E89D&quot;&gt;&lt;span style=&quot;user-select: none;&quot;&gt;+&lt;/span&gt; extension DTOAsModel {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#85E89D&quot;&gt;&lt;span style=&quot;user-select: none;&quot;&gt;+&lt;/span&gt;     var typedRollingStone: RollingStone? {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#85E89D&quot;&gt;&lt;span style=&quot;user-select: none;&quot;&gt;+&lt;/span&gt;         RollingStone(rawValue: rollingStone)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#85E89D&quot;&gt;&lt;span style=&quot;user-select: none;&quot;&gt;+&lt;/span&gt;     }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#85E89D&quot;&gt;&lt;span style=&quot;user-select: none;&quot;&gt;+&lt;/span&gt; }&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But then things get messy: objects are cluttered, autocompletion becomes hard to
read, initializers are not using the enum type, etc.&lt;/p&gt;
&lt;p&gt;So what I believe today is the right way to do things is:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Limit yourself to JSON-supported types in your DTO;&lt;/li&gt;
&lt;li&gt;Create typed model-objects;&lt;/li&gt;
&lt;li&gt;Add extensions that can convert from DTO objects into model objects in your
network layer.&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;struct&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; DTOAsJustDTO&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;Codable &lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; rollingStone: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;String&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;struct&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; ProperModel&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; rollingStone: RollingStone&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;extension&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; ProperModel&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    init?&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;dto&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: DTOAsJustDTO) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        guard&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; rollingStone &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; RollingStone&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;rawValue&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: dto.rollingStone) &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;else&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;            return&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; nil&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;        self&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.rollingStone &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; rollingStone&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;At the cost of a little boilerplate, you have two clean objects that do things
right.&lt;/p&gt;
&lt;p&gt;There are many options to support future values of the enum:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A &lt;a href=&quot;https://docs.swift.org/swift-book/documentation/the-swift-programming-language/initialization/#Failable-Initializers&quot;&gt;failable initializer&lt;/a&gt;, as in the example,&lt;/li&gt;
&lt;li&gt;A throwing initializer,&lt;/li&gt;
&lt;li&gt;A prop that can be optional,&lt;/li&gt;
&lt;li&gt;Adding an &lt;code&gt;.unknown&lt;/code&gt; rolling stone in the enum,&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It is really up to you and what feels best.&lt;/p&gt;
&lt;h2 id=&quot;example-2-improving-testability-of-code-you-dont-control&quot;&gt;Example 2: Improving testability of code you don’t control&lt;/h2&gt;
&lt;p&gt;Let’s take a look outside of the network layer, with other types of API that you
don’t control. The principles are similar.&lt;/p&gt;
&lt;p&gt;So now your app receives a push notification every time the Rolling Stones
release an album.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;func&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; showNotification&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;_&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; notification: UNNotification) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; userInfo &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; notification.request.content.userInfo&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    guard&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; albumName &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; userInfo[&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;albumName&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;as?&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; String&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; else&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        return&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;    print&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(albumName)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;How can you test this? You cannot create instances of &lt;code&gt;UNNotification&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Instead, get rid of things out of your control early on. Take control of things.
Like so:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;enum&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; NotificationEvent&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    case&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; newAlbum&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;extension&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; NotificationEvent&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    init?&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; notification: UNNotification) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        guard&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; albumName &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; notification.request.content.userInfo[&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;albumName&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;as?&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; String&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; else&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;            return&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; nil&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;        self&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; .&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;newAlbum&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(albumName)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;func&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; showNotification&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;_&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; notification: NotificationEvent) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    guard&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; case&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; NotificationEvent.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;newAlbum&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(albumName) &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; notification &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;else&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        return&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;    print&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(albumName)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;With this code, testing &lt;code&gt;NotificationEvent.init?(from:)&lt;/code&gt; will be challenging.
But testing &lt;code&gt;showNotification&lt;/code&gt; will be easy-peasy. Mission accomplished.&lt;/p&gt;
&lt;h2 id=&quot;more-examples-to-come&quot;&gt;More examples to come?&lt;/h2&gt;
&lt;p&gt;For sure, I will encounter more examples in the future. And I’ll continue to
update this post as a reference for my future-self on how I want to code future
similar scenarios.&lt;/p&gt;
&lt;section data-footnotes class=&quot;footnotes&quot;&gt;&lt;h2 class=&quot;sr-only&quot; id=&quot;footnote-label&quot;&gt;Footnotes&lt;/h2&gt;
&lt;ol&gt;
&lt;li id=&quot;user-content-fn-1&quot;&gt;
&lt;p&gt;I will call them Data Transfer Objects &lt;em&gt;aka&lt;/em&gt; DTO for the rest of this post &lt;a href=&quot;#user-content-fnref-1&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 1&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-2&quot;&gt;
&lt;p&gt;So you sort of control it, right? Well, not really. If an API is designed
for more than 1 client, it might include extra-details or complexity. So
while you can think you control it as an organization, your Swift project
does not. &lt;a href=&quot;#user-content-fnref-2&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 2&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;
</content:encoded><category>Swift</category><category>iOS</category></item><item><title>The Joy Sparked by Side Projects, 2022 Edition</title><link>https://www.mickf.net/tech/side-projects-2022/</link><guid isPermaLink="true">https://www.mickf.net/tech/side-projects-2022/</guid><description>Reviewing 2022, the benefits I gained from running a newsletter as a side project are tremendous. Let me explain why.</description><pubDate>Tue, 13 Dec 2022 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;🎄 December is here! Like every year, it is time to watch &lt;em&gt;Home Alone&lt;/em&gt; again and
to review the progress I made as a developer over the past 12 months. Side
projects contributed the most.&lt;/p&gt;
&lt;h2 id=&quot;why-side-projects-are-necessary-for-me&quot;&gt;Why side projects are necessary for me&lt;/h2&gt;
&lt;p&gt;Yes, a paying job is your bread and butter. But having side projects is key to
staying ahead of the younger guns of the tech world, flexing your developer
muscles in new directions and anticipating what’s next for you at work.&lt;/p&gt;
&lt;p&gt;Last year, I started writing &lt;a href=&quot;https://www.statium.app/&quot;&gt;a newsletter about soccer/football&lt;/a&gt;&lt;sup&gt;&lt;a href=&quot;#user-content-fn-1&quot; id=&quot;user-content-fnref-1&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; for
people based in France. The content is pretty basic. Still, I learned so much
just setting it up, running it, and trying to automate as many steps as possible
so that each edition would take as little time as possible to write, without
compromising the quality of the content.&lt;/p&gt;
&lt;h2 id=&quot;things-i-learned&quot;&gt;Things I learned&lt;/h2&gt;
&lt;p&gt;Here is a non-exhaustive list of the things I trained on last year to run the
newsletter, in an approximative chronological order:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/apple/swift-argument-parser&quot;&gt;&lt;strong&gt;Swift Argument Parser.&lt;/strong&gt;&lt;/a&gt; Writing a CLI in Swift is now my goto solution
when I need to write scripts. Including at work. It is so much easier to
write, document and maintain than Shell scripts.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://buttondown.email/&quot;&gt;&lt;strong&gt;Buttondown.&lt;/strong&gt;&lt;/a&gt; This is an indie tool to bootstrap newsletters. As part
of the side project journey, I believe it is worth exploring alternatives to
big corporations so I skipped Mailchimp, Mailjet and similar options. While I
really like Buttondown, I think the newsletter is now ready to grow out of it,
and finding a better option for my needs is on the roadmap for 2023.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.linode.com/&quot;&gt;&lt;strong&gt;Linode.&lt;/strong&gt;&lt;/a&gt; Similarly, I didn’t want to go the AWS route. And Linode’s
interface is much clearer than AWS — though it is not as feature rich. Linode
got recently bought by Akamai, so I am not as attached to it as I used to be.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.terraform.io/&quot;&gt;&lt;strong&gt;Terraform.&lt;/strong&gt;&lt;/a&gt; Infrastructure as code. I use it to create server
instances, manage DNS for the domain names, create and manage buckets and
keys.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.rfc-editor.org/rfc/rfc5545&quot;&gt;&lt;strong&gt;iCalendar RFC.&lt;/strong&gt;&lt;/a&gt; Not the sexiest subject. But I had to reverse-engineer
how calendar software behaves to get the newsletter to work the way I wanted.
Did you know that the iOS calendar behaves differently if you serve an ICS
file with a 2XX HTTP status code than if you serve it via a 3XX? &lt;a href=&quot;https://stackoverflow.com/questions/69631672/how-to-prevent-ios-from-suggesting-to-subscribe-to-an-ics-file-online&quot;&gt;I did
not&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.jsonfeed.org/&quot;&gt;&lt;strong&gt;JSONFeed.&lt;/strong&gt;&lt;/a&gt; An alternative to RSS written in JSON.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://micro.blog/statium&quot;&gt;&lt;strong&gt;Micro.blog.&lt;/strong&gt;&lt;/a&gt; An alternative to Twitter. Duh.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Modern React web frameworks.&lt;/strong&gt; I explored &lt;a href=&quot;https://nextjs.org/&quot;&gt;Next.js&lt;/a&gt; first, then
&lt;a href=&quot;https://remix.run/&quot;&gt;Remix&lt;/a&gt;. Both are pretty amazing.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://developer.apple.com/documentation/docc&quot;&gt;&lt;strong&gt;DocC.&lt;/strong&gt;&lt;/a&gt; The new documentation framework by Apple. I used &lt;a href=&quot;https://github.com/realm/jazzy&quot;&gt;Jazzy&lt;/a&gt;
before, but DocC — albeit sometimes awkward to use — is much more complete. As
illustrated by &lt;a href=&quot;https://www.mickf.net/tech/frenchkit-2022/&quot;&gt;Simon Støvring’s talk during FrenchKit 2022&lt;/a&gt;, you can
create amazing documentation with it.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://developer.apple.com/xcode-cloud/&quot;&gt;&lt;strong&gt;Xcode Cloud.&lt;/strong&gt;&lt;/a&gt; First-party CI and automated distribution of apps. It
seems to cover some common ground with Fastlane, very convenient to distribute
the app I use to run the newsletter on my iPhone and iPad via TestFlight.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://developer.apple.com/documentation/tabulardata&quot;&gt;&lt;strong&gt;TabularData.&lt;/strong&gt;&lt;/a&gt; A new framework provided by Apple to organize and
explore data.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://developer.apple.com/xcode/swiftui/&quot;&gt;&lt;strong&gt;SwiftUI.&lt;/strong&gt;&lt;/a&gt; I am sure you heard of it already 😉.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/pointfreeco/swift-composable-architecture&quot;&gt;&lt;strong&gt;The Composable Architecture.&lt;/strong&gt;&lt;/a&gt; A 3rd-party architecture library that
solved all the problems that were holding me back when I first got my toes wet
with SwiftUI.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://developers.google.com/optimization&quot;&gt;&lt;strong&gt;OR-Tools library.&lt;/strong&gt;&lt;/a&gt; Linear optimization library available in Python
among others. Picking the right tools to do the right job is essential. I
found this library to act like a Microsoft Excel solver.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Each of these tools would deserve their own post. I shouldn’t run out of
inspiration for this blog next year.&lt;/p&gt;
&lt;h2 id=&quot;the-positive-impacts-on-my-paying-job&quot;&gt;The positive impacts on my paying job&lt;/h2&gt;
&lt;h3 id=&quot;-a-better-set-of-tools-i-can-use&quot;&gt;🧰 A better set of tools I can use&lt;/h3&gt;
&lt;p&gt;Part of my job at Memo Bank is to write the iOS app that serves as the 2FA for
critical operations. The app does not do much. But the things it does are
critical. Our customers depend on it to pay salaries to their employees, pay
taxes on time, and be safe with their transactions.&lt;/p&gt;
&lt;p&gt;The app was bootstrapped with compatibility going up to iOS 12. Now that I got
my hands dirty with SwiftUI and &lt;em&gt;The Composable Architecture&lt;/em&gt; on my side
projects, I feel comfortable adopting them in the app for upcoming features.
That would not have been the case without the time I spent toying with them
outside of work. I made many mistakes. I rewrote things multiple times. It is
part of learning.&lt;/p&gt;
&lt;p&gt;Could this time spent on my free time have been part of the job? Maybe. But I
also like not having to be held accountable for anything when I explore and want
to play around with new things. I do whatever I want, without having to justify
my decisions to anyone else but me. I am in complete control of every decision.
Freedom &amp;amp; Fun.&lt;/p&gt;
&lt;h3 id=&quot;-a-greater-empathy&quot;&gt;🤗 A greater empathy&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;“It should be easy, it is &lt;em&gt;just&lt;/em&gt; a button.”&lt;/p&gt;
&lt;p&gt;— Quite probably my past self, in a self-indulgent micro-agression towards
some designer from my team. Who the hell did I think I was?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I wear every possible hat running this newsletter. I am a developer, a product
manager, and a designer. I do customer support, manage the infrastructure, etc.&lt;/p&gt;
&lt;p&gt;I get a glimpse of the struggles that every job comes with. I get reminded that
good design is hard to get right, that keeping an infrastructure up takes
effort, that making product decisions is hard. It is a useful humbling reminder
that shit is hard to get right.&lt;/p&gt;
&lt;h2 id=&quot;my-tips-and-life-lessons&quot;&gt;My tips and life lessons&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;🧱 Use a monorepo.&lt;/strong&gt; Over time, I realized that using a monorepo for my
projects was much more thrilling than having a million bunny projects with 5
commits each. The feeling of progress is much more satisfying.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;🏎 Take shortcuts towards the fun.&lt;/strong&gt; If you host your code on GitHub, don’t use
an organization and don’t open-source what you are doing until you feel ready.
For instance, at work, you should never leave secrets in your code. On a side
project, why not? If stakes are low, leave the boring required things you write
at work behind and sprint towards the fun parts.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;⏱ How to find time for it?&lt;/strong&gt; Any opportunity is good to take. My wife agreed
to leave me off kids-duty on Thursday evenings. I try to write a little bit of
code everyday, and when you work remotely, the lunch break is ideal for that.
Over time, things build up and the output you get from a 5-minute slot grows.&lt;/p&gt;
&lt;p&gt;Also, I recommend reading &lt;a href=&quot;https://www.avanderlee.com/optimization/side-projects-10-tips-for-being-successful/&quot;&gt;these tips from Antoine van der Lee&lt;/a&gt;. They are
great to act as a guard rail against uncontrollable impulses to try this new
thing. His point is to keep focus, realistic expectations and priorities
straight.&lt;/p&gt;
&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Why are you still reading this? Go work on your side project!&lt;/p&gt;
&lt;section data-footnotes class=&quot;footnotes&quot;&gt;&lt;h2 class=&quot;sr-only&quot; id=&quot;footnote-label&quot;&gt;Footnotes&lt;/h2&gt;
&lt;ol&gt;
&lt;li id=&quot;user-content-fn-1&quot;&gt;
&lt;p&gt;I won’t discuss which term is best. I can’t put it better than &lt;a href=&quot;https://kottke.org/22/12/fox-sports-us-world-cup-coverage-is-an-unmissable-abomination&quot;&gt;Jason Kottke
does&lt;/a&gt;: “it’s the sort of debate that 4th graders have on the playground”. &lt;a href=&quot;#user-content-fnref-1&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 1&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;
</content:encoded><category>Swift</category><category>iOS</category><category>JavaScript</category><category>React</category></item><item><title>Notes from FrenchKit 2022</title><link>https://www.mickf.net/tech/frenchkit-2022/</link><guid isPermaLink="true">https://www.mickf.net/tech/frenchkit-2022/</guid><description>Swift new features, SwiftUI and The Composable Architecture stole the show. As always, conferences help getting your coding juices flowing.</description><pubDate>Fri, 07 Oct 2022 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Previous editions: &lt;a href=&quot;https://www.mickf.net/tech/frenchkit-2019/&quot;&gt;2019&lt;/a&gt; · &lt;a href=&quot;https://www.mickf.net/tech/frenchkit-2018/&quot;&gt;2018&lt;/a&gt; · &lt;a href=&quot;https://www.mickf.net/tech/frenchkit-2017/&quot;&gt;2017&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;-the-talks-i-recommend&quot;&gt;🌟 The talks I recommend&lt;/h2&gt;
&lt;h3 id=&quot;any-idea-how-to-use-some-generics--antoine-van-der-lee&quot;&gt;any Idea How to Use some Generics? — Antoine van der Lee&lt;/h3&gt;
&lt;p&gt;Dive into the difference between &lt;code&gt;some&lt;/code&gt; vs &lt;code&gt;any&lt;/code&gt; and how they can replace older
forms of expressing constraints on generics.&lt;/p&gt;
&lt;p&gt;Note the choice of case in the title. 🤣&lt;/p&gt;
&lt;p&gt;— &lt;a href=&quot;https://youtu.be/xT5aaMyyR9c&quot;&gt;📺 Watch&lt;/a&gt;&lt;/p&gt;
&lt;h3 id=&quot;building-custom-property-wrappers-for-swiftui-and-how-to-test-them--donny-wals&quot;&gt;Building Custom Property Wrappers for SwiftUI (and how to test them) — Donny Wals&lt;/h3&gt;
&lt;p&gt;Implements
&lt;a href=&quot;https://github.com/donnywals/SwiftUIPropertyWrapperTalk&quot;&gt;a fetching data property wrapper for SwiftUI&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Donny is quite interesting because, year after year, he focuses on predicting
what Apple plans for the future as opposed to investing in 3rd-party libraries
or frameworks.&lt;/p&gt;
&lt;p&gt;For instance, he seems genuinely convinced that, for Apple people, data fetchers
belong to views — following Apple’s own APIs — and that Combine and Core Data
are just as relevant in 2022 as they always were.&lt;/p&gt;
&lt;p&gt;— &lt;a href=&quot;https://youtu.be/x3-GZzjeH9g&quot;&gt;📺 Watch&lt;/a&gt;&lt;/p&gt;
&lt;h3 id=&quot;masterclass-hacking-ios-apps---and-trying-to-prevent-it--elliot-schrock&quot;&gt;Masterclass: Hacking iOS Apps - and trying to prevent it — Elliot Schrock&lt;/h3&gt;
&lt;p&gt;This talk provided a lot of valuable insights. Using a jailbroken iPhone, Elliot
went backwards from the demo to the theory of hacking, highlighting how to
control the app from the CLI. Elliot also mentioned this funny analogy about
security:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;🏃 🐻 If you’re being chased by a bear, you must run faster than the slowest
guy.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Tools mentioned:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://www.cycript.org&quot;&gt;&lt;code&gt;cycript&lt;/code&gt;&lt;/a&gt; (pronounced ssssscript apparently);&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.hopperapp.com&quot;&gt;Hopper&lt;/a&gt; (disassembler);&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/KJCracks/Clutch&quot;&gt;Clutch&lt;/a&gt; (executable dumper);&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://wiki.smhuda.com/pentesting/tool-usage/ipainstaller&quot;&gt;ipainstaller&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;swift-quiz--vincent-pradeilles&quot;&gt;Swift Quiz — Vincent Pradeilles&lt;/h3&gt;
&lt;p&gt;Three questions:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;✅ Retaining cycles. I got this one right.&lt;/li&gt;
&lt;li&gt;❌ Mutating function on a &lt;code&gt;struct&lt;/code&gt; with a &lt;code&gt;let&lt;/code&gt; property. You can reassign
&lt;code&gt;self&lt;/code&gt;. I got it wrong.&lt;/li&gt;
&lt;li&gt;❌ Empty enums. Does the Swift compiler accept a function that has a
signature that returns something but actually has an empty body, when the
argument is an empty enum (which cannot be instantiated)? It does. I got it
wrong too. But it explains why the signature of &lt;code&gt;fatalError&lt;/code&gt; is &lt;code&gt;Never&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;— &lt;a href=&quot;https://youtu.be/mUBBY6JCC0c&quot;&gt;📺 Watch&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;-hot-takes&quot;&gt;🔥 Hot Takes&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;I am so bad at socializing during conferences.&lt;/strong&gt; My interactions with other
human beings at FrenchKit consisted primarily of asking questions during Q&amp;amp;A
sessions, but it was hard for me to go beyond that. I tried to attend an event
on the Thursday evening. But a bar packed with 200 people, 95% of which are
nerdy dorks like myself — now quite younger — is not an environment I can thrive
in. I am taller and deafer than the average person so that would translate into
me bending over groups of people, pretending I can hear what is being said. Not
quite fun.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Next time, I will try to attend NSSpain.&lt;/strong&gt; It was the last edition of
FrenchKit per say. The hosts are willing to expand to other technologies — which
will be appreciated after the dot conferences disappeared after being bought by
Welcome to the Jungle.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;I will build next features at work for iOS 14 users.&lt;/strong&gt; Today, we support
iOS 12. Looking at iosref’s
&lt;a href=&quot;https://iosref.com/ios&quot;&gt;iOS version by device table&lt;/a&gt;, I realized that bumping
straight to iOS 14 will leave aside some devices stuck with iOS 12. But no
device is stuck with iOS 13 — or iOS 14 for that matter. So, at the end of the
day, iOS 14 sounds like a sweet spot to be able to benefit both from async/await
and a decent version of SwiftUI.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;I should give things a second chance.&lt;/strong&gt; I’m talking about you jailbreaking
phones — to put myself in hackers shoes — and UI testing.&lt;/p&gt;
&lt;h2 id=&quot;-the-rest-of-my-notes&quot;&gt;🪣 The rest of my notes&lt;/h2&gt;
&lt;p&gt;Here I share raw notes from the other talks cause… why not?&lt;/p&gt;
&lt;h3 id=&quot;beyond-code-skills-for-impactful-development-that-makes-a-difference--maxim-cramer&quot;&gt;Beyond Code: Skills for Impactful Development That Makes a Difference — Maxim Cramer&lt;/h3&gt;
&lt;p&gt;How to make impact beyond code? Mostly about communication. 🦒 The image of the
giraffe in a park that every can sort of picture vs feature descriptions. We
share very little of our knowledge when we communicate. Shocking fact: 2% of
funding is for female founders.&lt;/p&gt;
&lt;p&gt;— &lt;a href=&quot;https://youtu.be/epYcQluY954&quot;&gt;📺 Watch&lt;/a&gt;&lt;/p&gt;
&lt;h3 id=&quot;i--swift-concurrency--tunde-adegoroye&quot;&gt;I 💕 Swift Concurrency — Tunde Adegoroye&lt;/h3&gt;
&lt;p&gt;Concurrency, &lt;code&gt;async let&lt;/code&gt;, tasks and tasks groups, actors.&lt;/p&gt;
&lt;p&gt;— &lt;a href=&quot;https://youtu.be/HptV7UUTToQ&quot;&gt;📺 Watch&lt;/a&gt;&lt;/p&gt;
&lt;h3 id=&quot;how-not-to-develop-an-umm-detector-using-create-ml--yono-mittlefehldt&quot;&gt;How not to develop an “Umm” detector using Create ML — Yono Mittlefehldt&lt;/h3&gt;
&lt;p&gt;Um detector. Not really about code but about the thought process. Some tools
mentioned worth bookmarking:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;sox CLI (&lt;a href=&quot;https://sox.sourceforge.net&quot;&gt;https://sox.sourceforge.net&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://pytorch.org/&quot;&gt;PyTorch&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.tensorflow.org/&quot;&gt;TensorFlow&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://developer.apple.com/machine-learning/&quot;&gt;Machine Learning - Apple Developer&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;— &lt;a href=&quot;https://youtu.be/45hxH7-p5IM&quot;&gt;📺 Watch&lt;/a&gt;&lt;/p&gt;
&lt;h3 id=&quot;documenting-your-project-with-docc--simon-støvring&quot;&gt;Documenting your project with DocC — Simon Støvring&lt;/h3&gt;
&lt;p&gt;Wrap up around DocC by the author of the
&lt;a href=&quot;https://apps.apple.com/fr/app/runestone-text-editor/id1548193893?l=en&quot;&gt;Runestone&lt;/a&gt;
text editor.&lt;/p&gt;
&lt;p&gt;I started using DocC with my &lt;a href=&quot;https://swiftpackageindex.com/dirtyhenry/swift-blocks/&quot;&gt;Blocks&lt;/a&gt; project, but I didn’t know about
&lt;a href=&quot;https://developer.apple.com/documentation/docc/tutorials&quot;&gt;tutorials&lt;/a&gt; with DocC.&lt;/p&gt;
&lt;p&gt;— &lt;a href=&quot;https://youtu.be/paR2INQMc3s&quot;&gt;📺 Watch&lt;/a&gt;&lt;/p&gt;
&lt;h3 id=&quot;swiftui-at-scale--thomas-ricouard&quot;&gt;SwiftUI at Scale — Thomas Ricouard&lt;/h3&gt;
&lt;p&gt;The point was that SwiftUI is production ready. And apparently, it’s tied to the
iOS version running the phone so it doesn’t make sense to use SwiftUI before
iOS 14. I guess this means that SwiftUI in iOS 13 is broken.&lt;/p&gt;
&lt;p&gt;— &lt;a href=&quot;https://youtu.be/tsZBLvdcoTw&quot;&gt;📺 Watch&lt;/a&gt;&lt;/p&gt;
&lt;h3 id=&quot;swiftui-navigation--luis-ascorbe&quot;&gt;SwiftUI Navigation — Luis Ascorbe&lt;/h3&gt;
&lt;p&gt;Should we use SwiftUI or UIKit for navigation? It depends. He recommended the
following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;NavigationStack.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://vimeo.com/751580644&quot;&gt;Brandon Williams: SwiftUI Navigation &amp;amp; URL Routing&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Taking a look at
&lt;a href=&quot;https://github.com/pointfreeco/swift-composable-architecture&quot;&gt;The Composable Architecture&lt;/a&gt;
aka &lt;em&gt;TCA&lt;/em&gt; which sounds like a good idea.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://vimeo.com/751173570&quot;&gt;Composable Architecture at Scale&lt;/a&gt; by Krzysztof
Zablocki&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;— &lt;a href=&quot;https://youtu.be/jhO9gfVg6_U&quot;&gt;📺 Watch&lt;/a&gt;&lt;/p&gt;
&lt;h3 id=&quot;from-source-code-to-executable-a-day-in-the-life-of-a-build-system--samuel-giddinis&quot;&gt;From source code to executable: a day in the life of a Build System — Samuel Giddinis&lt;/h3&gt;
&lt;p&gt;Why do we need build systems and the complexity behind them. Some notes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/realm/SwiftLint/blob/main/Makefile&quot;&gt;Swiftlint has a Makefile&lt;/a&gt;;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://bazel.build&quot;&gt;Bazel&lt;/a&gt; is great for large monorepos but require a
significant investment and care&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&quot;https://imgs.xkcd.com/comics/compiling.png&quot; alt=&quot;My Code’s Compiling&quot;&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/segiddins/Bazel-iOS-Workshop&quot;&gt;GitHub - segiddins/Bazel-iOS-Workshop: AppBuilders 2022 workshop on building an iOS app with Bazel&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;— &lt;a href=&quot;https://youtu.be/dpxqSjSKJYA&quot;&gt;📺 Watch&lt;/a&gt;&lt;/p&gt;
&lt;h3 id=&quot;migrating-your-legacy-code-to-local-spm-packages--zouhair-mahieddine&quot;&gt;Migrating your legacy code to local SPM packages — Zouhair Mahieddine&lt;/h3&gt;
&lt;p&gt;This title describes exactly the content of the talk. 😆&lt;/p&gt;
&lt;p&gt;— &lt;a href=&quot;https://youtu.be/bXCuVzsdyDo&quot;&gt;📺 Watch&lt;/a&gt;&lt;/p&gt;
&lt;h3 id=&quot;testing-for-accessibility--robin-kanatzar&quot;&gt;Testing for Accessibility — Robin Kanatzar&lt;/h3&gt;
&lt;p&gt;A reminder that the accessibility tool is good. Robin recommended the following
tool:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://www.evinced.com/products/flow-analyzer-for-mobile&quot;&gt;Mobile Flow Analyzer - Evinced, Inc.&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;— &lt;a href=&quot;https://youtu.be/59uLAKVB-d4&quot;&gt;📺 Watch&lt;/a&gt;&lt;/p&gt;
&lt;h3 id=&quot;cloud-functions-to-the-rescue--zamzam-farzamipooya&quot;&gt;Cloud Functions to the rescue — Zamzam Farzamipooya&lt;/h3&gt;
&lt;p&gt;The talk focuses on Firebase/Google. That’s kind of a non starter for my tastes.&lt;/p&gt;
&lt;p&gt;It reminded me of stuff I did for Flâneur and why I didn’t like Firebase: data
access boundaries are fragile and require significant effort.&lt;/p&gt;
&lt;p&gt;— &lt;a href=&quot;https://youtu.be/DdGfFkOz9gQ&quot;&gt;📺 Watch&lt;/a&gt;&lt;/p&gt;
&lt;h3 id=&quot;from-app-to-game-development--michel-andré-chirita&quot;&gt;From App to Game Development — Michel-André Chirita&lt;/h3&gt;
&lt;p&gt;Interesting. The game is:
&lt;a href=&quot;https://apps.apple.com/fr/app/versus-arena/id1542795843?l=en&quot;&gt;Versus Arena&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;It made me want to develop a Backgammon game again.&lt;/p&gt;
&lt;p&gt;— &lt;a href=&quot;https://youtu.be/HLz0Cfkaiew&quot;&gt;📺 Watch&lt;/a&gt;&lt;/p&gt;
&lt;h3 id=&quot;the-journey-of-widgets-begins-with-one-step--audrey-sobgou-zebaze&quot;&gt;The journey of Widgets begins with one step — Audrey Sobgou-Zebaze&lt;/h3&gt;
&lt;p&gt;How to start implementing widgets with
&lt;a href=&quot;https://developer.apple.com/widgets/&quot;&gt;WidgetKit&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;— &lt;a href=&quot;https://youtu.be/XRMcdUUA0HU&quot;&gt;📺 Watch&lt;/a&gt;&lt;/p&gt;
</content:encoded><category>Conference</category><category>Swift</category><category>iOS</category></item><item><title>Dealing With Dates With No Time in Swift</title><link>https://www.mickf.net/tech/date-with-no-time-operations-swift/</link><guid isPermaLink="true">https://www.mickf.net/tech/date-with-no-time-operations-swift/</guid><description>Exploring some code wrappring dates with no time, ie represented as strings in the YYYY‑MM‑DD ISO 8601 format.</description><pubDate>Wed, 02 Mar 2022 00:00:00 GMT</pubDate><content:encoded>&lt;h2 id=&quot;where-the-streets-dates-have-no-name-time&quot;&gt;Where the &lt;del&gt;Streets&lt;/del&gt; Dates Have No &lt;del&gt;Name&lt;/del&gt; Time&lt;/h2&gt;
&lt;p&gt;&lt;em&gt;Where the Streets Have No Name&lt;/em&gt;, the U2 song, was released on 31 August 1987.
At what time? It is not relevant. Just the date, ie the calendar day, matters.
If I had to translate this in a JSON API, I would write the following:
&lt;code&gt;{&quot;release_date&quot;: &quot;1987-08-31&quot;}&lt;/code&gt;, ie basic ISO 8601, no time or time zone.&lt;/p&gt;
&lt;p&gt;When dealing with such &lt;em&gt;dates with no time&lt;/em&gt;, some operations can be necessary.
For instance, what is the 7th day after 31 August 1987? No dependency allowed.
This blog post will answer this question. Easy peasy, right?&lt;/p&gt;
&lt;p&gt;But beware, the experienced developer should be humble when coding such
operations. Dealing with calendars is hard and I can easily prove it. Just
answer this simple question: is every minute in a calendar 60 seconds long? If
you answered “yes”, you failed the test.
&lt;a href=&quot;https://yourcalendricalfallacyis.com&quot;&gt;Go study and have fun&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Hopefully, Swift’s &lt;code&gt;Foundation&lt;/code&gt; provides everything we need to avoid obvious
traps. Let’s see what a struct to handle &lt;em&gt;dates with no time&lt;/em&gt; could look like.&lt;/p&gt;
&lt;h2 id=&quot;the-implementation&quot;&gt;The implementation&lt;/h2&gt;
&lt;p&gt;This is the end result. A discussion follows.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; Foundation&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;/// A string that represents dates using their ISO 8601 representations.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;///&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;/// `PlainDate` is a way to handle dates with no time — such as `2022-03-02` for March 2nd of 2022 — to&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;/// perform operations with convenience including adding days, dealing with ranges, etc.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;///&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;/// ## Usage Overview&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;///&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;/// A plain date can be initiated from a string literal, and can be used to create ranges.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;///&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;///     let plainDate: PlainDate = &quot;2022-03-01&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;///     let aWeekLater = plainDate.advanced(by: 7)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;///     for day in march1st ..&amp;lt; aWeekLater {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;///       print(day)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;///     }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; struct&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; PlainDate&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;    // MARK: - Creating an instance&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;    /// Returns a date string initialized using their ISO 8601 representation.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;    /// - Parameters:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;    ///   - dateAsString: The ISO 8601 representation of the date. For instance, `2022-03-02`for March 2nd of 2022.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;    ///   - calendar: The calendar — including the time zone — to use. The default is the current calendar.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;    /// - Returns: A date string, or `nil` if a valid date could not be created from `dateAsString`.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    public&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; init?&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; dateAsString: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;calendar&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: Calendar &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; .current) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; formatter &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; Self&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;createFormatter&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;timeZone&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: calendar.timeZone)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        guard&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; date &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; formatter.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;date&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: dateAsString) &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;else&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;            return&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; nil&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;        self&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;init&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;date&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: date, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;calendar&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: calendar, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;formatter&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: formatter)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;    /// Returns a date string initialized using their ISO 8601 representation.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;    /// - Parameters:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;    ///   - date: The date to represent.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;    ///   - calendar: The calendar — including the time zone — to use. The default is the current calendar.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    public&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; init&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;date&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: Date, &lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;calendar&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: Calendar &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; .current) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;        self&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;init&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;date&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: date, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;calendar&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: calendar, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;formatter&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;Self&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;createFormatter&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;timeZone&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: calendar.timeZone))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    private&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; init&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;date&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: Date, &lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;calendar&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: Calendar &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; .current, &lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;formatter&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: ISO8601DateFormatter) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;        self&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.formatter &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; formatter&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;        self&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.date &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; date&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;        self&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.calendar &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; calendar&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;    // MARK: - Properties&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    private&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; formatter: ISO8601DateFormatter&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    private&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; date: Date&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    private&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; calendar: Calendar&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    private&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; static&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; func&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; createFormatter&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;timeZone&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: TimeZone) &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; ISO8601DateFormatter {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; formatter &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; ISO8601DateFormatter&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        formatter.formatOptions &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; [.withFullDate]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        formatter.timeZone &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; timeZone&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        return&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; formatter&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;extension&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; PlainDate&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;ExpressibleByStringLiteral&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    public&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; init&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;stringLiteral&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; value: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;        self&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;init&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: value)&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;!&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;extension&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; PlainDate&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;Strideable&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    public&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; func&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; distance&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;to&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; other: PlainDate) &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; Int&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; timeInterval &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; date.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;distance&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;to&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: other.date)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        return&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; Int&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;round&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(timeInterval &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; 86400.0&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    public&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; func&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; advanced&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;by&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; value: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;Int&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; PlainDate {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; newDate &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; calendar.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;date&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;byAdding&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: .day, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: value, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;to&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: date)&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;!&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        return&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; PlainDate&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;date&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: newDate, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;calendar&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: calendar, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;formatter&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: formatter)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;just-how-bad-is-datestring-for-a-name&quot;&gt;Just how bad is &lt;del&gt;DateString&lt;/del&gt; for a name?&lt;/h3&gt;
&lt;p&gt;Edit: the first name for this class was &lt;code&gt;DateString&lt;/code&gt;. I know. Since, I found out
about &lt;a href=&quot;https://tc39.es/proposal-temporal/docs/index.html&quot;&gt;the &lt;code&gt;Temporal&lt;/code&gt; proposal for JavaScript&lt;/a&gt; that introduces something very
similar to what I am trying to achieve here as &lt;code&gt;PlainDate&lt;/code&gt;. So I renamed this
accordingly.&lt;/p&gt;
&lt;h3 id=&quot;why-are-time-zones-involved-in-this-code&quot;&gt;Why are time zones involved in this code?&lt;/h3&gt;
&lt;p&gt;It’s the result of logical decisions I made from the tools I had at hand:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Converting an ISO 8601 string? Use &lt;code&gt;ISO8601DateFormatter&lt;/code&gt;!&lt;/li&gt;
&lt;li&gt;What type does &lt;code&gt;ISO8601DateFormatter&lt;/code&gt; convert the input &lt;code&gt;String&lt;/code&gt; into? As a
&lt;code&gt;Date&lt;/code&gt;!&lt;/li&gt;
&lt;li&gt;So I should use a &lt;code&gt;Date&lt;/code&gt; — with time — to store a &lt;em&gt;date with no time&lt;/em&gt;? Yes!&lt;/li&gt;
&lt;li&gt;How can I output the date back into a &lt;code&gt;String&lt;/code&gt;? Use &lt;code&gt;ISO8601DateFormatter&lt;/code&gt;
again!&lt;/li&gt;
&lt;li&gt;But look at this test, it’s getting buggy around days on which clocks change
to deal with daylight saving time? Use a time zone!&lt;/li&gt;
&lt;li&gt;So I have to carry a &lt;code&gt;Calendar&lt;/code&gt; and a &lt;code&gt;TimeZone&lt;/code&gt; around? No need: a &lt;code&gt;Calendar&lt;/code&gt;
does include a &lt;code&gt;TimeZone&lt;/code&gt;, just carry the &lt;code&gt;Calendar&lt;/code&gt; around!&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;implementing-expressiblebystringliteral-is-so-easy-and-convenient&quot;&gt;Implementing ExpressibleByStringLiteral is so easy and convenient!&lt;/h3&gt;
&lt;p&gt;Yes, it is. Expressing a &lt;code&gt;PlainDate&lt;/code&gt; just as &lt;code&gt;&quot;1987-08-31&quot;&lt;/code&gt; is indeed pretty
awesome.&lt;/p&gt;
&lt;h3 id=&quot;wow-and-what-about-implementing-strideable&quot;&gt;Wow, and what about implementing Strideable?&lt;/h3&gt;
&lt;p&gt;I know, right? On top of answering our original question
(&lt;code&gt;date.advanced(by: offset)&lt;/code&gt;), &lt;code&gt;Strideable&lt;/code&gt; helps doing things like:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; startDate: PlainDate &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;2022-03-01&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; aWeekLater &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; startDate.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;advanced&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;by&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;7&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; date &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;  startDate &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;..&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; aWeekLater {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;  // do something.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;wait-a-minute-is-this-a-hard-coded-86400-in-the-code-isnt-that-forbidden&quot;&gt;Wait a minute! Is this a hard-coded 86400 in the code? Isn’t that forbidden?&lt;/h3&gt;
&lt;p&gt;🕵️ Good eye. 86400 is the number of seconds in a typical day. But not all days
are 86400 seconds long. But the point here is to compute the distance in days
between two dates, and I think this implementation is OK. I’ll explain why:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;code&gt;Calendar&lt;/code&gt; is ignoring leap seconds. I know because a former Apple Foundation
employee &lt;a href=&quot;https://stackoverflow.com/a/71312395/455016&quot;&gt;told me so&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;See the &lt;code&gt;round&lt;/code&gt;? This is enough to deal with daylight savings according to my
tests and my understanding of how daylight savings work. Consider a
collection that contains the number of seconds of an arbitrary number of
&lt;strong&gt;consecutive&lt;/strong&gt; days. (a) There’s more than a 99% chance that a randomly
picked item is 86400. (b) Considering that the 2 possible outliers values
will alternate: if you find a 23-hour long day (82800 seconds) in the
collection, you will find a 25-hour long day (90000 seconds) before you find
another occurrence of a 23-hour long day. So the average of a set will tend
to 86400 as it gets bigger.&lt;/li&gt;
&lt;li&gt;Here is a more intellectually satisfying alternative for this computation. It
might be more solid if you’re working on something really time-sensitive. But
it is about &lt;strong&gt;2 times slower&lt;/strong&gt;. So as long as my fast implementation does not
fail me, I’ll stick to it.&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; start &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; calendar.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;ordinality&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;of&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: .day, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: .era, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.date)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; end &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; calendar.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;ordinality&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;of&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: .day, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: .era, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: other.date)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;guard&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; start &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; start, &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; end &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; end &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;else&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;    fatalError&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;The distance between 2 dates could not be computed.&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; end &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; start&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Mission accomplished. Feel free to use this &lt;code&gt;PlainDate&lt;/code&gt; class as is. I’ve been
using it for a hobby project — a soccer newsletter — and it works great. If you
can read French and soccer is your thing, you can &lt;a href=&quot;https://www.statium.app/newsletter&quot;&gt;sign up for the
newsletter&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&quot;addendum--ios--macos-time-zones&quot;&gt;Addendum — iOS &amp;amp; macOS Time Zones&lt;/h2&gt;
&lt;p&gt;Here is a table of all the known time zones’ identifiers and abbreviations as
run on iOS 15.2 and macOS 12.2.1.&lt;/p&gt;
&lt;p&gt;For some reason, &lt;code&gt;UTC&lt;/code&gt; is an abbreviation to the &lt;code&gt;UTC&lt;/code&gt; identifier, but &lt;code&gt;UTC&lt;/code&gt; is
missing in the list of known identifiers. 🤷‍♂️ I initalized a time zone using
&lt;code&gt;UTC&lt;/code&gt;: it succeeded and querying the identifier returned &lt;code&gt;GMT&lt;/code&gt;. Double-🤷‍♂️.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Identifier&lt;/th&gt;
&lt;th&gt;Abbreviations&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Abidjan&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Accra&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Addis_Ababa&lt;/td&gt;
&lt;td&gt;EAT&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Algiers&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Asmara&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Bamako&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Bangui&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Banjul&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Bissau&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Blantyre&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Brazzaville&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Bujumbura&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Cairo&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Casablanca&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Ceuta&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Conakry&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Dakar&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Dar_es_Salaam&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Djibouti&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Douala&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/El_Aaiun&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Freetown&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Gaborone&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Harare&lt;/td&gt;
&lt;td&gt;CAT&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Johannesburg&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Juba&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Kampala&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Khartoum&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Kigali&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Kinshasa&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Lagos&lt;/td&gt;
&lt;td&gt;WAT&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Libreville&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Lome&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Luanda&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Lubumbashi&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Lusaka&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Malabo&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Maputo&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Maseru&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Mbabane&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Mogadishu&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Monrovia&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Nairobi&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Ndjamena&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Niamey&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Nouakchott&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Ouagadougou&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Porto-Novo&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Sao_Tome&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Tripoli&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Tunis&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Africa/Windhoek&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Adak&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Anchorage&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Anguilla&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Antigua&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Araguaina&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Argentina/Buenos_Aires&lt;/td&gt;
&lt;td&gt;ART&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Argentina/Catamarca&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Argentina/Cordoba&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Argentina/Jujuy&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Argentina/La_Rioja&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Argentina/Mendoza&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Argentina/Rio_Gallegos&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Argentina/Salta&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Argentina/San_Juan&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Argentina/San_Luis&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Argentina/Tucuman&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Argentina/Ushuaia&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Aruba&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Asuncion&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Atikokan&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Bahia&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Bahia_Banderas&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Barbados&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Belem&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Belize&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Blanc-Sablon&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Boa_Vista&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Bogota&lt;/td&gt;
&lt;td&gt;COT&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Boise&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Cambridge_Bay&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Campo_Grande&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Cancun&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Caracas&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Cayenne&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Cayman&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Chicago&lt;/td&gt;
&lt;td&gt;CDT, CST&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Chihuahua&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Costa_Rica&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Creston&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Cuiaba&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Curacao&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Danmarkshavn&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Dawson&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Dawson_Creek&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Denver&lt;/td&gt;
&lt;td&gt;MDT&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Detroit&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Dominica&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Edmonton&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Eirunepe&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/El_Salvador&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Fort_Nelson&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Fortaleza&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Glace_Bay&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Godthab&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Goose_Bay&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Grand_Turk&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Grenada&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Guadeloupe&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Guatemala&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Guayaquil&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Guyana&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Halifax&lt;/td&gt;
&lt;td&gt;ADT, AST&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Havana&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Hermosillo&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Indiana/Indianapolis&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Indiana/Knox&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Indiana/Marengo&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Indiana/Petersburg&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Indiana/Tell_City&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Indiana/Vevay&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Indiana/Vincennes&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Indiana/Winamac&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Inuvik&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Iqaluit&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Jamaica&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Juneau&lt;/td&gt;
&lt;td&gt;AKDT, AKST&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Kentucky/Louisville&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Kentucky/Monticello&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Kralendijk&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/La_Paz&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Lima&lt;/td&gt;
&lt;td&gt;PET&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Los_Angeles&lt;/td&gt;
&lt;td&gt;PDT, PST&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Lower_Princes&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Maceio&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Managua&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Manaus&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Marigot&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Martinique&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Matamoros&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Mazatlan&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Menominee&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Merida&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Metlakatla&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Mexico_City&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Miquelon&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Moncton&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Monterrey&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Montevideo&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Montreal&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Montserrat&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Nassau&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/New_York&lt;/td&gt;
&lt;td&gt;EDT, EST&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Nipigon&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Nome&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Noronha&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/North_Dakota/Beulah&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/North_Dakota/Center&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/North_Dakota/New_Salem&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Nuuk&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Ojinaga&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Panama&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Pangnirtung&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Paramaribo&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Phoenix&lt;/td&gt;
&lt;td&gt;MST&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Port-au-Prince&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Port_of_Spain&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Porto_Velho&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Puerto_Rico&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Punta_Arenas&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Rainy_River&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Rankin_Inlet&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Recife&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Regina&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Resolute&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Rio_Branco&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Santa_Isabel&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Santarem&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Santiago&lt;/td&gt;
&lt;td&gt;CLST, CLT&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Santo_Domingo&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Sao_Paulo&lt;/td&gt;
&lt;td&gt;BRST, BRT&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Scoresbysund&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Shiprock&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Sitka&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/St_Barthelemy&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/St_Johns&lt;/td&gt;
&lt;td&gt;NDT, NST&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/St_Kitts&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/St_Lucia&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/St_Thomas&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/St_Vincent&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Swift_Current&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Tegucigalpa&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Thule&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Thunder_Bay&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Tijuana&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Toronto&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Tortola&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Vancouver&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Whitehorse&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Winnipeg&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Yakutat&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;America/Yellowknife&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Antarctica/Casey&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Antarctica/Davis&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Antarctica/DumontDUrville&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Antarctica/Macquarie&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Antarctica/Mawson&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Antarctica/McMurdo&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Antarctica/Palmer&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Antarctica/Rothera&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Antarctica/South_Pole&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Antarctica/Syowa&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Antarctica/Troll&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Antarctica/Vostok&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Arctic/Longyearbyen&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Aden&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Almaty&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Amman&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Anadyr&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Aqtau&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Aqtobe&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Ashgabat&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Atyrau&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Baghdad&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Bahrain&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Baku&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Bangkok&lt;/td&gt;
&lt;td&gt;ICT&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Barnaul&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Beirut&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Bishkek&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Brunei&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Calcutta&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Chita&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Choibalsan&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Chongqing&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Colombo&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Damascus&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Dhaka&lt;/td&gt;
&lt;td&gt;BDT&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Dili&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Dubai&lt;/td&gt;
&lt;td&gt;GST&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Dushanbe&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Famagusta&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Gaza&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Harbin&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Hebron&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Ho_Chi_Minh&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Hong_Kong&lt;/td&gt;
&lt;td&gt;HKT&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Hovd&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Irkutsk&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Jakarta&lt;/td&gt;
&lt;td&gt;WIT&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Jayapura&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Jerusalem&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Kabul&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Kamchatka&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Karachi&lt;/td&gt;
&lt;td&gt;PKT&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Kashgar&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Kathmandu&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Katmandu&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Khandyga&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Krasnoyarsk&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Kuala_Lumpur&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Kuching&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Kuwait&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Macau&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Magadan&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Makassar&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Manila&lt;/td&gt;
&lt;td&gt;PHT&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Muscat&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Nicosia&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Novokuznetsk&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Novosibirsk&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Omsk&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Oral&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Phnom_Penh&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Pontianak&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Pyongyang&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Qatar&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Qostanay&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Qyzylorda&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Rangoon&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Riyadh&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Sakhalin&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Samarkand&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Seoul&lt;/td&gt;
&lt;td&gt;KST&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Shanghai&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Singapore&lt;/td&gt;
&lt;td&gt;SGT&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Srednekolymsk&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Taipei&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Tashkent&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Tbilisi&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Tehran&lt;/td&gt;
&lt;td&gt;IRST&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Thimphu&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Tokyo&lt;/td&gt;
&lt;td&gt;JST&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Tomsk&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Ulaanbaatar&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Urumqi&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Ust-Nera&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Vientiane&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Vladivostok&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Yakutsk&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Yangon&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Yekaterinburg&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asia/Yerevan&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Atlantic/Azores&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Atlantic/Bermuda&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Atlantic/Canary&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Atlantic/Cape_Verde&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Atlantic/Faroe&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Atlantic/Madeira&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Atlantic/Reykjavik&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Atlantic/South_Georgia&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Atlantic/St_Helena&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Atlantic/Stanley&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Australia/Adelaide&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Australia/Brisbane&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Australia/Broken_Hill&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Australia/Currie&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Australia/Darwin&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Australia/Eucla&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Australia/Hobart&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Australia/Lindeman&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Australia/Lord_Howe&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Australia/Melbourne&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Australia/Perth&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Australia/Sydney&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Amsterdam&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Andorra&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Astrakhan&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Athens&lt;/td&gt;
&lt;td&gt;EEST, EET&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Belgrade&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Berlin&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Bratislava&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Brussels&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Bucharest&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Budapest&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Busingen&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Chisinau&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Copenhagen&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Dublin&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Gibraltar&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Guernsey&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Helsinki&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Isle_of_Man&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Istanbul&lt;/td&gt;
&lt;td&gt;TRT&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Jersey&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Kaliningrad&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Kiev&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Kirov&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Lisbon&lt;/td&gt;
&lt;td&gt;WEST, WET&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Ljubljana&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/London&lt;/td&gt;
&lt;td&gt;BST&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Luxembourg&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Madrid&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Malta&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Mariehamn&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Minsk&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Monaco&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Moscow&lt;/td&gt;
&lt;td&gt;MSD, MSK&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Oslo&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Paris&lt;/td&gt;
&lt;td&gt;CEST, CET&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Podgorica&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Prague&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Riga&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Rome&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Samara&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/San_Marino&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Sarajevo&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Saratov&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Simferopol&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Skopje&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Sofia&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Stockholm&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Tallinn&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Tirane&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Ulyanovsk&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Uzhgorod&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Vaduz&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Vatican&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Vienna&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Vilnius&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Volgograd&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Warsaw&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Zagreb&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Zaporozhye&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe/Zurich&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GMT&lt;/td&gt;
&lt;td&gt;GMT&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Indian/Antananarivo&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Indian/Chagos&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Indian/Christmas&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Indian/Cocos&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Indian/Comoro&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Indian/Kerguelen&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Indian/Mahe&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Indian/Maldives&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Indian/Mauritius&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Indian/Mayotte&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Indian/Reunion&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pacific/Apia&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pacific/Auckland&lt;/td&gt;
&lt;td&gt;NZDT, NZST&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pacific/Bougainville&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pacific/Chatham&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pacific/Chuuk&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pacific/Easter&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pacific/Efate&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pacific/Enderbury&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pacific/Fakaofo&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pacific/Fiji&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pacific/Funafuti&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pacific/Galapagos&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pacific/Gambier&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pacific/Guadalcanal&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pacific/Guam&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pacific/Honolulu&lt;/td&gt;
&lt;td&gt;HST&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pacific/Johnston&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pacific/Kanton&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pacific/Kiritimati&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pacific/Kosrae&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pacific/Kwajalein&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pacific/Majuro&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pacific/Marquesas&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pacific/Midway&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pacific/Nauru&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pacific/Niue&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pacific/Norfolk&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pacific/Noumea&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pacific/Pago_Pago&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pacific/Palau&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pacific/Pitcairn&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pacific/Pohnpei&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pacific/Ponape&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pacific/Port_Moresby&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pacific/Rarotonga&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pacific/Saipan&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pacific/Tahiti&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pacific/Tarawa&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pacific/Tongatapu&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pacific/Truk&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pacific/Wake&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pacific/Wallis&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;The code to output this table:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; Foundation&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; identifier &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; TimeZone.knownTimeZoneIdentifiers.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;sorted&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;() {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; abbreviations &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; TimeZone.abbreviationDictionary.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;filter&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; { (k, v) &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;in&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        v &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; identifier&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;    print&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;| &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;\(identifier)&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; | &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;\(abbreviations.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;keys&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;sorted&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;().&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;joined&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;separator&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;, &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;))&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; |&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
</content:encoded><category>Swift</category><category>iOS</category></item><item><title>A Swift Recoverable Precondition That Can Throw</title><link>https://www.mickf.net/tech/swift-precondition-that-throws/</link><guid isPermaLink="true">https://www.mickf.net/tech/swift-precondition-that-throws/</guid><description>The what and the why of a Swift precondition helper that accepts statements that can throw recoverable errors.</description><pubDate>Fri, 17 Dec 2021 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;What on Earth is a &lt;em&gt;recoverable&lt;/em&gt; precondition? &lt;a href=&quot;https://www.swiftbysundell.com/articles/picking-the-right-way-of-failing-in-swift/&quot; title=&quot;Picking the right way of failing in Swift, by John Sundell&quot;&gt;Isn’t the point of a
precondition to be non-recoverable?&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Yes. Sorry I couldn’t think of a better name&lt;sup&gt;&lt;a href=&quot;#user-content-fn-1&quot; id=&quot;user-content-fnref-1&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;
&lt;h2 id=&quot;the-result&quot;&gt;The Result&lt;/h2&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;/// Checks a necessary condition for making forward progress.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;///&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;/// The difference with `precondition` is that if an error is _thrown_ when the condition is executed, the error will&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;/// be _rethrown_ so that it can be recovered. But this recoverability does not apply if the condition executes&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;/// properly and its condition fails.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;///&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;/// In other words, this function is a wrapper around `precondition` so that it can be fed a condition closure that can&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;/// throw.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;func&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; recoverablePrecondition&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;    _&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; condition: &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;@autoclosure&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; () &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;throws&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; -&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; Bool&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;    _&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; message: &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;@autoclosure&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; () &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; String&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; String&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;    file&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;StaticString&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; #file&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;    line&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;UInt&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; #line&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;rethrows&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    if&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; !&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;try&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; condition&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;()) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;        preconditionFailure&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;message&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(), &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;file&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: file, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;line&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: line)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;what-is-this&quot;&gt;What is this?&lt;/h2&gt;
&lt;p&gt;Let me explain. Here is the code I had:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;precondition&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;aLittleTenderness&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;())&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But then, I had to make &lt;code&gt;aLittleTenderness&lt;/code&gt; able to throw, and &lt;code&gt;precondition&lt;/code&gt;
was yelling at me about it:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;markdown&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;Property access can throw, but it is not marked with &apos;try&apos; and it is executed in&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;a non-throwing autoclosure&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Even when I &lt;em&gt;tried&lt;/em&gt; a little tenderness&lt;sup&gt;&lt;a href=&quot;#user-content-fn-2&quot; id=&quot;user-content-fnref-2&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;precondition&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;try&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; aLittleTenderness&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;())&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The compiler would complain:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;markdown&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;Property access can throw, but it is executed in a non-throwing autoclosure&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And this alternative looked terrible:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;precondition&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;((&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;try?&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; aLittleTenderness&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;()) &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;??&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; false&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So I created a &lt;em&gt;recoverable precondition&lt;/em&gt;, which means:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;if the code throws, then try to recover from it;&lt;/li&gt;
&lt;li&gt;if the code does not throw, treat it as a precondition.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Don’t hate me. &lt;a href=&quot;https://youtu.be/IQ9n2_5mbig&quot; title=&quot;Otis Redding - Try A Little Tenderness - Live 1967 (Reelin&amp;#x27; In The Years Archives)&quot;&gt;Listen to soul music instead&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&quot;lessons-learned&quot;&gt;Lessons Learned&lt;/h2&gt;
&lt;p&gt;Look at this badass signature! Of course I started from the signature of
&lt;a href=&quot;https://developer.apple.com/documentation/swift/1540960-precondition&quot; title=&quot;precondition(_:_:file:line:) Documentation&quot;&gt;&lt;code&gt;precondition&lt;/code&gt;&lt;/a&gt; and I adapted it to my needs. It features some keywords I
don’t use everyday. Each keyword deserves its own extensive explanation. But
wait, other people have already written about them:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://www.swiftbysundell.com/articles/using-autoclosure-when-designing-swift-apis/&quot; title=&quot;Using @autoclosure when designing Swift APIs, by John Sundell&quot;&gt;&lt;code&gt;@autoclosure&lt;/code&gt;&lt;/a&gt;;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.hackingwithswift.com/example-code/language/how-to-use-the-rethrows-keyword&quot; title=&quot;How to use the rethrows keyword, by Paul Hudson&quot;&gt;&lt;code&gt;rethrows&lt;/code&gt;&lt;/a&gt;;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://docs.swift.org/swift-book/ReferenceManual/Expressions.html#ID390&quot; title=&quot;Literal Expression section of the Expressions page of the Swift Reference Manual&quot;&gt;&lt;code&gt;#file&lt;/code&gt; and &lt;code&gt;#line&lt;/code&gt;&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;section data-footnotes class=&quot;footnotes&quot;&gt;&lt;h2 class=&quot;sr-only&quot; id=&quot;footnote-label&quot;&gt;Footnotes&lt;/h2&gt;
&lt;ol&gt;
&lt;li id=&quot;user-content-fn-1&quot;&gt;
&lt;p&gt;If you can think of one, let me know. &lt;a href=&quot;#user-content-fnref-1&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 1&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-2&quot;&gt;
&lt;p&gt;Beware, a terrible music joke is hiding in this statement, can you spot it? &lt;a href=&quot;#user-content-fnref-2&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 2&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;
</content:encoded><category>Swift</category><category>iOS</category></item><item><title>Responding with a HTTP redirect with Vapor</title><link>https://www.mickf.net/tech/http-redirect-with-vapor-in-swift/</link><guid isPermaLink="true">https://www.mickf.net/tech/http-redirect-with-vapor-in-swift/</guid><description>Different strategies — from old fashioned to recommended nowadays — to respond to a HTTP request with a redirection status code.</description><pubDate>Wed, 17 Nov 2021 00:00:00 GMT</pubDate><content:encoded>&lt;h2 id=&quot;the-part-where-i-realize-that-my-http-status-code-knowledge-is-rusty&quot;&gt;The part where I realize that my HTTP status code knowledge is rusty&lt;/h2&gt;
&lt;p&gt;To debug a tricky situation&lt;sup&gt;&lt;a href=&quot;#user-content-fn-1&quot; id=&quot;user-content-fnref-1&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;, I used Vapor to respond with &lt;code&gt;302 Found&lt;/code&gt; to an
HTTP request. Here is the code I ended up with.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; Vapor&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;struct&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; FoundWrapper&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; location: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;String&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;extension&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; FoundWrapper&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;ResponseEncodable &lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    public&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; func&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; encodeResponse&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; request: Request)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        -&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; EventLoopFuture&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;Response&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        var&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; headers &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; HTTPHeaders&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        headers.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;add&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: .location, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: location)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        return&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; request.eventLoop.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;makeSucceededFuture&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(.&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;init&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;            status&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: .found, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;headers&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: headers&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        ))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;func&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; routes&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;_&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; app: Application) &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;throws&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    app.&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;redirect&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;) { &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;_&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; in&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;        FoundWrapper&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;location&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;https://foo.tld/bar&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is the response when requesting that route:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;HTTP/1.1 302 Found&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;location: https://foo.tld/bar&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;At first, I was surprised that this code was not covered by &lt;a href=&quot;https://docs.vapor.codes/4.0/routing/#redirections&quot;&gt;the &lt;em&gt;Redirections&lt;/em&gt;
section of Vapor’s documentation&lt;/a&gt;. But then I learned that many browsers
broke how the 302 status code was intended to behave, and that &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/302&quot;&gt;&lt;code&gt;303 See Other&lt;/code&gt;
and &lt;code&gt;307 Temporary Redirect&lt;/code&gt; should now be favored&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Anyways, this code is useful to respond with an arbitrary status code, and
arbitrary header values. I’m saving it here. 😉&lt;/p&gt;
&lt;h2 id=&quot;the-part-where-i-get-things-right&quot;&gt;The part where I get things right&lt;/h2&gt;
&lt;p&gt;So in this particular situation, the right option was responding with
&lt;code&gt;303 See Other&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Here is the code to do so:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;func&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; routes&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;_&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; app: Application) &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;throws&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    app.&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;redirect&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;) { req &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;in&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        req.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;redirect&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;            to&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;https://foo.tld/bar&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;            type&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: .normal &lt;/span&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;// 303 See Other&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        )&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is the response when requesting that route:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;HTTP/1.1 303 See Other&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;location: https://foo.tld/bar&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;.normal&lt;/code&gt; type being the default, I could have omitted it. But I like to
include defaults in my code when they are not that obvious. It can spare my
future self a click to access the doc to remember what the default status code
is.&lt;/p&gt;
&lt;section data-footnotes class=&quot;footnotes&quot;&gt;&lt;h2 class=&quot;sr-only&quot; id=&quot;footnote-label&quot;&gt;Footnotes&lt;/h2&gt;
&lt;ol&gt;
&lt;li id=&quot;user-content-fn-1&quot;&gt;
&lt;p&gt;“Getting a good experience when clicking an event link in an e-mail”, see
details in &lt;a href=&quot;https://stackoverflow.com/q/69631672/455016&quot;&gt;this Stack Overflow thread&lt;/a&gt;. &lt;a href=&quot;#user-content-fnref-1&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 1&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;
</content:encoded><category>Swift</category><category>Vapor</category></item><item><title>Calling Swift code from Node JS</title><link>https://www.mickf.net/tech/swift-interface-for-node-js/</link><guid isPermaLink="true">https://www.mickf.net/tech/swift-interface-for-node-js/</guid><description>Swift and JavaScript can interact in many different ways. Let’s explore how we could create a dynamic library with Swift code, so that we can call that code from Node JS.</description><pubDate>Sat, 30 Oct 2021 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;For the last 4 years, on a daily basis, I’ve been writing either
JavaScript/TypeScript code (mostly React for the web) or Swift code (mostly for
iOS). I sometimes feel like Megan at the beginning of &lt;a href=&quot;https://www.themoviedb.org/movie/419680-daddy-s-home-2&quot; title=&quot;Daddy’s Home 2 on The Movie DB&quot;&gt;&lt;em&gt;Daddy’s Home 2&lt;/em&gt;&lt;/a&gt; when
she goes on stage to reveal that she wants a normal Christmas instead of having
to celebrate two Christmases in two families&lt;sup&gt;&lt;a href=&quot;#user-content-fn-1&quot; id=&quot;user-content-fnref-1&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;
&lt;p&gt;Yes, I sometimes want my 2 co-languages to live under the same roof.&lt;/p&gt;
&lt;h2 id=&quot;how-can-javascript--swift-interact&quot;&gt;How can JavaScript &amp;amp; Swift interact&lt;/h2&gt;
&lt;p&gt;JavaScript and Swift can interact in many different ways. A non-exhaustive list:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Running JavaScript from Swift code&lt;/strong&gt;. Thanks to &lt;a href=&quot;https://developer.apple.com/documentation/javascriptcore&quot;&gt;JavaScriptCore&lt;/a&gt;, this
option is straightforward. I gave &lt;a href=&quot;https://twitter.com/cocoaheadsparis/status/1060620815467769856&quot;&gt;a talk about it&lt;/a&gt; during a Paris
CocoaHeads session&lt;sup&gt;&lt;a href=&quot;#user-content-fn-2&quot; id=&quot;user-content-fnref-2&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Running Swift code from JavaScript inside the browser&lt;/strong&gt;. Thanks to the
&lt;a href=&quot;https://swiftwasm.org&quot;&gt;Swift WASM project&lt;/a&gt;, this option is pretty easy as well. But I couldn’t
find a good use case for it. And during my POC, a simple Hello World being
displayed in the browser would weigh almost 40 MB and I didn’t pursue this
lead.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img alt=&quot;A screenshot of a WASM hello world weighing 38.47 MB&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;1698&quot; width=&quot;1698&quot; height=&quot;1510&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Fwasm-hello-world.CJR_HyfV.png&amp;amp;w=1920&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;👉 Running Swift code from JavaScript in the terminal with Node 👈&lt;/strong&gt;. This
interaction is what this post is about! A use case could be to write a command
line interface that would use &lt;a href=&quot;https://oclif.io&quot;&gt;oclif&lt;/a&gt; for user interactions while running
Swift code under the hood. Sweet. I am sure there are other possible
Javascript/Swift interactions. If you can think of one, &lt;a href=&quot;https://github.com/dirtyhenry/tech-articles/pulls&quot;&gt;pull requests&lt;/a&gt; are
welcome.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A classic way for 2 languages to run hand-in-hand is to run hand-in-hand-in-hand
with a dynamic library in the middle. Our plan is:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Write a greeting function with Swift;&lt;/li&gt;
&lt;li&gt;Turn this code into a dynamic library;&lt;/li&gt;
&lt;li&gt;Use this dynamic library with Node.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;writing-a-dynamic-library-in-swift&quot;&gt;Writing a dynamic library in Swift&lt;/h2&gt;
&lt;p&gt;In real-life, the plan was trickier and there was a lot of back and forth
between all the steps.&lt;/p&gt;
&lt;p&gt;We can first create a dynamic library using Swift Package Manager:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;// Package.swift&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;library&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;MyDynamicLibrary&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: .dynamic, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;targets&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: [&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;MyLibrary&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;])&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Pretty basic. Let’s move on to a greeting function that will greet what is
passed as an argument.&lt;/p&gt;
&lt;p&gt;My oh-so-naive first draft of interfacable code looked like this:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; func&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; greet&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; String&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    return&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;Hello, &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;\(name)&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;!&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But my successful attempt ended up looking like this:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;@_cdecl&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;greet&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; func&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; greet&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;    cStringName&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;UnsafePointer&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;Int8&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;&amp;gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;    outputSize&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;Int16&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;    output&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;UnsafeMutablePointer&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;Int8&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; Bool&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; name &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; String&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;cString&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: cStringName)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; cString &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;Hello, &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;\(name)&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;!&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;cString&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: .&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;utf8&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;!&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    for&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; (index, char) &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; cString.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;enumerated&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;() {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        if&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; (index &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;&amp;gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; outputSize) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;            return&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; false&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        output.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;advanced&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;by&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: index).&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;pointee&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; char&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    return&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; true&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Lessons learned:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;An interoperable string is called a C String, which translates to a
&lt;code&gt;UnsafePointer&amp;lt;Int8&amp;gt;&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;Returning the output — a pointer — as a result of the function will result in
an error. Instead, returning a boolean — a value — indicating the success of
the execution makes more sense. My guess is that the library would release the
memory as soon as the function had returned, hence preventing Node to read
something meaningful in memory. Responsibilities should be switched and the
caller should provide writable memory where the library will copy the greeting
so that the caller can read it. And thus, for a proper error management and
prevent dreaded &lt;code&gt;segmentation fault&lt;/code&gt; errors, the caller needs to mention how
big the memory allocation is to the library;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/4506121/how-to-print-a-list-of-symbols-exported-from-a-dynamic-library&quot;&gt;&lt;code&gt;nm -gU&lt;/code&gt;&lt;/a&gt; is a command line tool that will display the list of external
symbols of a dynamic library;&lt;/li&gt;
&lt;li&gt;In order for the library to include searchable symbols, we need to use &lt;a href=&quot;https://forums.swift.org/t/formalizing-cdecl/40677&quot;&gt;this
&lt;code&gt;@_cdecl&lt;/code&gt; annotation&lt;/a&gt; that is private with Swift.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Rough trip. But it was fun.&lt;/p&gt;
&lt;h2 id=&quot;using-the-dynamic-library-from-node&quot;&gt;Using the dynamic library from Node&lt;/h2&gt;
&lt;p&gt;Similarly, this is the end result for the Node code.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;var ffi = require(&quot;ffi-napi&quot;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;var myLib = ffi.Library(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  &quot;../MyLibrary/.build/x86_64-apple-macosx/debug/libMyDynamicLibrary.dylib&quot;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    greet: [&quot;bool&quot;, [&quot;string&quot;, &quot;int&quot;, &quot;string&quot;]],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;const maxStringLength = 20;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;const theStringBuffer = Buffer.alloc(maxStringLength);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;const isSuccess = myLib.greet(&quot;Mick&quot;, maxStringLength, theStringBuffer);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;if (isSuccess) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  // Retrieve and convert the result back to a JavaScript string&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  var theString = theStringBuffer.toString(&quot;utf-8&quot;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  console.log(`The string: ${theString}`);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  process.exit(0);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;} else {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  console.error(`Calling greet failed.`);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  process.exit(1);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Lesson learned: interoperating with our dynamic library requires a certain kind
of library called a &lt;em&gt;FFI&lt;/em&gt;, standing for &lt;a href=&quot;https://en.wikipedia.org/wiki/Foreign_function_interface&quot;&gt;&lt;em&gt;Foreign Function Interface&lt;/em&gt;&lt;/a&gt;. The
&lt;a href=&quot;https://www.npmjs.com/package/ffi&quot;&gt;&lt;code&gt;ffi&lt;/code&gt;&lt;/a&gt; module didn’t work. Not sure why 🤷. &lt;a href=&quot;https://www.npmjs.com/package/ffi-napi&quot;&gt;&lt;code&gt;ffi-napi&lt;/code&gt;&lt;/a&gt; did work. Its
documentation is good enough to get inspired by examples for simple use cases.&lt;/p&gt;
&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;shell&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;➜&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;  node&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; index.js&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;The&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; string:&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; --Hello,&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; Mick!--&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;💪🎉 Node provided the argument, but the greeting is done with Swift.&lt;/p&gt;
&lt;h2 id=&quot;epilogue&quot;&gt;Epilogue&lt;/h2&gt;
&lt;p&gt;Please watch &lt;a href=&quot;https://www.themoviedb.org/movie/419680-daddy-s-home-2&quot; title=&quot;Daddy’s Home 2 on The Movie DB&quot;&gt;&lt;em&gt;Daddy’s Home 2&lt;/em&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;section data-footnotes class=&quot;footnotes&quot;&gt;&lt;h2 class=&quot;sr-only&quot; id=&quot;footnote-label&quot;&gt;Footnotes&lt;/h2&gt;
&lt;ol&gt;
&lt;li id=&quot;user-content-fn-1&quot;&gt;
&lt;p&gt;Best movie of the decade. I am dead serious. &lt;a href=&quot;#user-content-fnref-1&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 1&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-2&quot;&gt;
&lt;p&gt;I just realized the talks is not available on YouTube anymore so I will have
to repost its content online soon. &lt;a href=&quot;#user-content-fnref-2&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 2&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;
</content:encoded><category>Swift</category><category>Node.js</category><category>TypeScript</category><category>JavaScript</category></item><item><title>PKCE in Swift: Generating Cryptographically Secure Code Verifiers and Code Challenges</title><link>https://www.mickf.net/tech/oauth-pkce-swift-secure-code-verifiers-and-code-challenges/</link><guid isPermaLink="true">https://www.mickf.net/tech/oauth-pkce-swift-secure-code-verifiers-and-code-challenges/</guid><description>I started a side-project using the Spotify API. The first part of the journey was about getting access tokens to reach the API. Here are lessons learned from implementing OAuth 2.0 with the PKCE extension.</description><pubDate>Wed, 05 May 2021 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;I am making an app that uses the Spotify API. The typical first step to
successfully fetch API endpoints is to complete the authorization flow. The
Spotify API uses the &lt;em&gt;Proof Key for Code Exchange&lt;/em&gt; (&lt;em&gt;PKCE&lt;/em&gt; which is pronounced
“pixy”) extension of OAuth 2.0 to do so. This post presents the code I wrote to
generate the code verifier and the code challenge required to receive an access
token with PKCE.&lt;/p&gt;
&lt;h2 id=&quot;creating-a-code-verifier&quot;&gt;Creating a code verifier&lt;/h2&gt;
&lt;p&gt;Reading &lt;a href=&quot;https://tools.ietf.org/html/rfc7636&quot;&gt;the RFC for PKCE&lt;/a&gt;, the first step is to create a &lt;em&gt;code verifier&lt;/em&gt;, ie
a random string that must meet the following requirements:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;contains characters in the set: [A-Z] / [a-z] / [0-9] / “-” / “.” / “_” /
“~”;&lt;/li&gt;
&lt;li&gt;minimum length of 43 characters and a maximum length of 128 characters;&lt;/li&gt;
&lt;li&gt;has enough &lt;em&gt;entropy&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Entropy is a term used in thermodynamics to quantify states of disorder,
randomness and uncertainty. The higher the entropy, the more unpredictable the
state becomes. Applied to PKCE, the higher the entropy, the harder it would be
for a potential attacker to learn or guess how code verifiers are created.&lt;/p&gt;
&lt;p&gt;With Swift, the &lt;a href=&quot;https://developer.apple.com/documentation/security/1399291-secrandomcopybytes&quot;&gt;&lt;code&gt;SecRandomCopyBytes&lt;/code&gt;&lt;/a&gt; function in the &lt;a href=&quot;https://developer.apple.com/documentation/security&quot;&gt;Security
framework&lt;/a&gt; will help us comply with this entropy requirement.&lt;/p&gt;
&lt;p&gt;We first create an array of 32 zeroed octets&lt;sup&gt;&lt;a href=&quot;#user-content-fn-1&quot; id=&quot;user-content-fnref-1&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;, that we will feed into
&lt;code&gt;SecRandomCopyBytes&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;func&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; generateCryptographicallySecureRandomOctets&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;count&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;Int&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;throws&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; -&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;UInt8&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;] {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    var&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; octets &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;UInt8&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;](&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;repeating&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;count&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: count)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; status &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; SecRandomCopyBytes&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(kSecRandomDefault, octets.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;count&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;octets)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    if&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; status &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; errSecSuccess { &lt;/span&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;// Always test the status.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        return&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; octets&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    } &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;else&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        throw&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; PKCEError.failedToGenerateRandomOctets&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Calling this function multiple times will return different results that should
be unpredictable.&lt;/p&gt;
&lt;p&gt;Next, we need to transform these octets into a Base64-URL encoded string.
Beware, this is different than a Base64 encoded string. Different but close
enough to base an implementation on it, as recommended by the RFC’s Appendix A:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;func&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; base64URLEncode&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;octets&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: [&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;UInt8&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;]) &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; String&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; data &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; Data&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;bytes&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: octets, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;count&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: octets.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;count&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    return&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; data&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        .&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;base64EncodedString&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;()                    &lt;/span&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;// Regular base64 encoder&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        .&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;replacingOccurrences&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;of&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;=&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;with&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)  &lt;/span&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;// Remove any trailing &apos;=&apos;s&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        .&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;replacingOccurrences&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;of&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;+&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;with&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;-&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;// 62nd char of encoding&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        .&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;replacingOccurrences&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;of&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;/&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;with&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;_&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;// 63rd char of encoding&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        .&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;trimmingCharacters&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: .whitespaces)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We have a code verifier:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;// This is using a pipe-forward operator to compose functions with ease.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;// Check out the Playground code for the missing code,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;// Or https://www.pointfree.co/episodes/ep1-functions for more details.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; codeVerifier &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; try&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; 32&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    |&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; generateCryptographicallySecureRandomOctets&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    |&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; base64URLEncode&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Wait: why did we use 32 octets to generate a string of 43 characters? Since our
resulting string uses an alphabet of 64 letters&lt;sup&gt;&lt;a href=&quot;#user-content-fn-4&quot; id=&quot;user-content-fnref-4&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;, ie &lt;code&gt;2^6&lt;/code&gt;, each character
will code 6 bits. Since 32 octets are 256 bits, it requires 43&lt;sup&gt;&lt;a href=&quot;#user-content-fn-3&quot; id=&quot;user-content-fnref-3&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;3&lt;/a&gt;&lt;/sup&gt; characters to
be represented.&lt;/p&gt;
&lt;h2 id=&quot;creating-the-code-challenge&quot;&gt;Creating the code challenge&lt;/h2&gt;
&lt;p&gt;Creating the challenge is a matter of transforming the verifier with a series of
operations.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;func&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; challenge&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; verifier: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;throws&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; -&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; String&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; challenge &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; verifier&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        .&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;data&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: .ascii) &lt;/span&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;// (a)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        .&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;map&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; { SHA256.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;hash&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;data&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;$0&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;) } &lt;/span&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;// (b)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        .&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;map&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; { &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;base64URLEncode&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;octets&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;$0&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;) } &lt;/span&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;// (c)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    if&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; challenge &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; challenge {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        return&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; challenge&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    } &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;else&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        throw&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; PKCEError.failedToCreateChallengeForVerifier&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The operations are as follow:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;(a) convert the verifier string back into a collection of octets;&lt;/li&gt;
&lt;li&gt;(b) create a SHA-256 hash of that data with &lt;code&gt;SHA256&lt;/code&gt;, that is available either
from &lt;a href=&quot;https://developer.apple.com/documentation/cryptokit/sha256&quot;&gt;Apple CryptoKit&lt;/a&gt; on supported platforms or &lt;a href=&quot;https://apple.github.io/swift-crypto/docs/current/Crypto/Structs/SHA256.html&quot;&gt;Swift Crypto&lt;/a&gt; for
others.&lt;/li&gt;
&lt;li&gt;(c) transform into a Base64-URL encoded string.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;As it is, the code won’t compile:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;Cannot convert value of type &apos;SHA256.Digest&apos; (aka &apos;SHA256Digest&apos;) to expected argument type &apos;[UInt8]&apos;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is a good opportunity to transform the signature of our &lt;code&gt;base64URLEncode&lt;/code&gt;
function so that it can accept both a &lt;code&gt;[UInt8]&lt;/code&gt; or a &lt;code&gt;SHA256.Digest&lt;/code&gt;&lt;sup&gt;&lt;a href=&quot;#user-content-fn-2&quot; id=&quot;user-content-fnref-2&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;4&lt;/a&gt;&lt;/sup&gt; as an
input:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;func&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; base64URLEncode&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;S&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;&amp;gt;(&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;octets&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: S) &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; String&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; where&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; S &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; Sequence&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;UInt8&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; ==&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; S.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;Element&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; data &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; Data&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(octets)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    return&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; data&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        .&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;base64EncodedString&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;() &lt;/span&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;// Regular base64 encoder&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        .&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;replacingOccurrences&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;of&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;=&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;with&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;// Remove any trailing &apos;=&apos;s&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        .&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;replacingOccurrences&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;of&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;+&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;with&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;-&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;// 62nd char of encoding&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        .&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;replacingOccurrences&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;of&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;/&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;with&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;_&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;// 63rd char of encoding&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        .&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;trimmingCharacters&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: .whitespaces)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;testing-our-code&quot;&gt;Testing our code&lt;/h2&gt;
&lt;p&gt;The RFC provides testing samples so let’s use this provided data set to validate
this code:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;assertEqual&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;base64URLEncode&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;octets&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: [&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;236&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;255&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;224&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;193&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;]), &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;A-z_4ME&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; verifier &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; base64URLEncode&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;octets&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: [&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;    116&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;24&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;223&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;180&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;151&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;153&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;224&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;37&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;79&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;250&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;96&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;125&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;216&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;173&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;    187&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;186&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;22&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;212&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;37&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;77&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;105&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;214&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;191&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;240&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;91&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;88&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;88&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;83&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;    132&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;141&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;121&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;])&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;assertEqual&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(verifier, &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;assertEqual&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;try!&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; challenge&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: verifier), &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And let’s validate that we can create verifiers of lengths that can cover the
whole range:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; codeVerifier43 &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; try&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; 32&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    |&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; generateCryptographicallySecureRandomOctets&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    |&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; base64URLEncode&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;assertEqual&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(codeVerifier43.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;count&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;43&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; codeVerifier128 &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; try&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; 96&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    |&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; generateCryptographicallySecureRandomOctets&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    |&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; base64URLEncode&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;assertEqual&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(codeVerifier128.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;count&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;128&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;🎉 A lot of green in the output!&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;✅ A-z_4ME == A-z_4ME&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;✅ dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk == dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;✅ E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM == E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;✅ 43 == 43&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;✅ 128 == 128&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Check out &lt;a href=&quot;https://github.com/dirtyhenry/xcode-playgrounds/tree/main/PKCE.playground&quot;&gt;⛹️ the playground&lt;/a&gt; to run the code in Xcode. More to come on this
Spotify API exploration.&lt;/p&gt;
&lt;section data-footnotes class=&quot;footnotes&quot;&gt;&lt;h2 class=&quot;sr-only&quot; id=&quot;footnote-label&quot;&gt;Footnotes&lt;/h2&gt;
&lt;ol&gt;
&lt;li id=&quot;user-content-fn-1&quot;&gt;
&lt;p&gt;Being French, I prefer using the word &lt;code&gt;octets&lt;/code&gt; — the same as in French —
than &lt;code&gt;bytes&lt;/code&gt;. &lt;a href=&quot;#user-content-fnref-1&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 1&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-4&quot;&gt;
&lt;p&gt;Even though the RFC first mentions a set of 66 characters, the &lt;a href=&quot;https://tools.ietf.org/html/rfc4648#section-5&quot;&gt;Base64-URL
RFC&lt;/a&gt; excluded &lt;code&gt;.&lt;/code&gt; and &lt;code&gt;~&lt;/code&gt; for their special meaning on some file systems. &lt;a href=&quot;#user-content-fnref-4&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 2&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-3&quot;&gt;
&lt;p&gt;32 × 8 / 6 = 42.7 ⇒ 43 bits are required. &lt;a href=&quot;#user-content-fnref-3&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 3&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-2&quot;&gt;
&lt;p&gt;When digging in the documentation, you will find that &lt;code&gt;SHA256.Digest&lt;/code&gt;
conforms to &lt;code&gt;Digest&lt;/code&gt; which conforms itself to a &lt;code&gt;Sequence&lt;/code&gt; with an element
of &lt;code&gt;UInt8&lt;/code&gt;. &lt;a href=&quot;#user-content-fnref-2&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 4&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;
</content:encoded><category>Swift</category><category>OAuth</category><category>PKCE</category><category>CryptoKit</category></item><item><title>Notes From Swift Heroes Digital 2021</title><link>https://www.mickf.net/tech/swift-heroes-digital-2021/</link><guid isPermaLink="true">https://www.mickf.net/tech/swift-heroes-digital-2021/</guid><description>Among the talks I recommend the most: digging down into Core Text, the future of asynchronous development in Swift with `async/await` and how Core Data is still relevant when using SwiftUI.</description><pubDate>Fri, 16 Apr 2021 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;a href=&quot;https://swiftheroes.com/2021/&quot;&gt;Swift Heroes&lt;/a&gt; went digital because of the Covid pandemic restricting public
gatherings. I am not the best at socializing during conferences and watching
online talks from my comfy chair is a format that I somewhat shamefully enjoyed.
Here are my notes from the talks I have watched.&lt;/p&gt;
&lt;p&gt;Talks with 🌟 are the talks I recommend the most.&lt;/p&gt;
&lt;h2 id=&quot;lets-make-that-label-with-core-text---marcin-krzyzanowski-&quot;&gt;Let’s Make That Label With Core Text - &lt;a href=&quot;https://twitter.com/krzyzanowskim&quot;&gt;Marcin Krzyzanowski&lt;/a&gt; 🌟&lt;/h2&gt;
&lt;p&gt;Marcin is working on his &lt;a href=&quot;https://swiftstudio.app/&quot;&gt;Swift Studio&lt;/a&gt; project, a Swift IDE for which he had
to dig down deep into the Core Text framework. I enjoyed this talk following &lt;a href=&quot;https://www.mickf.net/tech/line-height-with-uikit/&quot;&gt;my
own errands on text layout customization&lt;/a&gt; and I intend to use the content of
his talk to address another use case: how to balance the lengths of broken lines
of text, to avoid a situation where the last line can be much shorter than its
siblings.&lt;/p&gt;
&lt;h2 id=&quot;future-of-swift-a-sneak-peek-at-asyncawait---vincent-pradeilles-&quot;&gt;Future of Swift: A Sneak Peek at &lt;code&gt;async/await&lt;/code&gt; - &lt;a href=&quot;https://twitter.com/v_pradeilles&quot;&gt;Vincent Pradeilles&lt;/a&gt; 🌟&lt;/h2&gt;
&lt;p&gt;Vincent presented the &lt;a href=&quot;https://github.com/apple/swift-evolution/blob/main/proposals/0296-async-await.md&quot;&gt;&lt;code&gt;async/await&lt;/code&gt; proposal&lt;/a&gt; that will be part of Swift
5.5. On the way, he explained how to install the development snapshots of Swift
in Xcode, insisted that &lt;code&gt;async/await&lt;/code&gt; would not be competing with Combine and
mentioned exciting &lt;a href=&quot;https://forums.swift.org/t/swift-concurrency-roadmap/41611&quot;&gt;upcoming features for Swift concurrency&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&quot;using-core-data-in-a-modern-swiftui-application---donny-wals-&quot;&gt;Using Core Data in a Modern SwiftUI Application - &lt;a href=&quot;https://twitter.com/donnywals&quot;&gt;Donny Wals&lt;/a&gt; 🌟&lt;/h2&gt;
&lt;p&gt;Until 2017, I was using Core Data on a daily basis. But since, I have not used
it at all. I had the feeling it was becoming a dying technology but this talk
convinced me it was still very relevant since Donny makes the case it integrates
really well with SwiftUI since &lt;code&gt;NSManagedObject&lt;/code&gt; conforms to &lt;code&gt;ObservableObject&lt;/code&gt;.
Donny wrote a book about it, &lt;a href=&quot;https://gumroad.com/l/practical-core-data&quot;&gt;&lt;em&gt;Practical Core Data&lt;/em&gt;&lt;/a&gt; that digs further on
the topic.&lt;/p&gt;
&lt;h2 id=&quot;evolving-existing-projects-with-swiftui---peter-steinberger&quot;&gt;Evolving Existing Projects With SwiftUI - &lt;a href=&quot;https://steipete.me/&quot;&gt;Peter Steinberger&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;This felt like a natural follow-up to Peter’s talk at &lt;a href=&quot;https://www.mickf.net/tech/frenchkit-2019/&quot;&gt;FrenchKit 2019&lt;/a&gt; about
&lt;a href=&quot;https://youtu.be/Xo3zGlyxXcI&quot;&gt;shipping a Catalyst app&lt;/a&gt;. He offered feedback on integrating small doses of
SwiftUI in a large codebase with a long history that is a mix of Objective-C and
Swift.&lt;/p&gt;
&lt;p&gt;Here is what I’ll take away from the talk:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;SwiftUI is unstable and change dramatically at each version;&lt;/li&gt;
&lt;li&gt;Previews can time out being &lt;em&gt;de facto&lt;/em&gt; unreliable;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;GeometryReader&lt;/code&gt; should be used as high in the hierarchy as possible;&lt;/li&gt;
&lt;li&gt;There are straightforward workarounds to SwiftUI limitations — via custom view
modifiers for instance — but they should be considered as hacks with the risks
it implies in terms of maintenance;&lt;/li&gt;
&lt;li&gt;Mentioned projects were:
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/siteline/SwiftUI-Introspect&quot;&gt;SwiftUI-Introspect&lt;/a&gt;: helps to introspect underlying UIKit components
from SwiftUI;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://swiftuix.com/&quot;&gt;SwiftUIX&lt;/a&gt;: a project that attempts to fill the gaps that SwiftUI suffers
from when compared to UIKit or AppKit.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;combining-swiftui-and-uikit-appclips-and-widgets---anna-zharkova&quot;&gt;Combining SwiftUI and UIKit: AppClips and Widgets - &lt;a href=&quot;https://twitter.com/anioutkajarkova&quot;&gt;Anna Zharkova&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Widgets and AppClips are additions to iOS that come with significant
restrictions compared to what you can achieve in an app. Anna presented
workarounds against the lack of dynamism that she met while developing widgets
and app clips using bike ride maps as an example.&lt;/p&gt;
&lt;p&gt;My main takeaway is that, since neither the keychain or local authentication can
be used in these app-derivatives, then if any of the data you would like to
present require authentication, you are out of luck.&lt;/p&gt;
&lt;h2 id=&quot;creating-machine-learning-models-with-create-ml---moritz-philip-recke-tiago-gomes-pereira--giovanni-monaco&quot;&gt;Creating Machine Learning Models With Create ML - Moritz Philip Recke, Tiago Gomes Pereira &amp;amp; Giovanni Monaco&lt;/h2&gt;
&lt;p&gt;This talk was presenting how to create machine learning models with convenience
using &lt;a href=&quot;https://github.com/cloud-annotations/cloud-annotations&quot;&gt;IBM’s Cloud Annotations tool&lt;/a&gt; to create training and testing data
sets, and feeding these into the macOS &lt;a href=&quot;https://developer.apple.com/machine-learning/create-ml/&quot;&gt;Create ML&lt;/a&gt; app. It did sound
accessible and I intend to give it a try one day.&lt;/p&gt;
&lt;h2 id=&quot;mocka-a-mock-server-for-developers-by-developers---fabrizio-brancati--firas-safa&quot;&gt;Mocka: A Mock Server for Developers by Developers - Fabrizio Brancati &amp;amp; Firas Safa&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/wise-emotions/mocka&quot;&gt;Mocka&lt;/a&gt; is an open-source server to mock backend API responses to test
backend edge cases with convenience. The project is promising and I will keep an
eye on it but it is still a young product with many missing features so I am not
sure I will start using it today.&lt;/p&gt;
&lt;h2 id=&quot;how-to-think-like-a-swiftui-view-modifier---josh-holtz&quot;&gt;How to Think Like a SwiftUI View Modifier - &lt;a href=&quot;https://twitter.com/joshdholtz&quot;&gt;Josh Holtz&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Josh presented some view modifiers he programmed and the struggles and pitfalls
he met on the way. A good time saver for people starting learning SwiftUI.&lt;/p&gt;
&lt;h2 id=&quot;full-stack-swift-development---kilo-loco&quot;&gt;Full Stack Swift Development - &lt;a href=&quot;https://twitter.com/kilo_loco&quot;&gt;Kilo Loco&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Kilo is a developer advocate for AWS and gave a fair overview of technologies to
use Swift on the backend, even though he obviously highlighted AWS Amplify. It
felt like investing on AWS technologies could result in a lock-in so I was not
convinced I would invest in this direction for hobby projects.&lt;/p&gt;
</content:encoded><category>Conference</category><category>Swift</category><category>SwiftUI</category><category>iOS</category></item><item><title>How I Decode ISO 8601 Dates from JSON APIs in Swift</title><link>https://www.mickf.net/tech/json-dates-swift/</link><guid isPermaLink="true">https://www.mickf.net/tech/json-dates-swift/</guid><description>JSONDecoder&apos;s .iso8601 strategy rejects fractional seconds, and the deferredToDate default isn&apos;t what APIs send. Why, and the date strategy I use instead.</description><pubDate>Tue, 30 Mar 2021 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;This blog post will present why I’m frustrated with the current state of
&lt;code&gt;JSONDecoder&lt;/code&gt; and &lt;code&gt;JSONEncoder&lt;/code&gt;&lt;sup&gt;&lt;a href=&quot;#user-content-fn-3&quot; id=&quot;user-content-fnref-3&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;, how I think dates should be formatted in a
JSON API, and the code I write to handle JSON date decoding and encoding in my
applications.&lt;/p&gt;
&lt;h2 id=&quot;the-problem-with-codables-json-support&quot;&gt;The Problem with &lt;code&gt;Codable&lt;/code&gt;’s JSON Support&lt;/h2&gt;
&lt;p&gt;Swift has 1st-party support for JavaScript script execution. Let’s create a
simple JSON payload including a date field in Swift:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; javaScriptContext &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; JSContext&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;!&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; jsonPayload &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; javaScriptContext.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;evaluateScript&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;const payload = { message: &apos;👋&apos;, creationDate: new Date() };&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;JSON.stringify(payload)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;// =&amp;gt; {&quot;message&quot;:&quot;👋&quot;,&quot;creationDate&quot;:&quot;2021-03-28T13:10:35.656Z&quot;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now let’s decode this JSON string with Swift:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;struct&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; PayloadStruct&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;Codable &lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; message: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;String&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; creationDate: Date&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;do&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;    _&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; try&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; jsonPayload&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;?&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;toString&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;?&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;data&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: .&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;utf8&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;).&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;map&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        try&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; JSONDecoder&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;().&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;decode&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(PayloadStruct.&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;$0&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;} &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;catch&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; DecodingError.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;typeMismatch&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(type, context) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;    dump&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(type)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;    dump&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(context) &lt;/span&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;// creationDate: Expected to decode Double but found a string/data instead.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This code throws a &lt;code&gt;DecodingError.typeMismatch&lt;/code&gt; error with the following
description: &lt;code&gt;Expected to decode Double but found a string/data instead.&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;This is because, by default, a &lt;code&gt;Date&lt;/code&gt; type is expected to be a &lt;code&gt;Double&lt;/code&gt;
specifying the number of seconds since 00:00:00 UTC on 1 January 2001. But the
date in our JSON string is formatted as ISO 8601.&lt;/p&gt;
&lt;p&gt;Let’s use &lt;code&gt;JSONDecoder&lt;/code&gt;’s built-in &lt;code&gt;.iso8601&lt;/code&gt; configuration of
&lt;code&gt;DateDecodingStrategy&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;do&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; jsonDecoder &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; JSONDecoder&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    jsonDecoder.dateDecodingStrategy &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; .iso8601&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;    _&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; try&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; jsonPayload&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;?&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;toString&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;?&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;data&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: .&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;utf8&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;).&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;map&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        try&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; jsonDecoder.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;decode&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(PayloadStruct.&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;$0&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;} &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;catch&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; DecodingError.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;dataCorrupted&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(context) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;    dump&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(context)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Another error? This time, the code throws a &lt;code&gt;DecodingError.dataCorrupted&lt;/code&gt; error
with the following description: &lt;code&gt;Expected date string to be ISO8601-formatted&lt;/code&gt;.
What is going on? 🤔&lt;/p&gt;
&lt;h2 id=&quot;there-is-no-date-in-json-but-there-is-in-js&quot;&gt;There is no date in JSON, but there is in JS&lt;/h2&gt;
&lt;p&gt;True, &lt;a href=&quot;https://www.json.org/&quot;&gt;JSON&lt;/a&gt; does not specify a format for dates. And if projects such as
&lt;a href=&quot;https://jsonapi.org/&quot;&gt;JSON API&lt;/a&gt; do &lt;a href=&quot;https://jsonapi.org/recommendations/#date-and-time-fields&quot;&gt;recommend&lt;/a&gt; using ISO 8601, because the &lt;a href=&quot;https://www.w3.org/TR/NOTE-datetime&quot;&gt;W3C&lt;/a&gt; also thinks
that this format makes the most sense, they are not clear about what exact
flavor of ISO 8601 should be used.&lt;/p&gt;
&lt;p&gt;But let’s remember that JSON stands for &lt;em&gt;JavaScript Object Notation&lt;/em&gt; and that
&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toJSON&quot;&gt;JavaScript does specify how to format its date type in JSON&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;If you want to refer to April 23rd 2012, at 6:25:43PM UTC timezone, at
millisecond 511, then, whatever your own timezone, you should use:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;2012-04-23T18:25:43.511Z&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Why?&lt;sup&gt;&lt;a href=&quot;#user-content-fn-1&quot; id=&quot;user-content-fnref-1&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;It is readable for humans;&lt;/li&gt;
&lt;li&gt;It sorts correctly;&lt;/li&gt;
&lt;li&gt;It includes fractional seconds, which can help re-establish chronology.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In Swift, this format is achieved by using a &lt;code&gt;ISO8601DateFormatter&lt;/code&gt; — beware,
not a &lt;code&gt;DateFormatter&lt;/code&gt; — set up with the formatting options
&lt;code&gt;.withInternetDateTime&lt;/code&gt; (which is the default), and &lt;code&gt;.withFractionalSeconds&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&quot;a-swift-class-and-convenient-extensions-to-manage-dates-in-json-api&quot;&gt;A Swift class and convenient extensions to manage dates in JSON API&lt;/h2&gt;
&lt;p&gt;As of today, here are the options for the enum
&lt;a href=&quot;https://developer.apple.com/documentation/foundation/jsondecoder/datedecodingstrategy&quot;&gt;&lt;code&gt;JSONDecoder.DateDecodingStrategy&lt;/code&gt;&lt;/a&gt; that &lt;code&gt;JSONDecoder&lt;/code&gt; can use:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;code&gt;deferredToDate&lt;/code&gt;: the default using a &lt;code&gt;TimeInterval&lt;/code&gt; (ie an alias to
&lt;code&gt;Double&lt;/code&gt;) that is not human-readable;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;iso8601&lt;/code&gt;: this option is using ISO 8601 without fractional seconds, which is
against the usage and JavaScript’s spec;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;formatted(DateFormatter)&lt;/code&gt;: never use this since you might — for instance —
break for users with a 12-hour AM/PM time formatting, which is a lesson I
learned the hard way&lt;sup&gt;&lt;a href=&quot;#user-content-fn-2&quot; id=&quot;user-content-fnref-2&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;custom((Decoder) -&amp;gt; Date)&lt;/code&gt;: 🎉 this is the option we want and here is the
version I suggest 👇.&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; JavaScriptISO8601DateFormatter&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    static&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; fractionalSecondsFormatter: ISO8601DateFormatter &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; res &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; ISO8601DateFormatter&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;        // The default format options is .withInternetDateTime.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;        // We need to add .withFractionalSeconds to parse dates with milliseconds.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        res.formatOptions &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; [.withInternetDateTime, .withFractionalSeconds]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        return&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; res&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    }()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    static&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; defaultFormatter &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; ISO8601DateFormatter&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    static&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; func&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; decodedDate&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;_&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; decoder: Decoder) &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;throws&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; -&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; Date {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; container &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; try&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; decoder.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;singleValueContainer&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; dateAsString &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; try&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; container.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;decode&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;        // See warning below.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        for&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; formatter &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; [fractionalSecondsFormatter, defaultFormatter] {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;            if&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; res &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; formatter.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;date&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: dateAsString) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;                return&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; res&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;            }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        throw&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; DecodingError.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;dataCorrupted&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(DecodingError.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;Context&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;            codingPath&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: decoder.codingPath,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;            debugDescription&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;Expected date string to be JavaScript-ISO8601-formatted.&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        ))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    static&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; func&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; encodeDate&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;date&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: Date, &lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;encoder&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: Encoder) &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;throws&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        var&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; container &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; encoder.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;singleValueContainer&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        try&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; container.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;encode&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(fractionalSecondsFormatter.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: date))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    private&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; init&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;() {}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;extension&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; JSONDecoder.DateDecodingStrategy&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    static&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; func&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; javaScriptISO8601&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;() &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; JSONDecoder.DateDecodingStrategy {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        .&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;custom&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(JavaScriptISO8601DateFormatter.decodedDate)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;extension&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; JSONDecoder&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    static&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; func&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; javaScriptISO8601&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;() &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; JSONDecoder {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; res &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; JSONDecoder&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        res.dateDecodingStrategy &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; .&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;javaScriptISO8601&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        return&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; res&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;extension&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; JSONEncoder.DateEncodingStrategy&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    static&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; func&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; javaScriptISO8601&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;() &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; JSONEncoder.DateEncodingStrategy {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        .&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;custom&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(JavaScriptISO8601DateFormatter.encodeDate)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;extension&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; JSONEncoder&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    static&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; func&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; javaScriptISO8601&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;() &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; JSONEncoder {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; res &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; JSONEncoder&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        res.dateEncodingStrategy &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; .&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;javaScriptISO8601&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        return&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; res&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;⚠️ In this code, I attempt decoding dates with 2 formatters: one that supports
fractional seconds and one that does not. The reason is that the JSON of the API
my app was consuming was coming from a Kotlin backend that used Java’s
&lt;a href=&quot;https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html&quot;&gt;&lt;code&gt;DateTimeFormatter&lt;/code&gt;&lt;/a&gt; that stipulates:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;If the nano-of-second is zero or not available then the format is complete.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Statistically speaking, 99,9% of the API would be formatted with fractional
seconds — that’s why we attempt decoding dates with this formatter first —, and
0,1% without. 🤷&lt;/p&gt;
&lt;h2 id=&quot;usage&quot;&gt;Usage&lt;/h2&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; payload &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; try&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; jsonPayload&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;?&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;toString&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;?&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;data&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: .&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;utf8&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;).&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;map&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    try&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; JSONDecoder.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;javaScriptISO8601&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;().&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;decode&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(PayloadStruct.&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;$0&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; reencodedJSONPayload &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;try?&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; JSONEncoder.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;javaScriptISO8601&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;().&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;encode&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(payload)).&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;flatMap&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;    String&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;data&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;$0&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;encoding&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: .&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;utf8&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Check out &lt;a href=&quot;https://github.com/dirtyhenry/xcode-playgrounds/tree/main/JSON-date.playground&quot;&gt;⛹️ the playground&lt;/a&gt; to run the code in Xcode.&lt;/p&gt;
&lt;section data-footnotes class=&quot;footnotes&quot;&gt;&lt;h2 class=&quot;sr-only&quot; id=&quot;footnote-label&quot;&gt;Footnotes&lt;/h2&gt;
&lt;ol&gt;
&lt;li id=&quot;user-content-fn-3&quot;&gt;
&lt;p&gt;The good news being that the community is &lt;a href=&quot;https://forums.swift.org/t/serialization-in-swift/46641&quot;&gt;currently collecting
feedbacks&lt;/a&gt; to iterate over Swift’s serialization features. &lt;a href=&quot;#user-content-fnref-3&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 1&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-1&quot;&gt;
&lt;p&gt;Please refer to &lt;a href=&quot;https://stackoverflow.com/questions/10286204/what-is-the-right-json-date-format&quot;&gt;this StackOverflow thread&lt;/a&gt; for a more elaborate
conversation about this issue. &lt;a href=&quot;#user-content-fnref-1&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 2&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-2&quot;&gt;
&lt;p&gt;And knowing that &lt;a href=&quot;https://github.com/Ranchero-Software/NetNewsWire/commit/afbe25a26c291dc5d006dfda2eb4650bcaa9f9f7&quot;&gt;I am not the only one&lt;/a&gt; does make me feel better. &lt;a href=&quot;#user-content-fnref-2&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 3&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;
</content:encoded><category>Swift</category><category>iOS</category><category>JSON</category><category>JavaScript</category></item><item><title>I Care (And Code) a Lot</title><link>https://www.mickf.net/tech/i-care-a-lot/</link><guid isPermaLink="true">https://www.mickf.net/tech/i-care-a-lot/</guid><description>A fun CSS experiment to reproduce a 90s inspired still from the trailer of the movie *I Care a Lot*.</description><pubDate>Wed, 24 Mar 2021 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;When I watched the &lt;a href=&quot;https://youtu.be/D40uHmTSPew&quot;&gt;trailer&lt;/a&gt; of Netflix’s &lt;a href=&quot;https://www.themoviedb.org/movie/601666-i-care-a-lot&quot;&gt;&lt;em&gt;I Care a Lot&lt;/em&gt;&lt;/a&gt; — which I
recommend —, a text-effect it used striked some nostalgia from the 90s. It had
this vintage Nike tee-shirt vibe to it, and I immediately challenged myself to
attempt to reproduce it in CSS.&lt;/p&gt;
&lt;p&gt;Here is what a still from the trailer looks like:&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;A still from the movie I Care a Lot&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;2508&quot; width=&quot;2508&quot; height=&quot;804&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Fi-care-a-lot-trailer-snapshot.WA9_9V0b.png&amp;amp;w=1920&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;p&gt;And here is the result of my CSS reproduction (works best on a desktop layout):&lt;/p&gt;
&lt;p id=&quot;icarealot&quot;&gt;
I Care a Lot
&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://codepen.io/dirtyhenry/pen/zYoybEB&quot;&gt;Play with the code on codepen.io&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&quot;about-the-font&quot;&gt;About the Font&lt;/h2&gt;
&lt;p&gt;The font looks like Futura Condensed ExtraBold Italic. On macOS or iOS, since
the italic version is not installed by default, it renders as a &lt;a href=&quot;https://www.marksimonson.com/notebook/view/FakevsTrueItalics/&quot;&gt;&lt;em&gt;fake
italic&lt;/em&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;If your system does not include any version of Futura, the CSS effect might look
nothing like the still. Sorry about that.&lt;/p&gt;
&lt;h2 id=&quot;animating-the-colors-combination&quot;&gt;Animating the Colors Combination&lt;/h2&gt;
&lt;p&gt;The thing I liked was the matching between the colors of (a) the text and (b)
its stroke.&lt;/p&gt;
&lt;p&gt;At first, I was assuming it was opacity that was creating this nice combination
but it is more complicated than that. After translating &lt;strong&gt;RGB&lt;/strong&gt; (Red Green Blue)
values of the color into &lt;strong&gt;HSL&lt;/strong&gt; (Hue Saturation Lightness)&lt;sup&gt;&lt;a href=&quot;#user-content-fn-1&quot; id=&quot;user-content-fnref-1&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;, things became
clearer: the color of the text was &lt;code&gt;hsl(49, 64%, 18%)&lt;/code&gt; while the color of the
stroke was &lt;code&gt;hsl(59, 96%, 68%)&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;This change of color model makes animating the hue of this effect very easy:
adding a complete 360 degrees rotation hue filter on our component, while
keeping the &lt;code&gt;+10&lt;/code&gt; difference in hue and constant saturation and lightness
values, leads to a good-looking animation.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;css&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;@keyframes&lt;/span&gt;&lt;span style=&quot;color:#FFAB70&quot;&gt; hue-full-rotation&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;  0%&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;    filter&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;hue-rotate&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;deg&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;  100%&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;    filter&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;hue-rotate&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;360&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;deg&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here is the animated version:&lt;/p&gt;
&lt;p id=&quot;icarealot&quot; class=&quot;hue-animated&quot;&gt;
I Care a Lot
&lt;/p&gt;
&lt;section data-footnotes class=&quot;footnotes&quot;&gt;&lt;h2 class=&quot;sr-only&quot; id=&quot;footnote-label&quot;&gt;Footnotes&lt;/h2&gt;
&lt;ol&gt;
&lt;li id=&quot;user-content-fn-1&quot;&gt;
&lt;p&gt;In case you are not familiar with HSL, Paul Hebert put together this nice
&lt;a href=&quot;https://cloudfour.com/thinks/hsl-a-color-format-for-humans/&quot;&gt;post&lt;/a&gt;, including &lt;a href=&quot;https://cloudfour.com/thinks/hsl-a-color-format-for-humans/#putting-it-to-the-test&quot;&gt;this classic exercise&lt;/a&gt; comparing how easy it is to
find a random color both in RGB and HSL. &lt;a href=&quot;#user-content-fnref-1&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 1&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;
</content:encoded><category>CSS</category><category>Sass</category></item><item><title>A CSS Polaroid Effect With Flexbox</title><link>https://www.mickf.net/tech/css-polaroid-effect-with-fluid-grids/</link><guid isPermaLink="true">https://www.mickf.net/tech/css-polaroid-effect-with-fluid-grids/</guid><description>Revisiting how to show images as if they were polaroids, in CSS, with technologies from 2021.</description><pubDate>Sun, 07 Mar 2021 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Back in 2010, after reading &lt;a href=&quot;https://legacy-zurb.netlify.app/playground/css3-polaroids&quot;&gt;Zurb’s Polaroids with CSS3 blog post&lt;/a&gt;, I told
myself it could be a really cool effect to present Dead Rooster’s MP3
selections&lt;sup&gt;&lt;a href=&quot;#user-content-fn-1&quot; id=&quot;user-content-fnref-1&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; so I adapted the code and made it work with (at the time) very
hot’n’sexy &lt;em&gt;fluid grids&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Flash forward to 2021.&lt;/p&gt;
&lt;p&gt;I’m migrating Dead Rooster to modern tools. Let’s revisit this effect to
re-enable it.&lt;/p&gt;
&lt;h2 id=&quot;jekyll-is-a-decent-sassscss-authoring-tool&quot;&gt;Jekyll is a decent Sass/SCSS authoring tool&lt;/h2&gt;
&lt;p&gt;The original version of this post mentioned &lt;a href=&quot;https://github.com/Compass/compass/&quot;&gt;&lt;strong&gt;Compass&lt;/strong&gt;&lt;/a&gt; as a good Sass
authoring framework. It is no longer actively maintainted and nowadays, I rarely
author any CSS outside of a Jekyll project or CSS-in-JS tools such as
&lt;a href=&quot;https://styled-components.com/&quot;&gt;styled-components&lt;/a&gt; or &lt;a href=&quot;https://emotion.sh/docs/introduction&quot;&gt;Emotion&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;We will use &lt;a href=&quot;https://jekyllrb.com/docs/assets/#sassscss&quot;&gt;Jekyll’s Sass/SCSS support&lt;/a&gt; today.&lt;/p&gt;
&lt;h2 id=&quot;the-polaroid-effect&quot;&gt;The Polaroid Effect&lt;/h2&gt;
&lt;ul class=&quot;polaroids&quot;&gt;
  &lt;li class=&quot;polaroid&quot; title=&quot;Guards&quot;&gt;
    &lt;img src=&quot;https://picsum.photos/seed/Guards/200&quot; alt=&quot;A random squared photo to illustrate the Polaroid effect.&quot;/&gt;
  &lt;/li&gt;
  &lt;li class=&quot;polaroid&quot; title=&quot;Women&quot;&gt;
    &lt;img src=&quot;https://picsum.photos/seed/Women/200&quot; alt=&quot;A random squared photo to illustrate the Polaroid effect.&quot;/&gt;
  &lt;/li&gt;
  &lt;li class=&quot;polaroid&quot; title=&quot;The Raveonettes&quot;&gt;
    &lt;img src=&quot;https://picsum.photos/seed/The%20Raveonettes/200&quot; alt=&quot;A random squared photo to illustrate the Polaroid effect.&quot;/&gt;
  &lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;how-it-works&quot;&gt;How it works&lt;/h2&gt;
&lt;p&gt;I created 2 codepens to compare the code from 2010 to the code of 2021:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://codepen.io/dirtyhenry/pen/BaQPoRL&quot;&gt;Polaroid Effects 2010&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://codepen.io/dirtyhenry/pen/vYyaNWE&quot;&gt;Polaroid Effects 2021&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;what-changed-since-2010&quot;&gt;What changed since 2010?&lt;/h2&gt;
&lt;p&gt;The old code used a lot of fixed sizes and maths, with a variable for the number
of columns at compile time that became a constant at runtime. To mimic this
behavior, we could have used a &lt;a href=&quot;https://css-tricks.com/snippets/css/complete-guide-grid/&quot;&gt;&lt;strong&gt;CSS Grid Layout&lt;/strong&gt;&lt;/a&gt; since, on Dead Rooster,
each post using this effect featured a 3 ⨉ 3 grid of images. But on smaller
screens, the code made the images become too small so I decided &lt;a href=&quot;https://css-tricks.com/snippets/css/a-guide-to-flexbox/&quot;&gt;&lt;strong&gt;CSS Flexbox
Layout&lt;/strong&gt;&lt;/a&gt; led to better results in terms of responsiveness.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Vendor prefixes&lt;/strong&gt; are for the most part useless nowadays. I removed all their
occurrences from the original code and the code behaves as expected on Safari,
Chrome and Firefox on macOS, and on Safari Mobile on iOS.&lt;/p&gt;
&lt;p&gt;Finally, SCSS now has a fun &lt;code&gt;random&lt;/code&gt; native method that can bring more
unpredictability — which is the fun part of this effect — than the Fibonacci
suite multiples that were used in the original code. The random value is only
random at compile-time though, so we still need multiple classes using
&lt;code&gt;:nth-child&lt;/code&gt; to avoid all polaroids to all be tilted at the same angle.&lt;/p&gt;
&lt;p&gt;You can see the effect live on Dead Rooster &lt;a href=&quot;https://deadrooster.org/compile-mp3-du-net-01/&quot;&gt;here&lt;/a&gt;, &lt;a href=&quot;https://deadrooster.org/compile-mp3-du-net-05/&quot;&gt;here&lt;/a&gt; or &lt;a href=&quot;https://deadrooster.org/compile-mp3-du-net-08/&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Rock on. 🤘&lt;/p&gt;
&lt;section data-footnotes class=&quot;footnotes&quot;&gt;&lt;h2 class=&quot;sr-only&quot; id=&quot;footnote-label&quot;&gt;Footnotes&lt;/h2&gt;
&lt;ol&gt;
&lt;li id=&quot;user-content-fn-1&quot;&gt;
&lt;p&gt;&lt;a href=&quot;https://deadrooster.org&quot;&gt;Dead Rooster&lt;/a&gt; is my blog, written in French, where
I write about pop culture since 2005. &lt;a href=&quot;#user-content-fnref-1&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 1&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;
</content:encoded><category>CSS</category><category>Sass</category><category>Flexbox</category><category>Jekyll</category></item><item><title>Pixel-Perfect Line Height With UIKit</title><link>https://www.mickf.net/tech/line-height-with-uikit/</link><guid isPermaLink="true">https://www.mickf.net/tech/line-height-with-uikit/</guid><description>In this post, I will show you my attempts to render a card component exactly as it was designed, and why it might be worth negotiating an approximation with a smaller footprint.</description><pubDate>Thu, 04 Feb 2021 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;According to Matthew Butterick, the author of the excellent &lt;a href=&quot;https://practicaltypography.com/&quot;&gt;&lt;em&gt;Practical
Typography&lt;/em&gt;&lt;/a&gt;, the &lt;a href=&quot;https://practicaltypography.com/summary-of-key-rules.html&quot;&gt;number one key rule&lt;/a&gt; of good typography is:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The four most important typographic considerations for body text are &lt;em&gt;point
size&lt;/em&gt;, &lt;em&gt;line spacing&lt;/em&gt;, &lt;em&gt;line length&lt;/em&gt;, and &lt;em&gt;font&lt;/em&gt;, because those choices
determine how the body text looks.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;While point sizes, line lengths and fonts are easy to control with UIKit, line
spacing is a little trickier.&lt;/p&gt;
&lt;p&gt;In this article, I will first describe in detail a clever helper to meet
challenging line spacing requirements with pixel-perfect precision. Your design
team will love you.&lt;/p&gt;
&lt;p&gt;I will then explain why I actually wouldn’t recommend implementing the solution
for every context, and instead provide a much sturdier &lt;em&gt;pixel-pretty-close&lt;/em&gt;&lt;sup&gt;&lt;a href=&quot;#user-content-fn-5&quot; id=&quot;user-content-fnref-5&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;
alternative. Your design team will still love you. I promise.&lt;/p&gt;
&lt;p&gt;Let’s dive in.&lt;/p&gt;
&lt;h2 id=&quot;the-designer-input&quot;&gt;The Designer Input&lt;/h2&gt;
&lt;p&gt;Say our design team gives us the following specs for a &lt;strong&gt;card&lt;/strong&gt; view component:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A &lt;strong&gt;title&lt;/strong&gt; with a point size of 28pt and a line height of 38pt&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;body&lt;/strong&gt; with a point size of 17pt and a line height of 24pt&lt;/li&gt;
&lt;li&gt;Both the title and body are 8pt apart on the Y-axis, and 8pt away from the
edges of the card on the X-axis.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The export from Sketch looks like this&lt;sup&gt;&lt;a href=&quot;#user-content-fn-1&quot; id=&quot;user-content-fnref-1&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;:&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;The card as designed by the design team.&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;375&quot; width=&quot;375&quot; height=&quot;182&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Fcard-as-designed.2rb5-5vE.png&amp;amp;w=400&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;p&gt;And here is a version with colored backgrounds for labels, to better understand
the layout and where line heights should be considered:&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;The card as designed by the design team, with boxes for better understanding of the structure.&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;375&quot; width=&quot;375&quot; height=&quot;182&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Fcard-as-designed-with-boxes.BJhqYNF3.png&amp;amp;w=400&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;p&gt;Next, we will iterate to reach a pixel-perfect translation of this design into
UIKit code.&lt;/p&gt;
&lt;h2 id=&quot;step-1-laying-out-the-labels&quot;&gt;Step 1: Laying out the labels&lt;/h2&gt;
&lt;p&gt;Let’s head over to a playground, create our 2 labels and position them with auto
layout with the following constraints:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;NSLayoutConstraint.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;activate&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;([&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;    // X-avis: 8pt padding between card and title:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    titleLabel.leadingAnchor.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;constraint&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;equalToSystemSpacingAfter&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: view.safeAreaLayoutGuide.leadingAnchor, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;multiplier&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;1.0&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    titleLabel.centerXAnchor.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;constraint&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;equalTo&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: view.safeAreaLayoutGuide.centerXAnchor),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;    // Y-axis: 8pt padding between card and title: ⚠️&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    titleLabel.topAnchor.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;constraint&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;equalToSystemSpacingBelow&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: view.safeAreaLayoutGuide.topAnchor, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;multiplier&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;1.0&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;    // Y-axis: 8pt padding between title and label:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    bodyLabel.firstBaselineAnchor.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;constraint&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;equalToSystemSpacingBelow&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: titleLabel.lastBaselineAnchor, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;multiplier&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;1.0&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    bodyLabel.leadingAnchor.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;constraint&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;equalTo&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: titleLabel.leadingAnchor),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    bodyLabel.trailingAnchor.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;constraint&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;equalTo&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: titleLabel.trailingAnchor)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;])&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you noticed this little warning in the comment ⚠️, bear with me: we will
address it further down.&lt;/p&gt;
&lt;p&gt;We haven’t written any code related to the line height just yet, but for the
sake of getting an idea of where we are at this point, here is a &lt;em&gt;ghost
snapshot&lt;/em&gt; of what our view looks like if we place the Sketch design, with a low
opacity, below our labels:&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;Pixel-wise comparison of the Sketch design and iOS view after Step 1.&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;375&quot; width=&quot;375&quot; height=&quot;182&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Fcard-step-1.D-zxr8Z9.png&amp;amp;w=400&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;h2 id=&quot;step-2-adding-some-paragraph-style&quot;&gt;Step 2: Adding some paragraph style&lt;/h2&gt;
&lt;p&gt;Now, let’s address the line spacing.&lt;/p&gt;
&lt;p&gt;The most standard approach to add line spacing is to use &lt;a href=&quot;https://developer.apple.com/documentation/uikit/uilabel/1620542-attributedtext&quot;&gt;&lt;code&gt;UILabel&lt;/code&gt;’s
&lt;code&gt;attributedText&lt;/code&gt;&lt;/a&gt; instead of the simpler &lt;code&gt;text&lt;/code&gt; attribute:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; attributedString &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; NSMutableAttributedString&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: bodyText)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;// See the reason behind this substraction below&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; lineSpacing &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; 24.0&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; res.font.lineHeight&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; paragraphStyle &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; NSMutableParagraphStyle&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;paragraphStyle.lineSpacing &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; lineSpacing&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;attributedString.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;addAttribute&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    .paragraphStyle,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;    value&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: paragraphStyle,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;    range&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;NSRange&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;location&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;length&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: attributedString.length)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;res.attributedText &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; attributedString&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here we create an attributed string with a paragraph style attribute. It can
control the &lt;em&gt;line spacing&lt;/em&gt;, ie the numbers of points between two lines of text
that should be added, or subtracted, to the default layout using the font
metrics&lt;sup&gt;&lt;a href=&quot;#user-content-fn-2&quot; id=&quot;user-content-fnref-2&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;
&lt;p&gt;The line spacing is the difference between the line height &lt;em&gt;of the design&lt;/em&gt; and
the line height &lt;em&gt;of the font being used&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;With line spacing added to both the title and the body labels, our &lt;em&gt;ghost
snapshot&lt;/em&gt; now looks like this.&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;Pixel-wise comparison of the Sketch design and iOS view after Step 2.&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;375&quot; width=&quot;375&quot; height=&quot;182&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Fcard-step-2.D0UuKh4b.png&amp;amp;w=400&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;p&gt;A little better but not quite great yet. While the body text line spacing
appears to be in line with the requirements from the design team — in the sense
that it looks just a little translated upwards — the card is still far from a
pixel-perfect result. What is going on?&lt;/p&gt;
&lt;p&gt;The paragraph style’s line spacing contributes to the &lt;strong&gt;inner&lt;/strong&gt; part of the line
height on a given paragraph — so, effectively, on strings spanning on more than
1 line which, in our example, is the body only. However, the labels don’t apply
the necessary extra &lt;strong&gt;outer&lt;/strong&gt; part of the line height.&lt;/p&gt;
&lt;h2 id=&quot;step-3-applying-outer-padding&quot;&gt;Step 3: Applying outer-padding&lt;/h2&gt;
&lt;p&gt;To meet our pixel-perfect superposition objective, we need to apply some extra
Y-axis &lt;strong&gt;padding&lt;/strong&gt;&lt;sup&gt;&lt;a href=&quot;#user-content-fn-3&quot; id=&quot;user-content-fnref-3&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;4&lt;/a&gt;&lt;/sup&gt; to our labels. Unfortunately, if we want to stay in the
peaceful UIKit realm and not cross the border to scary &lt;a href=&quot;https://developer.apple.com/documentation/coretext&quot;&gt;Core Text&lt;/a&gt; territory,
we need to wrap our labels with a view that will be in charge of this extra
padding.&lt;/p&gt;
&lt;p&gt;I’ll spare you the steps and repetition of code to fast forward to a convenient
&lt;code&gt;UIView&lt;/code&gt; helper subclass that will do the job:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;/// Let&apos;s keep font metrics and line height metrics together.s&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;struct&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; TextStyle&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; font: UIFont&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; lineHeight: CGFloat&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; LineHeightedLabel&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;UIView &lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    init&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;text&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;?&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;textStyle&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: TextStyle) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;        self&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.wrappedLabel &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; UILabel&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;        self&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.textStyle &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; textStyle&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;        super&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;init&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;frame&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: .zero)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        translatesAutoresizingMaskIntoConstraints &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; false&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;        setupViewAndConstraints&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;        setText&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;text&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: text)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    @available&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;unavailable&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    required&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; init?&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;coder&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; _: NSCoder) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;        fatalError&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;init(coder:) has not been implemented&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;    // MARK: - Inspecting the view&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; wrappedLabel: UILabel&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; textStyle: TextStyle&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    var&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; text: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;?&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        get&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;            return&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; wrappedLabel.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;text&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        set&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;            setText&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;text&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: newValue)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    private&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; var&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; topYAxisConstraint: NSLayoutConstraint&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;?&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    private&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; func&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; setupViewAndConstraints&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;() {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        wrappedLabel.translatesAutoresizingMaskIntoConstraints &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; false&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        wrappedLabel.font &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; textStyle.font&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;        addSubview&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(wrappedLabel)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;        // We apply the line height contribution to this constraint.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;        // Since its constant might evolve over time, let&apos;s keep a reference.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; safeTopYAxisConstraint &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; topAnchor.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;constraint&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;equalTo&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: wrappedLabel.topAnchor)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        topYAxisConstraint &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; safeTopYAxisConstraint&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        NSLayoutConstraint.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;activate&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;([&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;            safeTopYAxisConstraint,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;            leadingAnchor.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;constraint&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;equalTo&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: wrappedLabel.leadingAnchor),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;            trailingAnchor.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;constraint&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;equalTo&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: wrappedLabel.trailingAnchor),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;            centerYAnchor.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;constraint&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;equalTo&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: wrappedLabel.centerYAnchor)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        ])&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    func&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; setText&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;text&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;?&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        guard&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; text &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; text &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;else&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;            // No text? Then no padding either.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;            topYAxisConstraint&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;?&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.constant &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; 0.0&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;            wrappedLabel.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;text&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; nil&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;            return&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;        // This is the extra padding we want.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;        // Half of it will go on top of the label.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;        // The other half will go at the bottom of the label.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; lineSpacing &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; textStyle.lineHeight &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; textStyle.font.lineHeight&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; paragraphStyle &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; NSMutableParagraphStyle&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        paragraphStyle.lineSpacing &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; lineSpacing&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        paragraphStyle.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;alignment&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; wrappedLabel.textAlignment&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;        // Build an attributed string&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; attributedString &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; NSMutableAttributedString&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: text)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        attributedString.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;addAttribute&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;            .paragraphStyle,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;            value&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: paragraphStyle,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;            range&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;NSRange&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;location&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;length&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: attributedString.length)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        )&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        topYAxisConstraint&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;?&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.constant &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(lineSpacing &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; 2.0&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        wrappedLabel.attributedText &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; attributedString&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Where are we now? Let’s look at our &lt;em&gt;ghost snapshot&lt;/em&gt;:&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;Pixel-wise comparison of the Sketch design and iOS view after Step 3.&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;375&quot; width=&quot;375&quot; height=&quot;182&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Fcard-step-3.DRSlfFIJ.png&amp;amp;w=400&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;p&gt;Even though the mysteries of text-layout algorithms led Sketch and Xcode to make
different decisions about when to break lines, it seems like our code does a
good job respecting the designed layout so, tada 🎉, we’re done! All that’s left
to do is to copy paste this little helper everywhere.&lt;/p&gt;
&lt;p&gt;Well… sure, but be careful. While this wrapper does a good job in the context of
this exercise and its API&lt;sup&gt;&lt;a href=&quot;#user-content-fn-4&quot; id=&quot;user-content-fnref-4&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;5&lt;/a&gt;&lt;/sup&gt; is considerably stable, I actually wouldn’t take
this approach. Let’s see why.&lt;/p&gt;
&lt;h2 id=&quot;a-sturdier-alternative-using-font-descriptors-and-text-constraints&quot;&gt;A sturdier alternative using font descriptors and text constraints&lt;/h2&gt;
&lt;p&gt;The major drawbacks about this little helper are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;While it’s not super fragile, it is still not a great API since it only
handles two attributes (line spacing and text alignment);&lt;/li&gt;
&lt;li&gt;It adds an extra wrapping view for every label in our design. While this might
not be really expensive to lay out, it is not very intellectually satisfying;&lt;/li&gt;
&lt;li&gt;It requires to bend Apple’s own rules to do your thing. If more than 12 years
of iOS development has taught me one thing, it is that following Apple’s
guidelines will end up being a great return on investment either whenever
Apple launches its next big thing or when you discover your app had a blind
spot (accessibility being the usual suspect).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So what rule are we bending? Remember the little ⚠️ from above? Well if you
replace this constraint:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;// The origin of the titleLabel frame will be 8pt below the view&apos;s.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;titleLabel.topAnchor.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;constraint&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;  equalToSystemSpacingBelow&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: view.safeAreaLayoutGuide.topAnchor,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;  multiplier&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;1.0&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;by this one — which is likely what Apple wants you to do when you are handling
labels constraints:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;// The origin of the titleLabel frame will be 11pt below the view&apos;s.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;titleLabel.firstBaselineAnchor.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;constraint&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;  equalToSystemSpacingBelow&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: view.safeAreaLayoutGuide.topAnchor,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;  multiplier&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;1.0&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You end up with a slightly different result: the title label will be laid out
3pt further down if you use the text-specific constraint. Since the system knows
that &lt;code&gt;titleLabel&lt;/code&gt; is a &lt;code&gt;title1&lt;/code&gt; it will add additional padding that will look
quite better, without any design cost.&lt;/p&gt;
&lt;p&gt;Apple is very thoughtful about system font sizes and line heights, as
demonstrated in the &lt;a href=&quot;https://developer.apple.com/design/human-interface-guidelines/ios/visual-design/typography/&quot;&gt;Typography section of their Human Interfaces
Guidelines&lt;/a&gt;. If the designer in your team still wants to make adjustments on
point sizes and line spacings, a sturdier alternative to using &lt;code&gt;lineSpacing&lt;/code&gt;
might be to leverage font descriptors to slightly alter the font metrics so that
they better match your designs. You could use either &lt;a href=&quot;https://developer.apple.com/documentation/uikit/uifontdescriptor/symbolictraits/1616689-traitlooseleading&quot;&gt;&lt;code&gt;traitLooseLeading&lt;/code&gt;&lt;/a&gt; or
&lt;a href=&quot;https://developer.apple.com/documentation/uikit/uifontdescriptor/symbolictraits/1616694-traittightleading&quot;&gt;&lt;code&gt;traitTightLeading&lt;/code&gt;&lt;/a&gt; to slightly modify the line spacing of fonts.&lt;/p&gt;
&lt;p&gt;For our specific line height situation, we want &lt;code&gt;traitLooseLeading&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; font: UIFont &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; .&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;init&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;    descriptor&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: UIFontDescriptor&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        .&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;preferredFontDescriptor&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;withTextStyle&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: .body)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        .&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;withSymbolicTraits&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(.traitLooseLeading)&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;!&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;    size&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;0&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here is another ghost snapshot that doesn’t require to wrap &lt;code&gt;UILabel&lt;/code&gt; or use
attributed strings. Instead, it uses just the adequate constraints, a font with
a looser leading, and a simple tweak to use a multiplier of &lt;code&gt;1.4&lt;/code&gt; for the space
constraint between the title and the body.&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;Pixel-wise comparison of the Sketch design and a sturdier iOS view.&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;375&quot; width=&quot;375&quot; height=&quot;182&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Fcard-sturdier-option.D76oeD98.png&amp;amp;w=400&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;p&gt;While this solution will give you less control to get a perfect ghost snapshot
(see how the card’s total height is not as high as the Sketch design?), I think
it is the best option for most cases, that should be negotiated with your design
team.&lt;/p&gt;
&lt;p&gt;Check out &lt;a href=&quot;https://github.com/dirtyhenry/xcode-playgrounds/tree/main/line-height.playground&quot;&gt;⛹️ the playground&lt;/a&gt; to run the code in Xcode.&lt;/p&gt;
&lt;h2 id=&quot;related-links&quot;&gt;Related Links&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://medium.com/mobimeo-technology/what-if-your-designers-want-a-baseline-grid-on-ios-d5234c7b52c0&quot;&gt;What If Your Designers Want a Baseline Grid on iOS?&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;section data-footnotes class=&quot;footnotes&quot;&gt;&lt;h2 class=&quot;sr-only&quot; id=&quot;footnote-label&quot;&gt;Footnotes&lt;/h2&gt;
&lt;ol&gt;
&lt;li id=&quot;user-content-fn-5&quot;&gt;
&lt;p&gt;Credits for this awesome adjective go to &lt;a href=&quot;https://www.joshwcomeau.com/css/pixel-perfection/&quot;&gt;Josh W. Comeau&lt;/a&gt; &lt;a href=&quot;#user-content-fnref-5&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 1&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-1&quot;&gt;
&lt;p&gt;I know it looks like 💩 that is not the point 😉. &lt;a href=&quot;#user-content-fnref-1&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 2&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-2&quot;&gt;
&lt;p&gt;Every font has a lot of metrics. Apple’s &lt;a href=&quot;https://developer.apple.com/library/archive/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/CustomTextProcessing/CustomTextProcessing.html#//apple_ref/doc/uid/TP40009542-CH4-SW66&quot;&gt;&lt;em&gt;Using Text Kit to Draw and Manage
Text&lt;/em&gt; document&lt;/a&gt; is very helpful to learn about them, especially the &lt;em&gt;Font
Metrics&lt;/em&gt; figure that is a good recap of the most important ones. &lt;a href=&quot;#user-content-fnref-2&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 3&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-3&quot;&gt;
&lt;p&gt;Since we’re exploring multi-platform design — that, let’s face it, is
heavily influenced by the web lingo —, we might as well just start using it
here. &lt;a href=&quot;#user-content-fnref-3&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 4&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-4&quot;&gt;
&lt;p&gt;Updating the text, for instance, will not break the layout, even if you set
the text directly on the wrapped label. &lt;a href=&quot;#user-content-fnref-4&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 5&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;
</content:encoded><category>iOS</category><category>UIKit</category><category>Typography</category></item><item><title>My Definitive Front Matter</title><link>https://www.mickf.net/tech/my-definitive-front-matter/</link><guid isPermaLink="true">https://www.mickf.net/tech/my-definitive-front-matter/</guid><description>After years of making static sites with Jekyll, here is my template for a solid front matter for your next static site project.</description><pubDate>Sun, 17 Jan 2021 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;With every static site generator, you can write your posts or pages with
Markdown or CommonMark files in which you can include some structured metadata
called a &lt;em&gt;Front Matter&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Jekyll&lt;/em&gt; has &lt;a href=&quot;https://jekyllrb.com/docs/front-matter/&quot;&gt;it&lt;/a&gt;. &lt;em&gt;Hugo&lt;/em&gt; has &lt;a href=&quot;https://gohugo.io/content-management/front-matter/&quot;&gt;it&lt;/a&gt;. &lt;em&gt;Gatsby&lt;/em&gt; has &lt;a href=&quot;https://www.gatsbyjs.com/docs/how-to/routing/adding-markdown-pages/#frontmatter-for-metadata-in-markdown-files&quot;&gt;it&lt;/a&gt;. &lt;em&gt;Publish&lt;/em&gt; takes
distance from the naming&lt;sup&gt;&lt;a href=&quot;#user-content-fn-1&quot; id=&quot;user-content-fnref-1&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; but definitely has &lt;a href=&quot;https://github.com/JohnSundell/Publish/blob/master/Documentation/HowTo/custom-markdown-metadata-values.md&quot;&gt;it&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;When you start building a website with any of these products — I’m most familiar
with Jekyll by far —, the default scaffolding will prepare sample posts using
front matter keys that it considers as required. From this basic starting point,
users will have the liberty to add any additional keys of their liking. Over
time, after running many Jekyll projects, I came to rely mostly on the following
set:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;yaml&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#85E89D&quot;&gt;layout&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;post&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#85E89D&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;61C15587-6353-4F0B-B7EA-5FB936E1B7B2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#85E89D&quot;&gt;title&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;Hey Jude&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#85E89D&quot;&gt;author&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;Paul McCartney&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#85E89D&quot;&gt;excerpt&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;&amp;gt;-&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;  *Hey Jude* is a song by the English rock band the Beatles that was released as&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;  a non-album single in August 1968.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#85E89D&quot;&gt;image&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;hey-jude-single.jpg&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#85E89D&quot;&gt;category&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;Past Masters&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#85E89D&quot;&gt;tags&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;  - &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;1968&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;  - &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;Julian Lennon&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;  - &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;Na na na nananana&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#85E89D&quot;&gt;revisions&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;  &quot;2021-01-18&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;Fixed typos&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#85E89D&quot;&gt;alert&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#85E89D&quot;&gt;  level&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;info&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#85E89D&quot;&gt;  content&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;This is one of the greatest songs ever.&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I’ll detail each field now, having Jekyll in mind, but I’m pretty sure this can
be applied to any static generator.&lt;/p&gt;
&lt;h2 id=&quot;layout&quot;&gt;Layout&lt;/h2&gt;
&lt;p&gt;This is pretty basic. With Jekyll, you can include a default layout in the site
configuration but I like to keep it explicit.&lt;/p&gt;
&lt;h2 id=&quot;id&quot;&gt;ID&lt;/h2&gt;
&lt;p&gt;This is optional, but if you intend to change URL over time, it can be useful to
keep consistent feed since an ID is required by both Atom feeds and JSON feeds.&lt;/p&gt;
&lt;h2 id=&quot;title&quot;&gt;Title&lt;/h2&gt;
&lt;p&gt;Titles are important since you don’t want to rely on filenames to get your
posts’ names from. Some useful links to get capitalization right:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;in English, I like &lt;a href=&quot;https://thecapitalizer.com/&quot;&gt;The Capitalizer&lt;/a&gt;;&lt;/li&gt;
&lt;li&gt;in French, I couldn’t find a good tool but &lt;a href=&quot;https://www.axl.cefan.ulaval.ca/monde/regles-2TITRES.htm&quot;&gt;this page&lt;/a&gt; from an academic in
Quebec has a good overview of the rules to respect.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;author&quot;&gt;Author&lt;/h2&gt;
&lt;p&gt;This is optional since it will be relevant only if the website has more than 1
contributor. Also, most plugins allow it to be changed to &lt;code&gt;authors&lt;/code&gt; in case an
article is written by more than 1 person. In case you want to attach rich data
for each author, the &lt;a href=&quot;https://github.com/jekyll/jekyll-feed#author-information&quot;&gt;&lt;em&gt;Author information&lt;/em&gt;&lt;/a&gt; section from jekyll-feed’s
&lt;code&gt;README&lt;/code&gt; has good tips.&lt;/p&gt;
&lt;h2 id=&quot;excerpt&quot;&gt;Excerpt&lt;/h2&gt;
&lt;p&gt;This is optional. By default the first paragraph of the post will be used. But
it’s good to keep control over what will probably appear on the home page’s
reference to your post or social networks. I like &lt;em&gt;excerpt&lt;/em&gt; better than
&lt;em&gt;description&lt;/em&gt; because it is more specific and explicit.&lt;/p&gt;
&lt;h2 id=&quot;image&quot;&gt;Image&lt;/h2&gt;
&lt;p&gt;This is the cover of your post or page. I was using &lt;em&gt;cover&lt;/em&gt; for a while before
realizing &lt;em&gt;jekyll-feed&lt;/em&gt; was using &lt;em&gt;image&lt;/em&gt; by default so I converted.&lt;/p&gt;
&lt;h2 id=&quot;categories-and-tags&quot;&gt;Categories and Tags&lt;/h2&gt;
&lt;p&gt;As for the author, most plugins and themes will support singular or plural forms
of these tags.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;What is the difference between the two?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I would say that &lt;em&gt;categories&lt;/em&gt; are the paths of the navigation tree for your
website (just like folders and subfolders where you would store your files).
That’s what would be used to build a &lt;a href=&quot;https://bulma.io/documentation/components/breadcrumb/&quot;&gt;breadcrumb&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Tags&lt;/em&gt; on the other hand can be whatever and don’t involve any kind of structure
for your data.&lt;/p&gt;
&lt;p&gt;To put it another way, categories form a relatively rigid tree, while tags form
a free-form cloud.&lt;/p&gt;
&lt;h2 id=&quot;revisions&quot;&gt;Revisions&lt;/h2&gt;
&lt;p&gt;This section was &lt;del&gt;stolen&lt;/del&gt; inspired by the front matter of NSHipster’s articles
(see the &lt;a href=&quot;https://github.com/NSHipster/articles/blob/master/2014-07-21-xctestcase.md&quot;&gt;source&lt;/a&gt; for their &lt;code&gt;XCTestCase&lt;/code&gt; post for instance). When you intend
to keep your content relevant over time, it is very useful to let your users
know you updated your content so the revisions feature, albeit specific, can
become super useful.&lt;/p&gt;
&lt;h2 id=&quot;alerts&quot;&gt;Alerts&lt;/h2&gt;
&lt;p&gt;If you want to feature informative banners, in case you deprecate content, or
want to include an update to a post, an alert front matter is probably a better
way to go than modifying your content to include extra content (that would
probably be HTML to include an alert styling anyway, which you should avoid as
much as possible).&lt;/p&gt;
&lt;h2 id=&quot;no-date-no-slug&quot;&gt;No date? No slug?&lt;/h2&gt;
&lt;p&gt;Unless you intend to post multiple times a day, I would say the date belongs to
the filename only, and I don’t see the point of including the date with an
additional time in the front matter since it seems to just add clutter to it.&lt;/p&gt;
&lt;p&gt;On a similar note, I like that the slug for the URL is also part of the
filename. I don’t see any inconvenience doing so since Git does a pretty good
job at identifying renamings now, and the &lt;code&gt;id&lt;/code&gt; can help you tracking URL that
changed over time so that they don’t get duplicated in feeds.&lt;/p&gt;
&lt;p&gt;Any thoughts? &lt;a href=&quot;https://github.com/dirtyhenry/tech-articles/issues&quot;&gt;Let me know.&lt;/a&gt;&lt;/p&gt;
&lt;section data-footnotes class=&quot;footnotes&quot;&gt;&lt;h2 class=&quot;sr-only&quot; id=&quot;footnote-label&quot;&gt;Footnotes&lt;/h2&gt;
&lt;ol&gt;
&lt;li id=&quot;user-content-fn-1&quot;&gt;
&lt;p&gt;It seems to come from the &lt;a href=&quot;https://en.wikipedia.org/wiki/Book_design#Front_matter&quot;&gt;printed book design&lt;/a&gt; industry. &lt;a href=&quot;#user-content-fnref-1&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 1&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;
</content:encoded><category>Web Publishing</category><category>Static site generator</category><category>Markdown</category><category>YAML</category></item><item><title>How to Use OpenType Features with a Custom Font in UIKit</title><link>https://www.mickf.net/tech/activating-open-type-features-ios/</link><guid isPermaLink="true">https://www.mickf.net/tech/activating-open-type-features-ios/</guid><description>On the web, OpenType features are one line of CSS. On iOS, a custom font needs the right feature type and selector IDs. How I enabled Inter&apos;s open digits.</description><pubDate>Sun, 03 Jan 2021 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;a href=&quot;https://rsms.me/inter/&quot;&gt;Inter&lt;/a&gt; is an awesome typeface. It is free, open-source, and on top of
looking great by default, it provides &lt;a href=&quot;https://rsms.me/inter/#features&quot;&gt;many OpenType features&lt;/a&gt; that are
really easy to use on a website. The &lt;a href=&quot;https://rsms.me/inter/#features/ss01&quot;&gt;alternate digits feature&lt;/a&gt; is one of
them. Just add the following to a CSS style and you’re done.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;css&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;font-feature-settings: &quot;ss01&quot;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;How can we benefit from the same optional features with UIKit?&lt;/strong&gt; This post
will recap my journey to activate the alternate digits feature on an iOS app.&lt;/p&gt;
&lt;h2 id=&quot;adding-a-custom-font-and-using-it&quot;&gt;Adding a custom font and using it&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://developer.apple.com/documentation/uikit/text_display_and_fonts/adding_a_custom_font_to_your_app/&quot;&gt;Adding a custom font to your app&lt;/a&gt; is now pretty easy, compared to the old
days. From there, the most obvious next step is to run &lt;a href=&quot;https://github.com/dirtyhenry/swift-blocks/blob/main/Sources/Blocks/Extensions/Font.swift&quot;&gt;a piece of code&lt;/a&gt;
that I include in every project that use custom fonts. It simply prints a list
of the font names that are available from your app.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; extension&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; UIFont&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    static&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; func&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; allFontNames&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;() &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;] {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        familyNames.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;sorted&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;            .&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;map&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; { UIFont.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;fontNames&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;forFamilyName&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;$0&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;).&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;sorted&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;() }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;            .&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;flatMap&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; { &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;$0&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;listing-features-of-a-font&quot;&gt;Listing features of a font&lt;/h2&gt;
&lt;p&gt;Activating features with UIKit is described in the &lt;a href=&quot;https://developer.apple.com/library/archive/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/CustomTextProcessing/CustomTextProcessing.html#//apple_ref/doc/uid/TP40009542-CH4-SW6&quot;&gt;&lt;em&gt;Activating Font Features&lt;/em&gt;
section of the Text Programming Guide for iOS&lt;/a&gt;. The code that is presented
there relies on Objective-C Core Text that you can wrap in modern Swift.&lt;/p&gt;
&lt;p&gt;To list the features that are supported by a font, you can use the following
code:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;extension&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; UIFont&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    typealias&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; FontFeatureInfo&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;Any&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    func&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; listFeatures&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;() {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        guard&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; fontFeatures &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; CTFontCopyFeatures&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;as?&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; [FontFeatureInfo] &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;else&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;            debugPrint&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;Could not copy font features.&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;            return&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        fontFeatures.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;forEach&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; { fontFeatureInfo &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;in&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;            print&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(fontFeatureInfo)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It is hard to predict how large the output of this command will be and really
depends on the font. For the Inter font, &lt;a href=&quot;https://gist.github.com/dirtyhenry/875ebeac13882c5dad710f22f17be5c5&quot;&gt;the output looks pretty intense&lt;/a&gt;.
It is not the most pleasant prose to read for humans, but scanning for the
features we want will be pretty straightforward.&lt;/p&gt;
&lt;p&gt;In my context, the part I was interested in was the following:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;[&quot;CTFeatureTypeName&quot;: Alternative Stylistic Sets, &quot;CTFeatureTypeIdentifier&quot;: 35, &quot;CTFeatureTypeSelectors&quot;: &amp;lt;__NSArrayM 0x600002179f20&amp;gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    CTFeatureSelectorIdentifier = 2;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    CTFeatureSelectorName = &quot;Open digits&quot;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;},&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To activate the &lt;em&gt;Open digits&lt;/em&gt; feature, I had to use the &lt;strong&gt;feature type
identifier 35&lt;/strong&gt;, with the &lt;strong&gt;feature selector identifier 2&lt;/strong&gt;.&lt;/p&gt;
&lt;h2 id=&quot;enabling-the-font-features-you-want&quot;&gt;Enabling the font features you want&lt;/h2&gt;
&lt;p&gt;So far, the code I showed was to get your app in the starting blocks. It helps
you to prepare for the big stage moment: &lt;strong&gt;actually&lt;/strong&gt; enabling the font
features.&lt;/p&gt;
&lt;p&gt;So I wrapped these 35 and 2 &lt;em&gt;magic numbers&lt;/em&gt; into something more meaningful: a
simple struct trying to make sense of Apple’s documentation&lt;sup&gt;&lt;a href=&quot;#user-content-fn-1&quot; id=&quot;user-content-fnref-1&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;. It is pretty
basic, aimed to be built on in the future, and I made use of this incredible
&lt;a href=&quot;https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html&quot;&gt;Font Feature Registry&lt;/a&gt; resource&lt;sup&gt;&lt;a href=&quot;#user-content-fn-2&quot; id=&quot;user-content-fnref-2&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;2&lt;/a&gt;&lt;/sup&gt; to find inspiration for an adequate
naming:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; enum&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; FeatureTypeSelectorPair&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    typealias&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; PairDescriptor&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;Int&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;Int&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    static&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; stylisticAlternativesStylisticAltOne: PairDescriptor &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;35&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    static&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; func&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; attributeValue&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; pairDescriptor: PairDescriptor) &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; Any&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        [&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;            UIFontDescriptor.FeatureKey.featureIdentifier&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; pairDescriptor.0,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;            UIFontDescriptor.FeatureKey.typeIdentifier&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; pairDescriptor.1,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        ]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Once there, I was able to instanciate the &lt;code&gt;UIFont&lt;/code&gt; including the option I wanted
like so:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;func&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; createFontWithOptions&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;fontName&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;size&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: CGFloat) &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; UIFont {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; resultFont &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; UIFontDescriptor&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: fontName, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;size&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: size)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        .&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;addingAttributes&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;([&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;            .featureSettings&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; [&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;                FeatureTypeSelectorPair.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;attributeValue&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;                    for&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: FeatureTypeSelectorPair.stylisticAlternativesStylisticAltOne&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;                ),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;            ],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        ])&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;    // 0.0 means the size from the descriptor will prevail.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    return&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; UIFont&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;descriptor&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: resultFont, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;size&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;0.0&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;the-outcome-an-alternative-digits-style&quot;&gt;The outcome: an alternative digits style&lt;/h2&gt;
&lt;p&gt;🎉 Tada! I was done. Here is what it looks like in the end: a label with the
default Inter Bold font appears first, and the label with the Inter Bold with
the alternate digits feature enabled appears last.&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;A screenshot comparing the string ‘0123456789’ with or without the option&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;471&quot; width=&quot;471&quot; height=&quot;205&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Finter-font-with-or-without-options.ZRVP-q9l.png&amp;amp;w=512&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;p&gt;Check out &lt;a href=&quot;https://github.com/dirtyhenry/xcode-playgrounds/tree/master/activating-opentype-features.playground&quot;&gt;⛹️ the playground&lt;/a&gt; to run the code in Xcode.&lt;/p&gt;
&lt;section data-footnotes class=&quot;footnotes&quot;&gt;&lt;h2 class=&quot;sr-only&quot; id=&quot;footnote-label&quot;&gt;Footnotes&lt;/h2&gt;
&lt;ol&gt;
&lt;li id=&quot;user-content-fn-1&quot;&gt;
&lt;p&gt;⚠️ Note:
&lt;a href=&quot;https://developer.apple.com/documentation/uikit/uifontdescriptor/featurekey&quot;&gt;the documentation of &lt;code&gt;UIFontDescriptor.FeatureKey&lt;/code&gt;&lt;/a&gt;
was one of the most confusing I met. It said (1) that &lt;code&gt;featureIdentifier&lt;/code&gt;
was a key for identifying a font feature type such as ligature or character
shape and (2) &lt;code&gt;typeIdentifier&lt;/code&gt; was a key for identifying the font feature
selector. So &lt;code&gt;featureIdentifier&lt;/code&gt; refers to &lt;code&gt;CTFeatureTypeIdentifier&lt;/code&gt; while
&lt;code&gt;typeIdentifier&lt;/code&gt; refers to &lt;code&gt;CTFeatureSelectorIdentifier&lt;/code&gt;. Of course, I had
it switched the wrong way the first time I ran the code. Confusing you said?
🤯 &lt;a href=&quot;#user-content-fnref-1&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 1&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-2&quot;&gt;
&lt;p&gt;I never considered myself an expert in typefaces or fonts design and
abilities but this resource was so humbling that I definitely decreased the
perception of my own level in that skill by quite some orders of magnitude
😂 &lt;a href=&quot;#user-content-fnref-2&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 2&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;
</content:encoded><category>iOS</category><category>Swift</category><category>UIKit</category><category>Typography</category></item><item><title>Pomodoro CLI 1.0.0 Released 🎉</title><link>https://www.mickf.net/tech/pomodoro-cli-swift/</link><guid isPermaLink="true">https://www.mickf.net/tech/pomodoro-cli-swift/</guid><pubDate>Sat, 01 Feb 2020 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;A little more than two years after &lt;a href=&quot;https://www.mickf.net/tech/swift-command-line-pomodoro/&quot;&gt;I started working on this&lt;/a&gt;, I am happy to
annouce that &lt;a href=&quot;https://github.com/dirtyhenry/pomodoro-cli/releases&quot;&gt;&lt;code&gt;pomodoro-cli&lt;/code&gt; 1.0.0&lt;/a&gt; has been released today. I finally felt
that it had enough features to decide a tag was needed.&lt;/p&gt;
&lt;h2 id=&quot;how-can-you-install-it&quot;&gt;How Can You Install It?&lt;/h2&gt;
&lt;p&gt;I still need to work on the distribution via Homebrew but the code and
installation steps can be found on &lt;a href=&quot;https://dirtyhenry.github.io/pomodoro-cli/&quot; title=&quot;Jazzy docs for Pomodoro CLI&quot;&gt;the project website&lt;/a&gt; or &lt;a href=&quot;https://github.com/dirtyhenry/pomodoro-cli&quot; title=&quot;GitHub repository for Pomodoro CLI&quot;&gt;its GitHub
repository&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&quot;what-on-earth-is-pomodoro&quot;&gt;What on Earth Is Pomodoro?&lt;/h2&gt;
&lt;p&gt;It is a time management technique that was created by &lt;a href=&quot;https://francescocirillo.com&quot; title=&quot;Francesco Cirillo’s Website&quot;&gt;Francesco Cirillo&lt;/a&gt;.
To summarize, it’s all about splitting up your work into 25-minutes chunks of
time that are each full-focused on 1 objective. Pretty damn efficient when you
can afford to stick to it I must say.&lt;/p&gt;
&lt;h2 id=&quot;why-the-hell-did-you-do-that&quot;&gt;Why the Hell Did You Do That?&lt;/h2&gt;
&lt;p&gt;Sure, whether you’re talking CLI apps or whatever apps, there is nothing
revolutionary with this tool. As a matter of fact, There is &lt;a href=&quot;https://github.com/search?q=pomodoro+cli&quot; title=&quot;GitHub search results for Pomodoro and CLI&quot;&gt;a crazy amount of
alternatives on GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;But!&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;I made it.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This argument might only work for me, but it does count;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;It is made in Swift.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;As of today, it is the only result for &lt;a href=&quot;https://github.com/search?q=pomodoro+cli+language%3ASwift&quot; title=&quot;GitHub search results for Pomodoro, CLI AND Swift&quot;&gt;this other GitHub search&lt;/a&gt;;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;It has hooks.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;You can plug your own scripts when a pomodoro starts and when a pomodoro
finishes. I used them to include a cool Italian voice making announcements
and they put my display to sleep when a pomodoro is over. No excuse for not
taking a break.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;It keeps an history.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Every pomodoro starts by asking a simple question: what is the intent of the
current pomodoro. When the pomodoro finishes, the dates and this intent are
logged in a YAML file so I can track back how I spent my time.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;a-simple-use-case&quot;&gt;A simple use case&lt;/h2&gt;
&lt;p&gt;This blog post was written during 1 Pomodoro. Here is the associated log from
the journal:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;yml&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;- - &lt;/span&gt;&lt;span style=&quot;color:#85E89D&quot;&gt;startDate&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;01/02/2020 21:23:10&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;  - &lt;/span&gt;&lt;span style=&quot;color:#85E89D&quot;&gt;endDate&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;01/02/2020 21:48:10&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;  - &lt;/span&gt;&lt;span style=&quot;color:#85E89D&quot;&gt;message&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;Write a blog post about Pomodoro 1.0.0&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;What do you think? How do you like them tomatoes? 🍅&lt;/p&gt;
</content:encoded><category>Swift</category><category>Command-line interface</category><category>Open Source</category></item><item><title>Notes from FrenchKit 2019</title><link>https://www.mickf.net/tech/frenchkit-2019/</link><guid isPermaLink="true">https://www.mickf.net/tech/frenchkit-2019/</guid><pubDate>Thu, 10 Oct 2019 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;a href=&quot;https://www.mickf.net/tech/frenchkit-2018/&quot;&gt;&lt;strong&gt;Again&lt;/strong&gt;&lt;/a&gt;, &lt;a href=&quot;https://frenchkit.fr&quot;&gt;FrenchKit 2019&lt;/a&gt; was awesome. Talks with 🌟 are the talks I
recommend.&lt;/p&gt;
&lt;h2 id=&quot;day-1&quot;&gt;Day 1&lt;/h2&gt;
&lt;h3 id=&quot;animations-with-swiftui--chris-eidhof-&quot;&gt;Animations with SwiftUI — &lt;a href=&quot;https://twitter.com/chriseidhof&quot;&gt;Chris Eidhof&lt;/a&gt; 🌟&lt;/h3&gt;
&lt;p&gt;Using a basic animation example, namely creating a shaking effect on a rectangle
view, Chris shows the hidden complexity of SwiftUI and how developers used to
UIKit need to change their mental model about how to build views. Under the
hood, SwiftUI seems very similar to React: a tree of views with wrappers all
hover the place, with an efficient diffing algorithm deciding what to re-render.&lt;/p&gt;
&lt;h3 id=&quot;understanding-combine--daniel-steinberg-&quot;&gt;Understanding Combine — &lt;a href=&quot;https://twitter.com/dimsumthinking&quot;&gt;Daniel Steinberg&lt;/a&gt; 🌟&lt;/h3&gt;
&lt;p&gt;A good counterpart to Chris’ talk to mention how Apple frameworks evolved from
using the delegation pattern, then closures and are now adopting Reactive
Programming. Combine will probably become the &lt;em&gt;de facto&lt;/em&gt; framework to use, as
opposed to RxSwift and ReactiveCococa, due to its 1st party nature. The only
problem is that it is only available for iOS 13.&lt;/p&gt;
&lt;h3 id=&quot;swiftui--redux--thomas-ricouard&quot;&gt;SwiftUI &amp;amp; Redux — Thomas Ricouard&lt;/h3&gt;
&lt;p&gt;Many frameworks are available to bring the Redux pattern to iOS development, ie
dispatch actions, reducers, immutable states, mapStateToProps, etc. It could be
a good idea to use one to keep having architectural conversations relevant to
the mobile and web teams.&lt;/p&gt;
&lt;h3 id=&quot;testing--declarative-uis--nataliya-patsovska-&quot;&gt;Testing &amp;amp; Declarative UIs — &lt;a href=&quot;https://twitter.com/nataliya_bg&quot;&gt;Nataliya Patsovska&lt;/a&gt; 🌟&lt;/h3&gt;
&lt;p&gt;Great talk promoting snapshot testing, something I tend to already do on ongoing
projects 💪. Nataliya mentioned how we could benefit from a new feature of
iOS/Xcode ie Previews. She wondered if tree inspecting libraries similar to
&lt;code&gt;react-testing-library&lt;/code&gt; would eventually show up to inspect contents of SwiftUI
tree representations. A cool idea for an OSS side-project 💡.&lt;/p&gt;
&lt;h3 id=&quot;showcase-driven-development--jérôme-alves-&quot;&gt;Showcase Driven Development — &lt;a href=&quot;https://twitter.com/JegnuX/&quot;&gt;Jérôme Alves&lt;/a&gt; 🌟&lt;/h3&gt;
&lt;p&gt;This talk was about how Heetch created a browsing interface within the debug
release version of their app to demo &lt;em&gt;work in progress&lt;/em&gt; to their product and
quality teams as early as they could, building on &lt;a href=&quot;https://khanlou.com/2019/07/continuous-integration/&quot;&gt;the real continuous
integration post&lt;/a&gt; by Soroush Khanlou.&lt;/p&gt;
&lt;h3 id=&quot;slide-to-unlock--joel-kin-&quot;&gt;Slide to Unlock — &lt;a href=&quot;https://twitter.com/myunderpants&quot;&gt;Joel Kin&lt;/a&gt; 🌟&lt;/h3&gt;
&lt;p&gt;Subtitle: Building Custom UI with UIKit and Core Animation.&lt;/p&gt;
&lt;p&gt;When something looks a little complicated, should you spend time looking for a
library doing what you need, or should you spend time implementing it yourself?
Building on UISlider, Joel shows a real-case scenario of what to assess to make
the best informed decision. Notably, UISlider had a much better accessibility
support that 3rd parties equivalents.&lt;/p&gt;
&lt;h3 id=&quot;swiftly-swift-manipulation-with-swift--marcin-krzyzanowski&quot;&gt;Swiftly Swift manipulation… with Swift — &lt;a href=&quot;https://twitter.com/krzyzanowskim&quot;&gt;Marcin Krzyzanowski&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Marcin shows up what’s under the hood of his &lt;em&gt;work in progress&lt;/em&gt; code reordering
tool. While we could benefit from such a tool, it sounds too immature to be
integrated in a CI, but worth trying and keeping an eye on. Or even
contributing? It involves playing with SourceKitten and Swift AST.&lt;/p&gt;
&lt;p&gt;Update: it appears that Marcin is working on a &lt;a href=&quot;https://swiftstudio.app/&quot;&gt;Swift IDE&lt;/a&gt; that
retrospectively highlights his talk under a new light. See &lt;a href=&quot;https://www.mickf.net/tech/swift-heroes-digital-2021/&quot;&gt;the notes from Swift
Heroes Digital 2021&lt;/a&gt; for details.&lt;/p&gt;
&lt;h3 id=&quot;empower-your-uitableview-datasources-with-a-flexible-model--denis-poifol&quot;&gt;Empower Your UITableView DataSources with a Flexible Model — Denis Poifol&lt;/h3&gt;
&lt;p&gt;A prescription of a model to write table view view models.&lt;/p&gt;
&lt;h3 id=&quot;when-did-my-view-layout--gaëtan-zanella&quot;&gt;When Did My View Layout? — Gaëtan Zanella&lt;/h3&gt;
&lt;p&gt;The title of the talk is misleading. It was more about what is an iOS
application in terms of entry point, event management, run loop, etc.&lt;/p&gt;
&lt;h3 id=&quot;math--map-masterclass--daniel-steinberg&quot;&gt;Math &amp;amp; Map Masterclass — Daniel Steinberg&lt;/h3&gt;
&lt;p&gt;Good simple exercises on how to implement an alternative version of &lt;code&gt;map&lt;/code&gt; for
arrays, generics, optionals, results, and combine. Basic &amp;amp; deep at the same
time.&lt;/p&gt;
&lt;h3 id=&quot;swift-pills---vincent-pradeilles-&quot;&gt;Swift Pills - &lt;a href=&quot;https://twitter.com/v_pradeilles&quot;&gt;Vincent Pradeilles&lt;/a&gt; 🌟&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Weakifiable&lt;/li&gt;
&lt;li&gt;Autoclosure for log tooling&lt;/li&gt;
&lt;li&gt;Use map instead of if let These 3 tips are very actionable and recommended.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;day-2&quot;&gt;Day 2&lt;/h2&gt;
&lt;h3 id=&quot;swift-generics-topic--rob-napier&quot;&gt;Swift Generics Topic — Rob Napier&lt;/h3&gt;
&lt;p&gt;Don’t make things generic to early. Very similar to
&lt;a href=&quot;https://kentcdodds.com/blog/aha-programming&quot;&gt;this AHA Programming&lt;/a&gt;&lt;/p&gt;
&lt;h3 id=&quot;note-encryption--anastasiia-voitova-&quot;&gt;Note encryption — &lt;a href=&quot;https://twitter.com/vixentael&quot;&gt;Anastasiia Voitova&lt;/a&gt; 🌟&lt;/h3&gt;
&lt;p&gt;Subtitle: 10 lines for encryption, 1500 lines for key management.&lt;/p&gt;
&lt;p&gt;Anastasiia mentioned the real case of how her consulting company helped the Bear
app to add security features in their app. What trade-offs you should pick
depending on the risks, threats, trust. Lots of recommended readings:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Cossack Labs / Implementing End-to-End encryption in Bear App:
&lt;a href=&quot;https://t.co/oy5vJNCdvR?amp=1&quot;&gt;here&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/OWASP/owasp-mstg&quot;&gt;OWASP/owasp-mstg&lt;/a&gt;: The Mobile Security
Testing Guide (MSTG) is a comprehensive manual for mobile app security
development, testing and reverse engineering.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;swiftpms-new-resolver--mert-buran&quot;&gt;SwiftPM’s New Resolver — Mert Buran&lt;/h3&gt;
&lt;p&gt;Subtitle: Can it Resolve the Conflicts in my Relationship?.&lt;/p&gt;
&lt;p&gt;Really fun and innovative format. Many analogies to explain how pubgrub works
for SPM, and how algorithms we took for granted are under-appreciated.&lt;/p&gt;
&lt;h3 id=&quot;this-is-not-rocket-data-science--hervé-berenger&quot;&gt;This is Not Rocket (Data) Science — Hervé Berenger&lt;/h3&gt;
&lt;p&gt;Almost a star for this one. The idea was: how AI is actually hidden everywhere
and how 1st party frameworks can already help with a lot of stuff. Example:
using the background color of a messaging app to give a hint of the tone of the
message that is being written to help think twice about the choice of words
being used.&lt;/p&gt;
&lt;h3 id=&quot;building-voice-first-apps--elaine-dias-batista&quot;&gt;Building Voice-First Apps — Elaine Dias Batista&lt;/h3&gt;
&lt;p&gt;Elaine insisted how voice-first could be important for accessibility, and to do
it properly with existing frameworks.&lt;/p&gt;
&lt;h3 id=&quot;an-introduction-to-property-based-testing--vincent-pradeilles&quot;&gt;An Introduction to Property-Based Testing — &lt;a href=&quot;https://twitter.com/v_pradeilles&quot;&gt;Vincent Pradeilles&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Another approach to test using random values that can auto-discover edge cases
of input values that will reveal bugs in a codebase. It is not self sufficient
but can be a good complement to other testing strategies. Also, it can lead to
randomness in tests: for instance, a test could fail at the 10th execution. But
frameworks handling these kind of tests will provide you the failing data and
you can turn this failing scenario into a deterministic test case by adding it
in traditional test cases.&lt;/p&gt;
&lt;h3 id=&quot;shipping-a-catalyst-app-the-good-the-bad-and-the-ugly--peter-steinberger&quot;&gt;Shipping a Catalyst app: The Good, the Bad and the Ugly — &lt;a href=&quot;https://steipete.me/&quot;&gt;Peter Steinberger&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The story of how &lt;a href=&quot;https://pdfviewer.io&quot;&gt;PDF Viewer&lt;/a&gt; was ported to macOS using a
mix of AppKit, UIKit, private API, etc. The conclusion for me is that if you can
invest on SwiftUI, it is not worth exploring Catalyst.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://youtu.be/Xo3zGlyxXcI&quot;&gt;📺 Watch the talk&lt;/a&gt;&lt;/p&gt;
&lt;h3 id=&quot;and-thats-a-wrap--olivier-halligon&quot;&gt;And That’s A Wrap! — Olivier Halligon&lt;/h3&gt;
&lt;p&gt;An exploration of property wrappers, a feature introduced by Swift 5.1. It is
totally compatible with older version of iOS as it is interpreted at compile
time. The idea is to DRY behaviors of some properties. Example use cases:
clamping values into a range, handling UserDefaults with convenience,
customizing how a type conform to Codable, database mapping, etc.&lt;/p&gt;
&lt;h3 id=&quot;vapor-classroom--david-bonnet&quot;&gt;Vapor Classroom — David Bonnet&lt;/h3&gt;
&lt;p&gt;Key takeaways:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Apple now releases Swift Docker images on the same day new version of Swift
are released;&lt;/li&gt;
&lt;li&gt;Vapor allows to share DTO between an iOS client and a backend;&lt;/li&gt;
&lt;li&gt;A lot of boilerplate code that should be made better via property wrapper in
Vapor 4.&lt;/li&gt;
&lt;/ul&gt;
</content:encoded><category>Conference</category><category>Swift</category><category>iOS</category></item><item><title>WWDC 2019, A Basic Wish List</title><link>https://www.mickf.net/tech/wwdc-2019-basic-wishlist/</link><guid isPermaLink="true">https://www.mickf.net/tech/wwdc-2019-basic-wishlist/</guid><pubDate>Wed, 29 May 2019 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;It’s &lt;a href=&quot;https://www.macstories.net/stories/wwdc-a-wish-list-2019-edition/&quot;&gt;WWDC Wish List Season&lt;/a&gt;. Here is mine. Back to basics.&lt;/p&gt;
&lt;p&gt;In the last week or so, I’ve experienced 3 different obvious bugs using 3
different Apple products. If you ask me, my top item for a WWDC wish list would
be: &lt;em&gt;let bring attentions to details back&lt;/em&gt;!&lt;/p&gt;
&lt;h2 id=&quot;1-the-ipad-bug-recently-used-emojis&quot;&gt;#1. The iPad bug: recently used emojis&lt;/h2&gt;
&lt;p&gt;Here is a screenshot of my frequently used emojis:&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;My frequently used keyboard with 6 duplicates appearing&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;645&quot; width=&quot;645&quot; height=&quot;251&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Fduplicates.CdH3Urc7.gif&amp;amp;w=640&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;p&gt;Six duplicates and I don’t remember ever using this shower emoji 🚿.&lt;/p&gt;
&lt;h2 id=&quot;2-the-iphone-bug-typographic-glitch&quot;&gt;#2. The iPhone bug: typographic glitch&lt;/h2&gt;
&lt;p&gt;&lt;img alt=&quot;Double space&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;375&quot; width=&quot;375&quot; height=&quot;94&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Fdouble-space.CywSSCAw.gif&amp;amp;w=400&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;p&gt;I know putting two spaces after a punctuation is kind of a debate in the US, but
wait a minute, &lt;a href=&quot;https://practicaltypography.com/one-space-between-sentences.html&quot;&gt;no it isn’t&lt;/a&gt;. And certainly not within a date, nor in French.&lt;/p&gt;
&lt;h2 id=&quot;3-the-apple-watch-bug-maths-horror&quot;&gt;#3. The Apple Watch bug: maths horror&lt;/h2&gt;
&lt;p&gt;&lt;img alt=&quot;Math horror from the native Apple Watch weather app&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;312&quot; width=&quot;312&quot; height=&quot;390&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Fbug-weather-apple-watch.D7fqDmQQ.png&amp;amp;w=320&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;p&gt;So, 13 ≤ 12 ≤ 20? 😱&lt;/p&gt;
</content:encoded><category>iOS</category><category>Apple</category></item><item><title>Lessons learned from testing a React front with Cypress</title><link>https://www.mickf.net/tech/testing-react-app-with-cypress/</link><guid isPermaLink="true">https://www.mickf.net/tech/testing-react-app-with-cypress/</guid><pubDate>Wed, 27 Feb 2019 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;End-to-end testing is rarely the hot subject a team will fight about to tackle.
But it is useful for at least 2 scenarios:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;basic tests objectives: detect regressions, bugs, crashes, etc.;&lt;/li&gt;
&lt;li&gt;automate &amp;amp; speed up the process of seeding a system.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;why-cypress&quot;&gt;Why Cypress?&lt;/h2&gt;
&lt;p&gt;Here is a list of features that will help decide what the best solution is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Gitlab’s CI compatibility&lt;/li&gt;
&lt;li&gt;SauceLabs compatibility&lt;/li&gt;
&lt;li&gt;Visual regression tools&lt;/li&gt;
&lt;li&gt;Debugging tools&lt;/li&gt;
&lt;li&gt;Ease of maintenance of the tests&lt;/li&gt;
&lt;li&gt;Ease of use by non-technical people (ideally, it should be used by the Product
team)&lt;/li&gt;
&lt;li&gt;Size of the community&lt;/li&gt;
&lt;li&gt;Confidence in the product long-term&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;because-selenium-is-not-the-right-choice&quot;&gt;Because Selenium is not the right choice&lt;/h3&gt;
&lt;p&gt;After spending a day poking around Selenium’s Node port:&lt;/p&gt;
&lt;p&gt;Selenium via Node is not mature (the doc of v4 is limited and hard to read) and
quite buggy (submitting a form on Firefox just doesn’t work). When deciding to
commit to Selenium, you must handle it via Java directly as it seems to work
much better this way.&lt;/p&gt;
&lt;p&gt;The WebDriver protocol doesn’t allow to use &lt;code&gt;dom-testing-library&lt;/code&gt;-like features:
we can only fetch elements via id, name, etc. but not via visually appearing
elements (except for links exclusively). There is no obvious workaround given
the nature of how JS is injected in the browser to retrieve elements. As a
consequence, I guess WebDriver.IO or Nightwatch or other layers on top of
Selenium shouldn’t even be evaluated for the time being.&lt;/p&gt;
&lt;h3 id=&quot;cypress-promises&quot;&gt;Cypress’ promises&lt;/h3&gt;
&lt;p&gt;Cypress is a modern solution that is compatible with &lt;code&gt;dom-testing-library&lt;/code&gt;.
Minus points for a non-compatibility with Sauce Labs for the time being but they
promise it could work in the future (and they seem well-funded so promises could
be resolved).&lt;/p&gt;
&lt;h3 id=&quot;the-tooling-around-it&quot;&gt;The tooling around it&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://testing-library.com/docs/cypress-testing-library/intro&quot;&gt;Cypress Testing Library&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://chancejs.com&quot;&gt;Chance&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/cypress-io/eslint-plugin-cypress&quot;&gt;eslint-plugin-cypress&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;troubleshooting&quot;&gt;Troubleshooting&lt;/h2&gt;
&lt;h3 id=&quot;how-to-avoid-unnecessary-waits&quot;&gt;How to avoid unnecessary waits?&lt;/h3&gt;
&lt;p&gt;You can wait for a button to be enabled this way:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;js&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;1.&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;  cy.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;getByText&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&apos;Suivant&apos;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;).&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;as&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&apos;next&apos;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;2.&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;  cy.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&apos;@next&apos;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;).&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;should&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&apos;be.enabled&apos;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;).&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;click&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;();&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here is a line-by-line explanation of how it works:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Get the DOM element with our usual &lt;code&gt;getByTest&lt;/code&gt; and &lt;em&gt;alias&lt;/em&gt; for further
reference;&lt;/li&gt;
&lt;li&gt;Use Cypress’ native &lt;code&gt;get&lt;/code&gt; with the alias, assert/wait that the button is
enabled, and then click on it.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The difference between &lt;code&gt;getByText&lt;/code&gt; and &lt;code&gt;get&lt;/code&gt; is that &lt;code&gt;getByText&lt;/code&gt; asserts
&lt;code&gt;be.enable&lt;/code&gt; right away and won’t wait the same way Cypress does. Cf.
&lt;a href=&quot;https://docs.cypress.io/guides/references/best-practices.html#Unnecessary-wait-for-cy-get&quot;&gt;this doc&lt;/a&gt;
from Cypress:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Whenever commands have an assertion they will not resolve until their
associated assertions pass. This enables you to simply describe the state of
your application without having to worry about when it gets there.&lt;/p&gt;
&lt;/blockquote&gt;
</content:encoded><category>React</category><category>Cypress</category><category>Testing</category></item><item><title>Notes from FrenchKit 2018</title><link>https://www.mickf.net/tech/frenchkit-2018/</link><guid isPermaLink="true">https://www.mickf.net/tech/frenchkit-2018/</guid><pubDate>Mon, 19 Nov 2018 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;a href=&quot;https://frenchkit.fr/&quot;&gt;FrenchKit&lt;/a&gt; 2018 was awesome. I recommend it &lt;a href=&quot;https://www.mickf.net/tech/frenchkit-2017/&quot;&gt;again&lt;/a&gt; to any iOS/Swift
developer around. Day 1 was much better than Day 2. Two recurring topics were:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;code generation leveraging;&lt;/li&gt;
&lt;li&gt;and the importance of a good product management policy.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Most speakers seemed to use &lt;a href=&quot;https://www.deckset.com&quot;&gt;Deckset&lt;/a&gt; for their
presentations. As &lt;a href=&quot;https://www.mickf.net/tech/frenchkit-2017/&quot;&gt;often&lt;/a&gt;, international speakers were much much better
than French ones.&lt;/p&gt;
&lt;p&gt;Here are the talks I recommend.&lt;/p&gt;
&lt;h2 id=&quot;brew-create---max-howell&quot;&gt;brew create - Max Howell&lt;/h2&gt;
&lt;p&gt;Storytelling of how Max came to create &lt;a href=&quot;https://brew.sh&quot;&gt;Homebrew&lt;/a&gt; and how he
managed its huge success. It’s surprising he had such a product-oriented
approach for such a tech product. The whole talk was really nicely put (very
minimalist use of slides and a great video of the git activity to give a visual
feeling to the growing popularity of Brew).&lt;/p&gt;
&lt;p&gt;Two segments particularly stood out to me:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;One about the importance of naming things (the whole brew, cellar, keg,
formulae that Brew is using);&lt;/li&gt;
&lt;li&gt;One about the feeling of code ownership and how to control it.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;— &lt;a href=&quot;https://youtu.be/WMMPRS58n-o&quot;&gt;📺 Watch&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;going-prod-with-server-side-swift---pim-stolk&quot;&gt;Going Prod with Server-Side Swift - Pim Stolk&lt;/h2&gt;
&lt;p&gt;How an ING side-project (Banking of Things) is using server-side Swift. They
picked &lt;a href=&quot;https://www.kitura.dev&quot;&gt;Kitura&lt;/a&gt; over &lt;a href=&quot;https://vapor.codes&quot;&gt;Vapor&lt;/a&gt;
because they had a good vibe from the team and they seem to work very closely
together. They had tips to use containers to be as cloud-provider agnostic as
possible.&lt;/p&gt;
&lt;p&gt;— &lt;a href=&quot;https://youtu.be/tRakjsKwdg4&quot;&gt;📺 Watch&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;sharing-swift-writing-code-that-scales---florent-pillet&quot;&gt;Sharing Swift: writing code that scales - Florent Pillet&lt;/h2&gt;
&lt;p&gt;This was a good counterpart to Pim’s talk. Florent is French and is using Vapor
server-side. He’s really a big fan of
&lt;a href=&quot;https://github.com/apple/swift-nio&quot;&gt;SwiftNIO&lt;/a&gt; and its performances. One of his
tip was to make builds in containers locally so you can just deploy binaries to
production containers (no need for Swift compilers). He seems to have insights
straight from Apple saying that &lt;a href=&quot;https://swift.org/package-manager/&quot;&gt;SPM&lt;/a&gt; is not
coming to iOS anytime soon.&lt;/p&gt;
&lt;p&gt;Both Florent &amp;amp; Pim consider &lt;strong&gt;server-side Swift is production ready&lt;/strong&gt;. Kitura &amp;amp;
Vapor both provide &lt;a href=&quot;https://prometheus.io&quot;&gt;Prometheus&lt;/a&gt; support which seems to be
good enough for monitoring. One of the main pain point remaining seems to be
debugging from Linux.&lt;/p&gt;
&lt;p&gt;— &lt;a href=&quot;https://youtu.be/1G63BKeNfjA&quot;&gt;📺 Watch&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;the-lost-art-of-system-design---john-sundell&quot;&gt;The Lost Art of System Design - John Sundell&lt;/h2&gt;
&lt;p&gt;John is as a good showman and as energetic as reading
&lt;a href=&quot;https://www.swiftbysundell.com&quot;&gt;his blog&lt;/a&gt; lets you think. The talk was about
how to answer “where should we sit this piece of code?”. He was advocating
towards decoupling, building frameworks, keys &amp;amp; lock-in to different parts of an
application. Great practical tips that were somewhat Swift-related but can be
applied to any language as well.&lt;/p&gt;
&lt;p&gt;For instance: RootFactory creating basic objects and a LoggedFactory creating
objects once the user is logged in which translates that we’re sure we can
provide a User and that we don’t need to make it optional, etc.&lt;/p&gt;
&lt;p&gt;— &lt;a href=&quot;https://youtu.be/bAokeFxW2fo&quot;&gt;📺 Watch&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;swift-strings-seven-ways---mattt&quot;&gt;Swift Strings Seven Ways - Mattt&lt;/h2&gt;
&lt;p&gt;A storytelling kind of talk about how we take strings for granted and we think
they’re simple but they’re not. The guy is a big name in the iOS scene — among
others, creator of &lt;a href=&quot;https://nshipster.com&quot;&gt;NSHipster&lt;/a&gt; —, and it was surprising
to see a talk that was sometimes borderline spiritual (he digs the Cherokee
language a lot).&lt;/p&gt;
&lt;p&gt;But the 2nd half was way more practical about string jargons, struggles, and
tips on how to process them safely (ie override string by other types for
identifiers for instance in order to hide the complexity of string for a simple
usage, use Base64 for exchanging in a safe way, etc.)&lt;/p&gt;
&lt;p&gt;— &lt;a href=&quot;https://youtu.be/linHwUqeagU&quot;&gt;📺 Watch&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;the-700-next-devices---chris-eidhof&quot;&gt;The 700 next devices - Chris Eidhof&lt;/h2&gt;
&lt;p&gt;Again, a big figure in iOS development since he started
&lt;a href=&quot;https://www.objc.io&quot;&gt;objc.io&lt;/a&gt;. He gave a live-coding presentation of a layout
library he build for Swift that is going to be introduced in
&lt;a href=&quot;https://talk.objc.io&quot;&gt;Swift Talks&lt;/a&gt;. The library is really useful and has a nice
API and seems somewhat influenced by flex box as a complement to AutoLayout. It
will be even more useful once UIKit gets on macOS. Tip: when using the
Accessibility inspector during development, the simulator seems super
responsive.&lt;/p&gt;
&lt;p&gt;— &lt;a href=&quot;https://youtu.be/OLDHgg0uh6A&quot;&gt;📺 Watch&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;the-underestimated-power-of-keypaths---vincent-pradeilles&quot;&gt;The Underestimated Power of KeyPaths - &lt;a href=&quot;https://twitter.com/v_pradeilles&quot;&gt;Vincent Pradeilles&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Lightning talk about how to use key paths to improve Swift convenience, in
particular to avoid dumb closures.&lt;/p&gt;
&lt;p&gt;— &lt;a href=&quot;https://youtu.be/jpAT5DoSUgw&quot;&gt;📺 Watch&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;improving-your-developer-experience-with-open-source-swift---dimitri-dupuis-latour&quot;&gt;Improving your Developer Experience with Open-Source Swift - Dimitri Dupuis-Latour&lt;/h2&gt;
&lt;p&gt;Interesting short talk to make contributing to Swift and its environment not as
scary as it seems. Empowering mode ✊.&lt;/p&gt;
&lt;p&gt;— &lt;a href=&quot;https://youtu.be/olS5w9fBxog&quot;&gt;📺 Watch&lt;/a&gt;&lt;/p&gt;
</content:encoded><category>Conference</category><category>Swift</category><category>iOS</category></item><item><title>Notes from FrenchKit 2017</title><link>https://www.mickf.net/tech/frenchkit-2017/</link><guid isPermaLink="true">https://www.mickf.net/tech/frenchkit-2017/</guid><pubDate>Fri, 12 Jan 2018 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;a href=&quot;https://frenchkit.fr&quot;&gt;FrenchKit&lt;/a&gt; 2017 was awesome. I recommend it to any iOS/Swift developer
around.&lt;/p&gt;
&lt;p&gt;I wrote many notes during the two days of the conference but I forgot to process
them right afterwards when things were still fresh. Bummer.&lt;/p&gt;
&lt;p&gt;Finally, I went through the notes today and decided to make a blog post out of
them anyway. Raw and undetailed, 2018-style!&lt;/p&gt;
&lt;h2 id=&quot;my-favorite-talks&quot;&gt;My favorite talks&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://youtu.be/DrdxSNG-_DE&quot;&gt;Playground Driven Development&lt;/a&gt; by Brandon
Williams (quite more detailed than the
&lt;a href=&quot;https://talk.objc.io/episodes/S01E51-playground-driven-development-at-kickstarter&quot;&gt;objc.io&lt;/a&gt;’s
one)&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://youtu.be/e9NI5XnEqHA&quot;&gt;May the Code Review Be with You&lt;/a&gt; by Egor
Tolstoy&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://youtu.be/3ia3ngqM2mM&quot;&gt;You Deserve Nice Things&lt;/a&gt; by Soroush Khanlou&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://youtu.be/dYWE2d4_IPY&quot;&gt;Core Data Custom Store&lt;/a&gt; by Rew Islam&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://youtu.be/WM6WECv4B2E&quot;&gt;Scaling Open Source Communities&lt;/a&gt; by Felix
Krause&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Side note to mention that a big theme of the conference was &lt;strong&gt;code generation&lt;/strong&gt;.
It was frenquently quoted as something you should try out and be ready to use
when relevant. I’m in.&lt;/p&gt;
&lt;h2 id=&quot;what-could-be-improved-next-time&quot;&gt;What could be improved next time?&lt;/h2&gt;
&lt;h3 id=&quot;france-we-need-to-become-better-public-speakers&quot;&gt;France, we need to become better public speakers&lt;/h3&gt;
&lt;p&gt;As you can see above, not a single French speaker made it to my favorite talks.
This is hard to explain but for some reasons, French speakers are often nervous,
awkward or even uncharismatic. I rarely gave public talks but when I did, these
all applied to me as well. Not sure where this is coming from but fellow French
developers, we need to address this! 🇫🇷💪&lt;/p&gt;
&lt;h3 id=&quot;lets-be-better-with-jokes&quot;&gt;Let’s be better with jokes&lt;/h3&gt;
&lt;p&gt;I’m sick of jokes filled of condescending notes.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Core Data sucks &lt;em&gt;(audience laughs)&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Or:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Cocoapods sucks &lt;em&gt;(audience laughs)&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I don’t remember the exact jokes but I felt some were patronizing and
misleading. Core Data and Cocoapods are awesome tools. They have flaws but
nobody should be embarassed using them.&lt;/p&gt;
&lt;p&gt;Also, enough with cat memes. As most overused material, they lost everything
that made them cool/cute/funny in the first place.&lt;/p&gt;
&lt;h2 id=&quot;my-todo-list-until-frenchkit-2018&quot;&gt;My TODO list until FrenchKit 2018&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;☐ Try &lt;a href=&quot;https://github.com/krzysztofzablocki/Sourcery&quot;&gt;Sourcery&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;☒ Check out BuddyBuild &lt;sup&gt;&lt;a href=&quot;#user-content-fn-footnote&quot; id=&quot;user-content-fnref-footnote&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/li&gt;
&lt;li&gt;☑︎ Check out Swift 4’s
&lt;a href=&quot;https://developer.apple.com/documentation/swift/codable&quot;&gt;Codable&lt;/a&gt; protocol&lt;/li&gt;
&lt;li&gt;☒ Check out the &lt;a href=&quot;https://www.jetbrains.com/objc/&quot;&gt;AppCode&lt;/a&gt; IDE&lt;/li&gt;
&lt;li&gt;☐ The &lt;code&gt;rethrows&lt;/code&gt; keyword?&lt;/li&gt;
&lt;li&gt;☐ Play a little with the &lt;code&gt;Sequence&lt;/code&gt;, &lt;code&gt;IteratorProtocol&lt;/code&gt; protocols&lt;/li&gt;
&lt;li&gt;☑︎ Start using GitHub’s global search&lt;/li&gt;
&lt;li&gt;☑︎ Follow &lt;a href=&quot;https://twitter.com/PublicExtension&quot;&gt;PublicExtension&lt;/a&gt; on Twitter&lt;/li&gt;
&lt;li&gt;☐ Check out Server-side Swift
&lt;ul&gt;
&lt;li&gt;☑︎ Kitura&lt;/li&gt;
&lt;li&gt;☑︎ Vapor&lt;/li&gt;
&lt;li&gt;☐ &lt;a href=&quot;https://perfect.org&quot;&gt;Perfect&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;☐ Play with &lt;code&gt;NSAtomicStore&lt;/code&gt; (good for a small data set)&lt;/li&gt;
&lt;li&gt;☒ Check out [Dashlane/CustomStores]&lt;sup&gt;&lt;a href=&quot;#user-content-fn-update&quot; id=&quot;user-content-fnref-update&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;&lt;/li&gt;
&lt;li&gt;☐ Have a clearer understanding of static vs dynamic libraries&lt;/li&gt;
&lt;li&gt;☐ Is it possible to dual boot with a Linux distribution?&lt;/li&gt;
&lt;li&gt;☑︎ Start using &lt;a href=&quot;https://github.com/realm/SwiftLint&quot;&gt;SwiftLint&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;☐ Read
&lt;a href=&quot;https://github.com/apple/swift/blob/master/docs/Android.md&quot;&gt;Getting Started with Swift on Android&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;☑︎ Start using &lt;a href=&quot;https://github.com/danger/danger&quot;&gt;Danger&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;☑︎ Check out &lt;a href=&quot;https://grafana.com&quot;&gt;Grafana&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;☐ Display Xcode build durations&lt;/li&gt;
&lt;li&gt;☐ Checkout &lt;a href=&quot;https://michele.io/test-logs-in-xcode/&quot;&gt;xcactivitylog files&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;☐ There should be some direct mapping between graphql and core data.&lt;/li&gt;
&lt;li&gt;☑︎ Subscribe to Awesome iOS Newsletter&lt;/li&gt;
&lt;li&gt;☑︎ Subscribe to &lt;a href=&quot;https://swiftnews.curated.co&quot;&gt;this week in Swit&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;things-i-wrote-but-forgot-what-it-was-about&quot;&gt;Things I wrote but forgot what it was about&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;detrace&lt;/li&gt;
&lt;li&gt;Sirius : coordinator&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you know what they could mean, please get in touch.&lt;/p&gt;
&lt;section data-footnotes class=&quot;footnotes&quot;&gt;&lt;h2 class=&quot;sr-only&quot; id=&quot;footnote-label&quot;&gt;Footnotes&lt;/h2&gt;
&lt;ol&gt;
&lt;li id=&quot;user-content-fn-footnote&quot;&gt;
&lt;p&gt;Been bought by Apple since. &lt;a href=&quot;#user-content-fnref-footnote&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 1&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-update&quot;&gt;
&lt;p&gt;The code is still missing today, not sure it will ever show up. &lt;a href=&quot;#user-content-fnref-update&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 2&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;
</content:encoded><category>Conference</category><category>Swift</category><category>iOS</category></item><item><title>Writing a Swift Pomodoro Timer Command-Line Tool</title><link>https://www.mickf.net/tech/swift-command-line-pomodoro/</link><guid isPermaLink="true">https://www.mickf.net/tech/swift-command-line-pomodoro/</guid><pubDate>Sat, 04 Nov 2017 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;I wanted to experiment on writing command line tools with Swift, I wrote a
simple command-line &lt;a href=&quot;https://en.wikipedia.org/wiki/Pomodoro_Technique&quot;&gt;pomodoro&lt;/a&gt; timer. I had to find answers to quite a
number of questions to achieve this, but Internet is great at finding answers to
things. So here we go.&lt;/p&gt;
&lt;h2 id=&quot;how-to-write-a-progress-bar-on-the-command-line&quot;&gt;How to write a progress bar on the command line?&lt;/h2&gt;
&lt;p&gt;I had never written a progress bar on the command line before and this
&lt;a href=&quot;https://stackoverflow.com/questions/238073/how-to-add-a-progress-bar-to-a-shell-script&quot;&gt;StackOverflow question&lt;/a&gt; was of great help to understand how
they work.&lt;/p&gt;
&lt;h2 id=&quot;how-to-start-with-swift-command-line-tools&quot;&gt;How to start with Swift command-line tools?&lt;/h2&gt;
&lt;p&gt;To get started, I recommend &lt;a href=&quot;https://talk.objc.io/episodes/S01E22-command-line-tools-with-swift&quot;&gt;this Swift Talk video&lt;/a&gt; (a little over 17
minutes long). As I had trouble setting up dependencies right (the video is
getting old and Swift changed in the meantime), &lt;a href=&quot;https://swift.org/package-manager/&quot;&gt;this post about the Package
Manager&lt;/a&gt; on Swift’s website, was also pretty useful to get a
working Xcode project with the &lt;a href=&quot;https://github.com/kylef/Commander&quot;&gt;Commander&lt;/a&gt; dependency setup right.&lt;/p&gt;
&lt;p&gt;Basically, everything you need to type in the terminal is:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;swift&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; package&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; init&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; --type&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; executable&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;# Setting up dependencies in `Package.swift`&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;swift&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; package&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; update&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;swift&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; package&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; generate-xcodeproj&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;swift&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; build&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;.build/debug/&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;&amp;lt;name-of-your-target&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;how-to-output-things-to-the-standard-output&quot;&gt;How to output things to the standard output?&lt;/h2&gt;
&lt;p&gt;Well &lt;code&gt;print()&lt;/code&gt; is the easy answer by it doesn’t manage escaping characters
right. So &lt;code&gt;FileHandle.standardOutput&lt;/code&gt; was what I was looking for to manage a
proper terminal progress bar.&lt;/p&gt;
&lt;h2 id=&quot;what-does-the-results-look-like&quot;&gt;What does the results look like?&lt;/h2&gt;
&lt;p&gt;Try it &lt;a href=&quot;https://github.com/dirtyhenry/pomodoro-cli/&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&quot;what-are-the-next-steps&quot;&gt;What are the next steps?&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;✔︎ &lt;del&gt;Ask for the description of the task before starting the pomodoro&lt;/del&gt;;&lt;/li&gt;
&lt;li&gt;✔︎ &lt;del&gt;Log the pomodoro in a file for archives and time-reporting&lt;/del&gt;;&lt;/li&gt;
&lt;li&gt;✔︎ &lt;del&gt;Notify the user in the notification center or by a sound when the timer
ends.&lt;/del&gt;;&lt;/li&gt;
&lt;li&gt;✔︎ &lt;del&gt;Integrate with other stuff via &lt;strong&gt;Shell&lt;/strong&gt; scripts.&lt;/del&gt;;&lt;/li&gt;
&lt;li&gt;Use the full width of the terminal window instead of a fixed length (which
should mean
&lt;a href=&quot;https://stackoverflow.com/questions/36219597/referring-to-environment-variables-in-swift&quot;&gt;reading environment variables&lt;/a&gt;);&lt;/li&gt;
&lt;li&gt;✔︎ &lt;del&gt;Build for release&lt;/del&gt;;&lt;/li&gt;
&lt;li&gt;Distribute.&lt;/li&gt;
&lt;/ul&gt;
</content:encoded><category>Swift</category><category>Command-line interface</category></item><item><title>Dynamic resizing of a UICollectionViewCell&apos;s height</title><link>https://www.mickf.net/tech/ios11-size-for-dynamic-collection-view-cell/</link><guid isPermaLink="true">https://www.mickf.net/tech/ios11-size-for-dynamic-collection-view-cell/</guid><pubDate>Thu, 19 Oct 2017 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Your cell includes dynamic text and you need to size it appropriately. I feel
like I did that 1.000.000 times so here it is: my Swift 3 definitive method for
not repeating myself. It works well with iOS 11 and below.&lt;/p&gt;
&lt;p&gt;Here are the steps to make it work:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Make sure your cell has all the constraints required to be self-dependent to
define its size&lt;/li&gt;
&lt;li&gt;Add a dependency to constraint the width of the cell (which should be easy to
compute, as most of the time you want to find the height of your cell)&lt;/li&gt;
&lt;li&gt;Get inspired by the following code to create an equivalent method for your
cell&lt;/li&gt;
&lt;/ol&gt;
&lt;script src=&quot;https://gist.github.com/dirtyhenry/1820b9cb07095c42f427e38a912477d4.js&quot;&gt;
&lt;/script&gt;
</content:encoded><category>iOS</category><category>Swift</category><category>UIKit</category></item><item><title>Troubleshooting Keychain Items on iOS</title><link>https://www.mickf.net/tech/deleting-keychain-items/</link><guid isPermaLink="true">https://www.mickf.net/tech/deleting-keychain-items/</guid><description>Learn how to debug your app&apos;s Keychain items on iOS by listing them and/or deleting them.</description><pubDate>Mon, 26 Jun 2017 00:00:00 GMT</pubDate><content:encoded>&lt;h2 id=&quot;how-keychain-items-can-slow-down-debugging&quot;&gt;How Keychain Items Can Slow Down Debugging&lt;/h2&gt;
&lt;p&gt;Firebase, among other iOS libraries can install items in a device keychain and
it can become pretty painful to test authentication without having to
reinitialize the simulator, and it gets even more complicated on a real device.&lt;/p&gt;
&lt;h2 id=&quot;some-debugging-code&quot;&gt;Some Debugging Code&lt;/h2&gt;
&lt;p&gt;Here is a little piece of code that will output what are the items your app can
access in the keychain, and will either output them, delete them or both.&lt;/p&gt;
&lt;p&gt;⚠️ I want to insist this should be enabled for debug/development purposes only,
you most likely don’t want to use this code in a production environment.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://gist.github.com/dirtyhenry/46a87f9a3717532085974edcfa114051&quot;&gt;the gist&lt;/a&gt;&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;func&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; iterateKeychainItems&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;log&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;Bool&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;delete&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;Bool&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; secItemClasses &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; [&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        kSecClassGenericPassword,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        kSecClassInternetPassword,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        kSecClassCertificate,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        kSecClassKey,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        kSecClassIdentity&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    ]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    if&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; (log) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        for&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; secItemClass &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; secItemClasses {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;            let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; query: [&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;Any&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; [&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;                kSecReturnAttributes &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;as&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; String&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; kCFBooleanTrue,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;                kSecMatchLimit &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;as&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; String&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; kSecMatchLimitAll,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;                kSecClass &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;as&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; String&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; secItemClass&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;            ]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;            var&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; result: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;AnyObject&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;?&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;            let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; status &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; SecItemCopyMatching&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(query &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;as&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; CFDictionary, &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;result)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;            if&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; status &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; noErr {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;                print&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(result &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;as&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; Any&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;            }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;        print&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;AppUsageMetadata.iterateKeychainItems ended.&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    if&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; (delete) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        for&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; secItemClass &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; secItemClasses {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;            let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; dictionary &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; [kSecClass &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;as&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; String&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;secItemClass]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;            SecItemDelete&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(dictionary &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;as&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; CFDictionary)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
</content:encoded><category>iOS</category><category>Swift</category><category>Security</category></item><item><title>A FileManager Swift extension to manage iOS file systems basics with ease</title><link>https://www.mickf.net/tech/filemanager-swift-extension-for-ios-file-system-basics/</link><guid isPermaLink="true">https://www.mickf.net/tech/filemanager-swift-extension-for-ios-file-system-basics/</guid><pubDate>Tue, 13 Jun 2017 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;I recently spent some time figuring out the best way to find the URL/paths of
the &lt;a href=&quot;https://developer.apple.com/library/content/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html#//apple_ref/doc/uid/TP40010672-CH2-SW12&quot;&gt;recommended iOS file system used directories&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I felt that iOS URL/paths was very confusing:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;NSSearchPathForDirectoriesInDomains&lt;/code&gt; returns an array of paths&lt;/li&gt;
&lt;li&gt;&lt;code&gt;FileManager&lt;/code&gt;’s
&lt;code&gt;urls(for directory: FileManager.SearchPathDirectory, in domainMask: FileManager.SearchPathDomainMask)&lt;/code&gt;
returns an array of URL&lt;/li&gt;
&lt;li&gt;&lt;code&gt;NSHomeDirectory()&lt;/code&gt; returns 1 &lt;code&gt;String&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;String&lt;/code&gt; (ie paths) are missing the URL management methods that &lt;code&gt;NSString&lt;/code&gt; had&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So I came up with this little &lt;code&gt;FileManager&lt;/code&gt;’s extension that could be useful to
many:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;extension FileManager {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    func homeDirectory() -&amp;gt; URL {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;        return URL(fileURLWithPath: NSHomeDirectory())&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    func homeDirectoryPath() -&amp;gt; String {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;        return NSHomeDirectory()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    func tmpDirectory() -&amp;gt; URL {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;        return homeDirectory().appendingPathComponent(&quot;tmp&quot;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    // ...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
</content:encoded><category>Swift</category><category>iOS</category></item><item><title>IPv6 Ready ?</title><link>https://www.mickf.net/tech/ipv6-not-ready/</link><guid isPermaLink="true">https://www.mickf.net/tech/ipv6-not-ready/</guid><pubDate>Fri, 13 Nov 2015 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;L’infrastructure réseau est-elle &lt;strong&gt;prête pour l’IPv6 ?&lt;/strong&gt; La question s’est posée
très simplement pour nous au moment de chercher un hébergement pour nos
serveurs. La réponse est simplement &lt;strong&gt;non&lt;/strong&gt; !&lt;/p&gt;
&lt;h2 id=&quot;ipv6-et-gandi-vps&quot;&gt;IPv6 et Gandi VPS&lt;/h2&gt;
&lt;p&gt;Ayant l’habitude de travailler avec &lt;a href=&quot;http://www.gandi.net/&quot;&gt;Gandi&lt;/a&gt; (noms de
domaine et un serveur mi-pro / mi-perso), je suis allé voir leurs offres. Le
serveur de base est à 7,96€ HT / mois&lt;sup&gt;&lt;a href=&quot;#user-content-fn-1&quot; id=&quot;user-content-fnref-1&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; en proposant seulement une IPv6.
Rajouter une IPv4 au serveur représente 3,53€ HT / mois en plus, soit 44%
d’augmentation !&lt;/p&gt;
&lt;p&gt;De là est né l’envie de tester un serveur IPv6 only et de vérifier si cela
fonctionne correctement dans une infrastructure réseau à destination du grand
public. Après tout pourquoi pas, on dit depuis des années qu’il faut passer à
IPv6 pour palier à
&lt;a href=&quot;https://fr.wikipedia.org/wiki/%C3%89puisement_des_adresses_IPv4&quot;&gt;l’épuisement des adresses IPv4&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Nous avons donc créé un petit serveur IPv6 only pour nos tests.&lt;/p&gt;
&lt;h2 id=&quot;ipv6-et-la-freebox&quot;&gt;IPv6 et la Freebox&lt;/h2&gt;
&lt;p&gt;À la maison, mon fournisseur d’accès est Free, avec une Freebox V4 (firmware
1.5.20). La configuration par défaut de cette Freebox n’accepte pas l’IPv6, ce
qui est un très mauvais démarrage pour nos tests.&lt;/p&gt;
&lt;p&gt;Il est possible d’activer le support de l’IPv6 en allant dans les réglages, mais
cela implique qu’on se restreint à un public de connaisseurs. Et puis surtout,
même après activation, on se rend vite compte que ça ne fonctionne pas tout le
temps.&lt;/p&gt;
&lt;p&gt;Un &lt;code&gt;ssh@ipv6.de.mon.serveur.io&lt;/code&gt;&lt;sup&gt;&lt;a href=&quot;#user-content-fn-2&quot; id=&quot;user-content-fnref-2&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;2&lt;/a&gt;&lt;/sup&gt; va tourner dans le vide sans afficher de
prompt, alors que le &lt;code&gt;ssh@ipv4.de.mon.serveur.io&lt;/code&gt; vers ce même serveur (qui a
donc 2 IPs) va répondre tout de suite.&lt;/p&gt;
&lt;p&gt;Et un peu plus tard, &lt;code&gt;ssh@ipv6.de.mon.serveur.io&lt;/code&gt;&lt;sup&gt;&lt;a href=&quot;#user-content-fn-2&quot; id=&quot;user-content-fnref-2-2&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;2&lt;/a&gt;&lt;/sup&gt; va fonctionner…&lt;/p&gt;
&lt;p&gt;Ce n’est peut-être pas Free le fautif, c’est peut-être un élément du réseau
entre Free et Gandi, mais ce qui est sûr c’est qu’il y a 2 obstacles majeurs. Il
faut déjà avoir une démarche volontaire d’activation de l’IPv6, et même dans ce
cas, ça ne fonctionne pas tout le temps.&lt;/p&gt;
&lt;h2 id=&quot;ipv6-et-la-mobilité&quot;&gt;IPv6 et la mobilité&lt;/h2&gt;
&lt;p&gt;Notre &lt;a href=&quot;https://github.com/statium-app&quot;&gt;application &lt;em&gt;Statium&lt;/em&gt;&lt;/a&gt; est proposée sur mobile ; et pour
notre &lt;a href=&quot;http://blog.statium.io/&quot;&gt;data-lab&lt;/a&gt; nous faisons particulièrement
attention à ce qu’il soit compatible à 100% avec les smartphones.&lt;/p&gt;
&lt;p&gt;Donc la 2ème question qui vient à l’esprit : est-ce que le réseau 3G et 4G
supporte l’IPv6 ? Là encore c’est plutôt décevant.&lt;/p&gt;
&lt;p&gt;Mon opérateur est Bouygues Telecom avec un abonnement 4G et mon associé a la
même configuration. Nous avons effectué quelques tests pour accéder au serveur
HTTP en IPv6&lt;sup&gt;&lt;a href=&quot;#user-content-fn-3&quot; id=&quot;user-content-fnref-3&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;, aucun n’a fonctionné (tests effectués avec Safari sur iOS 8).&lt;/p&gt;
&lt;p&gt;De nouveau, ce n’est peut-être pas l’infrastructure Bouygues Telecom qui pose
problème, c’est peut-être un élément d’interconnexion, mais le résultat est le
même : si notre serveur est IPv6 only, on sait d’ores et déjà qu’on sera
inaccessible à une partie importante du traffic mobile.&lt;/p&gt;
&lt;h2 id=&quot;ipv6-not-ready&quot;&gt;IPv6 not ready&lt;/h2&gt;
&lt;p&gt;En résumé, quand on est éditeur de services, de contenus ou d’applications avec
une dépendance à internet (ce qui est une tautologie pléonasmique de nos jours),
on ne peut pas se permettre d’exposer son infrastructure en IPv6 (sauf si on a
l’envie d’être injoignable par la majorité de ses utilisateurs).&lt;/p&gt;
&lt;p&gt;À l’heure du mouvement &lt;a href=&quot;http://www.lafrenchtech.com/&quot;&gt;French Tech&lt;/a&gt; lancé par le
gouvernement, il serait intéressant d’accélérer le support de l’IPv6 chez les
opérateurs, sans quoi rien ne pourra se mettre en place.&lt;/p&gt;
&lt;p&gt;La
&lt;a href=&quot;http://www.nextinpact.com/news/92774-fibre-ipv6-open-data-vote-premieres-mesures-loi-macron.htm&quot;&gt;tentative de loi de Corinne Erhel&lt;/a&gt;
va dans ce sens, mais elle n’est pas encore passée.&lt;/p&gt;
&lt;p&gt;Et même si cette loi passe bientôt ; elle oblige les équipementiers à délivrer
des terminaux compatibles IPv6 à partir du 1er janvier 2017 ; le temps que le
renouvellement se propage ensuite chez les utilisateurs finaux et dans les
infrastructures réseaux, il faudra compter quelques années avant d’avoir un taux
de couverture IPv6 assez intéressant pour que les éditeurs passent le pas.&lt;/p&gt;
&lt;p&gt;On n’y est pas encore !&lt;/p&gt;
&lt;section data-footnotes class=&quot;footnotes&quot;&gt;&lt;h2 class=&quot;sr-only&quot; id=&quot;footnote-label&quot;&gt;Footnotes&lt;/h2&gt;
&lt;ol&gt;
&lt;li id=&quot;user-content-fn-1&quot;&gt;
&lt;p&gt;en se basant sur l’achat d’un pack de 2 millions de crédits chez Gandi &lt;a href=&quot;#user-content-fnref-1&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 1&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-2&quot;&gt;
&lt;p&gt;une IPv6 a cet aspect : &lt;code&gt;2001:4198:dc0:41:316:3eaf:fab8:b694&lt;/code&gt; &lt;a href=&quot;#user-content-fnref-2&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 2&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt; &lt;a href=&quot;#user-content-fnref-2-2&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 2-2&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;sup&gt;2&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-3&quot;&gt;
&lt;p&gt;une URL avec une IPv6 a cet aspect :
&lt;code&gt;http://[2001:4198:dc0:41:316:3eaf:fab8:b694]&lt;/code&gt; &lt;a href=&quot;#user-content-fnref-3&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 3&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;
</content:encoded><category>IPv6</category><category>DevOps</category></item><item><title>DroidCon 2014</title><link>https://www.mickf.net/tech/droidcon-2014/</link><guid isPermaLink="true">https://www.mickf.net/tech/droidcon-2014/</guid><pubDate>Wed, 22 Oct 2014 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;You can watch all the videos on &lt;a href=&quot;https://www.youtube.com/channel/UCkatLlah5weIpN23LqMgdTg&quot;&gt;the Droidcon Paris Youtube
channel&lt;/a&gt; but I especially recommend these 3 talks.&lt;/p&gt;
&lt;h2 id=&quot;scaling-android-development-at-twitter&quot;&gt;&lt;em&gt;Scaling Android Development at Twitter&lt;/em&gt;&lt;/h2&gt;
&lt;p&gt;&lt;img alt=&quot;Scaling Android Development at Twitter&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;1243&quot; width=&quot;1243&quot; height=&quot;708&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Fdroidcon-jan-chong.CPpLNp4m.png&amp;amp;w=1080&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;p&gt;This talk by &lt;a href=&quot;http://en.wikipedia.org/wiki/Software_release_train&quot;&gt;Jan Chong&lt;/a&gt;, engineering manager at Twitter for
Android, was about how Twitter’s mobile team transitioned from a 5-people team
to a 70+ contributors effort. Here are some key points from the talk.&lt;/p&gt;
&lt;p&gt;You can watch it &lt;a href=&quot;http://youtu.be/T5qEnillTHc&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&quot;operations&quot;&gt;Operations&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;In 3 years, Twitter for Android went from a 8 to 12 weeks release schedule to
1 release a week&lt;/li&gt;
&lt;li&gt;The key quality indicator they’re following are crashed : they analyzed that
when a user experienced a crash, his engagement would drop significantly for
the next month (of course, they use &lt;a href=&quot;https://try.crashlytics.com&quot;&gt;Crashlytics&lt;/a&gt;, that they own)&lt;/li&gt;
&lt;li&gt;API released for mobiles need to be supported for a loooooong time&lt;/li&gt;
&lt;li&gt;They baked an API mechanism to support A/B testing within their apps that does
not require republishing&lt;/li&gt;
&lt;li&gt;They also have an interesting feature switch system where they remotely
control a device/manufacturer/OS version matrix to swith features on and off,
again to be able to tune their apps and avoir crashes without the need to
republish&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;tools-and-processes&quot;&gt;Tools and processes&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;They’re using Gradle and Android Studio&lt;/li&gt;
&lt;li&gt;Twitter practice &lt;a href=&quot;http://en.wikipedia.org/wiki/Eating_your_own_dog_food&quot;&gt;dogfooding&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;They switched from &lt;a href=&quot;https://code.google.com/p/robotium/&quot;&gt;Robotium&lt;/a&gt; to &lt;a href=&quot;https://code.google.com/p/android-test-kit/wiki/Espresso&quot;&gt;Espresso&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;They also use &lt;a href=&quot;https://developer.android.com/training/testing/ui-automator&quot;&gt;uiautomator&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;They use a &lt;a href=&quot;http://en.wikipedia.org/wiki/Software_release_train&quot;&gt;release train&lt;/a&gt; schedule to run their and
transitioned from a single 4-week train to two concurrent 2-weeks trains to
reduce the gap between deadlines&lt;/li&gt;
&lt;li&gt;They also use a “+1/+2” code review system&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;how-open-source-powers-facebook-on-android-by-simon-stewart&quot;&gt;&lt;em&gt;How Open Source Powers Facebook on Android&lt;/em&gt;, by Simon Stewart&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://youtu.be/MT6bU9ofJDE&quot;&gt;📺&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;petit-design-pour-grande-humanité-by-geoffrey-dome&quot;&gt;&lt;em&gt;Petit Design pour Grande Humanité&lt;/em&gt;, by Geoffrey Dome&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://youtu.be/mwF4qk9OMe8&quot;&gt;📺&lt;/a&gt;&lt;/p&gt;
</content:encoded><category>Conference</category><category>Android</category></item><item><title>Simulating protected properties and selectors in Objective-C</title><link>https://www.mickf.net/tech/simulating-protected-modifier-with-objective-c/</link><guid isPermaLink="true">https://www.mickf.net/tech/simulating-protected-modifier-with-objective-c/</guid><pubDate>Wed, 19 Mar 2014 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;There’s no &lt;code&gt;protected&lt;/code&gt; modifier in Objective-C. In a sense, we should be
grateful that Objective-C is not Java. On the other hand, sometimes it can suck.
What’s the best way to deal with it? Let’s simulate protection!&lt;/p&gt;
&lt;h2 id=&quot;the-problem-is-already-asked-and-answered&quot;&gt;The problem is already asked and answered&lt;/h2&gt;
&lt;p&gt;When looking for a solution to this, I found these two StackOverflow posts:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://stackoverflow.com/questions/12633627/expose-a-private-objective-c-method-or-property-to-subclasses&quot;&gt;Expose a private Objective-C method or property to subclasses&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://stackoverflow.com/questions/3725857/protected-methods-in-objective-c&quot;&gt;Protected methods in objective-c&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;which exposed the real case where the lack of &lt;code&gt;protected&lt;/code&gt; sucks (ie subclassing)
and also the solution to the problem (ie simulating protection) as used by Apple
herself in classes such as
&lt;a href=&quot;https://developer.apple.com/library/ios/documentation/uikit/reference/UIGestureRecognizer_Class/Reference/Reference.html&quot;&gt;&lt;code&gt;UIGestureRecognizer&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&quot;a-concrete-example&quot;&gt;A Concrete Example&lt;/h2&gt;
&lt;h3 id=&quot;the-public&quot;&gt;The public…&lt;/h3&gt;
&lt;p&gt;Let’s say I have a &lt;code&gt;BSDaddy&lt;/code&gt; base class with only one publicly declared taskk:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;objc&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;@interface&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; BSDaddy&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; : &lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;NSObject&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;- (&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;NSString&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;introduction&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;@end&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now I want a &lt;code&gt;BSSon&lt;/code&gt; class, inheriting from &lt;code&gt;BSDaddy&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;objc&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;#import&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;BSDaddy.h&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;@interface&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; BSSon&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; : &lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;BSDaddy&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;@end&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;-the-protected&quot;&gt;… the protected…&lt;/h3&gt;
&lt;p&gt;Let’s say, Dad has information it should share with his son, like an address for
instance. Let’s create a new file &lt;code&gt;BSDaddySubclass.h&lt;/code&gt; in which we declared this
kind of stuff.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;objc&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;@interface&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; BSDaddy&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; ()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;@property&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;nonatomic&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;strong&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;NSString&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;protectedAddress;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;- (&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;NSString&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;healthInsuranceId&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;@end&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Please note that I’m using &lt;code&gt;()&lt;/code&gt; instead of something more precise like
&lt;code&gt;(subclass)&lt;/code&gt; as, otherwise, the properties are not auto-synthetized.&lt;/p&gt;
&lt;h3 id=&quot;-and-the-private&quot;&gt;… and the private&lt;/h3&gt;
&lt;p&gt;Here is a basic implementation of Dad, in which we also defined stuff we want to
keep private from Son.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;objc&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;#import&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;BSDaddy.h&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;#import&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;BSDaddySubclass.h&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;@interface&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; BSDaddy&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; ()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;@property&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;weak&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;nonatomic&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;NSString&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;secretSexFantasy;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;- (&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;NSNumber&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;creditCardPinNumber&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;@end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;@implementation&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; BSDaddy&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;- (&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;init&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;   self&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;super&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; init&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;   if&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;      self&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.protectedAddress &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; @&quot;Hill Valley&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;      self&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.secretSexFantasy &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; @&quot;being disguised as an alien&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;   }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;   return&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; self&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;- (&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;NSString&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;introduction&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; { &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; @&quot;Hi! My name is George McFly!&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;; }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;- (&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;NSString&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;healthInsuranceId&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; { &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; @&quot;123456789&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;; }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;- (&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;NSNumber&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;creditCardPinNumber&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; { &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;NSNumber&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; numberWithInteger:1234&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;]; }&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Please note that we reuse &lt;code&gt;()&lt;/code&gt; for the new interface declaration, it will not
conflict with the one in &lt;code&gt;BSDaddySubclass.h&lt;/code&gt;&lt;/p&gt;
&lt;h3 id=&quot;now-lets-implement-son&quot;&gt;Now let’s implement Son&lt;/h3&gt;
&lt;p&gt;Son is a rebel and want to share everything about his dad when he introduces
himself.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;objc&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;#import&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;BSSon.h&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;#import&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;BSDaddySubclass.h&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;@implementation&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; BSSon&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;- (&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;NSString&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;introduction&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;   // Property &apos;secretSexFantasy&apos; not found on object of type &apos;BSSon *&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;   // NSString *myDadSecretFantasy = self.secretSexFantasy;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;   #pragma&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; clang&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; diagnostic&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; push&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;   #pragma&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; clang&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; diagnostic&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; ignored&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;-Wundeclared-selector&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;   NSString&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;myDadSecretFantasy &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; nil&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;   NSNumber&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;creditCardPinNumber &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; nil&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;   if&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; ([&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; respondsToSelector:&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;@selector&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;secretSexFantasy&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)]) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;      myDadSecretFantasy &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; performSelector:&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;@selector&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;secretSexFantasy&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;                                   withObject:nil&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;   }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;   if&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; ([&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; respondsToSelector:&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;@selector&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;creditCardPinNumber&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)]) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;      creditCardPinNumber &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; performSelector:&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;@selector&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;creditCardPinNumber&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;                                    withObject:nil&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;   }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;   #pragma&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; clang&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; diagnostic&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; pop&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;   return&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;NSString&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; stringWithFormat:&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;@&quot;Hi! I&apos;m Marty. My dad says: “&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;%@&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;”. He&apos;ll be mad cause I&apos;m making public that we live in &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;%@&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; and his health insurance ID is &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;%@&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;. He&apos;ll be even madder after I tell you his secret sex fantasy is &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;%@&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;, and that his credit card PIN number is &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;%@&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;.&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, [&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;super&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; introduction&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;], &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.protectedAddress, [&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; healthInsuranceId&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;], myDadSecretFantasy, creditCardPinNumber];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Please note:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;code&gt;BSDaddySubclass.h&lt;/code&gt; is imported.&lt;/li&gt;
&lt;li&gt;The properties and tasks declared in &lt;code&gt;BSDad.m&lt;/code&gt; can’t be used: you will get a
compilation error if you try&lt;/li&gt;
&lt;li&gt;The properties and tasks declared in &lt;code&gt;BSDadSubclass.h&lt;/code&gt; &lt;strong&gt;can&lt;/strong&gt; be used
normally without the need of an extra &lt;code&gt;@synthesize&lt;/code&gt; or &lt;code&gt;@dynamic&lt;/code&gt; for
properties.&lt;/li&gt;
&lt;li&gt;Most importantly, please note that this is just &lt;em&gt;simulated protection&lt;/em&gt;, which
relies on a &lt;strong&gt;convention&lt;/strong&gt;! If another class decides to import
&lt;code&gt;BSDadSubclass.h&lt;/code&gt;, nothing will prevent it to do so and use the protected
methods as public ones. You just need to &lt;em&gt;establish the convention that this
is bad programming&lt;/em&gt; within your team. To make this even clearer, remember as
well that &lt;em&gt;there is no such things as private methods&lt;/em&gt; either. If you know a
private method exists, you can still call it. That’s the power of Objective-C
and remember what Uncle Ben said: “With great power comes great
responsability”!&lt;/li&gt;
&lt;li&gt;Optional: notice also the several &lt;code&gt;#pragma&lt;/code&gt; that will prevent you to get
warnings when trying to perform private selectors in your code. If you need
them, you should be aware maybe you’re doing something nasty.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;This is how George and Marty will introduce themselves:&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;Hello George and Marty&quot; title=&quot;Nasty Marty&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;434&quot; width=&quot;434&quot; height=&quot;704&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Finheritance.fnlUB2aV.png&amp;amp;w=400&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;p&gt;You can find the full source code of this example on &lt;a href=&quot;https://github.com/dirtyhenry/bootstragram-ios&quot;&gt;my iOS Demo
code&lt;/a&gt; on GitHub.&lt;/p&gt;
&lt;p&gt;And again, if you want to address me some feedback or comments, it’s via
&lt;a href=&quot;https://github.com/dirtyhenry/tech-articles/issues&quot; title=&quot;Issues&quot;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;
</content:encoded><category>Objective-C</category><category>iOS</category></item><item><title>How to generate Programming Guides with Appledoc</title><link>https://www.mickf.net/tech/programming-guides-with-appledoc/</link><guid isPermaLink="true">https://www.mickf.net/tech/programming-guides-with-appledoc/</guid><pubDate>Wed, 19 Feb 2014 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;a href=&quot;https://github.com/tomaz/appledoc&quot;&gt;appledoc&lt;/a&gt; is a pretty awesome tool. It’s a command line tool that
generates a very Apple-like documentation for your Objective-C projects. The
documentation is a little short on details and isn’t clear if you can also
create Apple-like Programming Guides or documentation pages decoupled from code.
Well guess what? You can! And with &lt;a href=&quot;https://daringfireball.net/projects/markdown/&quot;&gt;Markdown&lt;/a&gt; support, which makes the
whole thing even more awesome.&lt;/p&gt;
&lt;h2 id=&quot;how-do-you-do-it-then&quot;&gt;How do you do it then?&lt;/h2&gt;
&lt;p&gt;It’s pretty straightforward, you just need to create Markdown files, suffixed
with &lt;code&gt;-template.md&lt;/code&gt; and add a &lt;code&gt;--include&lt;/code&gt; instruction in your appledoc call as
in:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;appledoc ... \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  --include my-first-template.md \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  --include My\ Second-template.md \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  ...&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now, visit your index.html and you’ll get a new links section at the bottom of
the page called &lt;em&gt;Programming Guides&lt;/em&gt;!&lt;/p&gt;
&lt;h2 id=&quot;random-notes&quot;&gt;Random Notes&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;The name of the guide will be the same than the prefix of your file, so feel
free to add spaces in it to have a pretty programming guide filename. (Maybe,
there would be some Jekyll-like metadata stuff support to add to support a
better way to name your programming guide with a spaceless filename)&lt;/li&gt;
&lt;li&gt;Let’s all say a big &lt;em&gt;Thank You&lt;/em&gt; to Tomaz for this awesome tool. If the doc is
light, the length of &lt;a href=&quot;https://github.com/tomaz/appledoc/issues/7&quot;&gt;his&lt;/a&gt;
&lt;a href=&quot;https://github.com/tomaz/appledoc/issues/66&quot;&gt;comments&lt;/a&gt; in
&lt;a href=&quot;https://github.com/tomaz/appledoc/issues/74&quot;&gt;issues&lt;/a&gt; pages are very detailed
and gave me the solution for this problem.&lt;/li&gt;
&lt;/ul&gt;
</content:encoded><category>Objective-C</category><category>Documentation</category><category>iOS</category></item><item><title>Service to Activity Communication With The Android SDK</title><link>https://www.mickf.net/tech/android-service-activity-communication/</link><guid isPermaLink="true">https://www.mickf.net/tech/android-service-activity-communication/</guid><pubDate>Tue, 28 Jan 2014 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;I’m an experienced iOS developer but still consider myself a noob regarding
Android development. Never mind, I still want to share my latest experiment with
the Android SDK: how to run a long operation in the background while still
updating the UI regularly?&lt;/p&gt;
&lt;h2 id=&quot;where-asynctask-wont-do-the-job&quot;&gt;Where AsyncTask won’t do the job…&lt;/h2&gt;
&lt;p&gt;The Android SDK provides a convenient object to perform background operations
that will need to provide a UI feedback: &lt;a href=&quot;https://developer.android.com/reference/android/os/AsyncTask.html&quot; title=&quot;AsyncTask Class API Reference&quot;&gt;&lt;code&gt;AsyncTask&lt;/code&gt;&lt;/a&gt;. But as
&lt;a href=&quot;https://developer.android.com/reference/android/os/AsyncTask.html&quot; title=&quot;AsyncTask Class API Reference&quot;&gt;Android’s documentation&lt;/a&gt; says:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;AsyncTasks should ideally be used for short operations (a few seconds at the
most.)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The question then arises: what should we use when a longer background operation
is needed?&lt;/p&gt;
&lt;h2 id=&quot;well-guess-what-it-depends&quot;&gt;Well, guess what? It depends…&lt;/h2&gt;
&lt;p&gt;Searching for an answer to this question on services like StackOverflow ends up
being more confusing than helpful. &lt;a href=&quot;https://stackoverflow.com/search?q=android+ui+communication+background&quot; title=&quot;Search for &amp;#x27;Android UI Communication Background&amp;#x27; on StackOverflow&quot;&gt;Many questions&lt;/a&gt; are asked in
this area but no clear answer appears. But depending on the specific aspects of
each question, many keywords appear to help getting our quest further:
&lt;code&gt;Services&lt;/code&gt;, &lt;code&gt;Handlers&lt;/code&gt;, etc.&lt;/p&gt;
&lt;h2 id=&quot;lets-give-services-a-try&quot;&gt;Let’s give Services a try&lt;/h2&gt;
&lt;p&gt;Ideally, I wanted to find something similar to the &lt;a href=&quot;https://nshipster.com/key-value-observing/&quot;&gt;KVO&lt;/a&gt; mechanism in iOS.&lt;/p&gt;
&lt;p&gt;I decided to give &lt;code&gt;Services&lt;/code&gt; a try and developed a &lt;a href=&quot;https://en.wikipedia.org/wiki/Proof_of_concept&quot; title=&quot;Proof of Concept&quot;&gt;POC&lt;/a&gt; you can find on
&lt;a href=&quot;https://github.com/dirtyhenry/bootstragram-android&quot; title=&quot;My bootstragram-android repository on GitHub&quot;&gt;my bootstragram-android repository on GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The main reason why I picked &lt;code&gt;Services&lt;/code&gt; over other solutions is that I wanted to
be able to share &lt;em&gt;any kind of objects&lt;/em&gt;, not only &lt;code&gt;Serializable&lt;/code&gt; and &lt;code&gt;Parcelable&lt;/code&gt;
ones. This constraint eliminated a solution based on a
&lt;a href=&quot;https://developer.android.com/reference/android/support/v4/content/LocalBroadcastManager.html&quot; title=&quot;LocalBroadcastManager Class API Reference&quot;&gt;&lt;code&gt;LocalBroadcastManager&lt;/code&gt;&lt;/a&gt; as from my understanding,
objects that can be passed with the &lt;code&gt;Intent&lt;/code&gt; (ie &lt;code&gt;Extra&lt;/code&gt;) have to be
&lt;code&gt;Serializable&lt;/code&gt; or &lt;code&gt;Parcelable&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;My objectives for this POC were:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Create a background operation that will live as long as my app, no less.&lt;/li&gt;
&lt;li&gt;This operation must run continously and must update some kind of state at a
relatively high-frequency.&lt;/li&gt;
&lt;li&gt;The user must be able to get a UI representation of that state without being
blocked on one activiy in particular.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Some notes about it went follow.&lt;/p&gt;
&lt;h3 id=&quot;the-poc-story&quot;&gt;The POC Story&lt;/h3&gt;
&lt;p&gt;The pitch for the POC is as silly as can be. The app will generate in the
background a new hex-string every 2 seconds. It will have to be displayed in a
screen with a new color. Wow! I’m sure this app would be a hit on the Google
Play Store!&lt;/p&gt;
&lt;h3 id=&quot;create-a-service&quot;&gt;Create a Service&lt;/h3&gt;
&lt;p&gt;When you create a &lt;code&gt;Service&lt;/code&gt;, you need to declare it in your app manifest. I made
mine private to my app but it’s not required.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;xml&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#85E89D&quot;&gt;application&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; ...&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;  ....&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;  &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#85E89D&quot;&gt;service&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; android:name&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;.services.RandomEventsService&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;           android:exported&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;false&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; &amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;  &amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:#85E89D&quot;&gt;service&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;  ....&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:#85E89D&quot;&gt;application&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The service itself is a subclass of &lt;a href=&quot;https://developer.android.com/reference/android/app/IntentService.html&quot; title=&quot;IntentService Class API Reference&quot;&gt;&lt;code&gt;IntentService&lt;/code&gt;&lt;/a&gt; (which
provides a convenient &lt;code&gt;onHandleIntent&lt;/code&gt; method to override) doing very simple
things:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;java&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;protected&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; void&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; onHandleIntent&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(Intent intent) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;  while&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    final&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; RandomSingleton singleton &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; RandomSingleton.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;getInstance&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;();&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    singleton.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;increment&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;();&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    long&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; endTime &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; System.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;currentTimeMillis&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;() &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; 1000&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    while&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; (System.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;currentTimeMillis&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;() &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; endTime) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;      synchronized&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        try&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;          wait&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(endTime &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; System.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;currentTimeMillis&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;());&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        } &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;catch&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; (Exception &lt;/span&gt;&lt;span style=&quot;color:#FFAB70&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;          Log.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(TAG, &lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;Couldn&apos;t sleep in peace&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, e);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;      }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;      singleton.&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;increment&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;();&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The service just runs continously and wakes up every 2 seconds to update the
&lt;code&gt;RandomSingleton&lt;/code&gt; singleton object via the &lt;code&gt;increment()&lt;/code&gt; method: objectives 1
and 2 are achieved.&lt;/p&gt;
&lt;p&gt;Here is &lt;a href=&quot;https://github.com/dirtyhenry/bootstragram-android/blob/master/src/com/bootstragram/demo/services/RandomEventsService.java&quot; title=&quot;My RandomEventsService source code&quot;&gt;the full source code&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The service is started via a button in an activity:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;java&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; void&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; onClick&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(View v) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;  Intent intent &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; new&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; Intent&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(ServiceFeedbackActivity.this, RandomEventsService.class);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;  startService&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(intent);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;ui-representation-and-notifications&quot;&gt;UI Representation and Notifications&lt;/h3&gt;
&lt;p&gt;We still have objective 3 to achieve. To do so:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;I made my &lt;code&gt;RandomSingleton&lt;/code&gt; a subclass of
&lt;a href=&quot;https://developer.android.com/reference/android/database/ContentObservable.html&quot; title=&quot;ContentObservable Class API Reference&quot;&gt;&lt;code&gt;ContentObservable&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;I created an activity using a subclass of
&lt;a href=&quot;https://developer.android.com/reference/android/database/ContentObserver.html&quot; title=&quot;ContentObserver Class API Reference&quot;&gt;&lt;code&gt;ContentObserver&lt;/code&gt;&lt;/a&gt;, observing &lt;code&gt;RandomSingleton&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Then I made &lt;code&gt;RandomSingleton&lt;/code&gt; call &lt;code&gt;dispatchChange(...)&lt;/code&gt; at the end of the
&lt;code&gt;increment()&lt;/code&gt; method&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;And that’s it.&lt;/p&gt;
&lt;h3 id=&quot;the-result&quot;&gt;The Result&lt;/h3&gt;
&lt;p&gt;&lt;img alt=&quot;The app updates the UI every 2s accordingly to the new singleton state&quot; title=&quot;The app updates the UI every 2s accordingly to the new singleton state&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;463&quot; width=&quot;463&quot; height=&quot;245&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Fandroid-services-to-activity-communication.CHJ7XyqO.gif&amp;amp;w=512&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;After a frustrating research that had made me more confused than confident about
my problem, I found out that the actual implementation was pretty
straightforward and easier to implement than I expected.&lt;/p&gt;
&lt;p&gt;Nevertheless, I’m still curious of feedbacks you might have about this code and
I invite you to get in touch via &lt;a href=&quot;https://github.com/dirtyhenry/tech-articles/issues&quot; title=&quot;Issues&quot;&gt;GitHub&lt;/a&gt; if you want to engage a
discussion about this page (in particular if you know a better way to do a
Service to UI communication).&lt;/p&gt;
</content:encoded><category>Android</category></item><item><title>Notes from MongoDB for Developers MOOC</title><link>https://www.mickf.net/tech/notes-from-m101/</link><guid isPermaLink="true">https://www.mickf.net/tech/notes-from-m101/</guid><pubDate>Thu, 16 Jan 2014 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;I signed up for the online &lt;a href=&quot;https://education.mongodb.com/&quot;&gt;MongoDB University&lt;/a&gt;
MongoDB for Node.js Developers course aka M101JS. MongoDB sounds like a
promising technology and MongoDB’s courseware uses EdX’s excellent software that
I had already used for the MIT 6.002x Electronics course so I was pretty
confident of the usefulness of all this.&lt;/p&gt;
&lt;div class=&quot;alert alert-info&quot;&gt;
&lt;strong&gt;Work in Progress!&lt;/strong&gt;
I switched from Python to Node.js and started over. I&apos;m currently in:
&lt;ul&gt;
&lt;li&gt;Week 5, “Compound Grouping”.&lt;/li&gt;
&lt;li&gt;Week 6, next video is “Connecting to a Replica Set from the Node.js driver”&lt;/li&gt;
&lt;li&gt;Week 7, next video is “Introduction to Blog”
&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;introduction-to-mongodb&quot;&gt;Introduction to MongoDB&lt;/h2&gt;
&lt;p&gt;MongoDB is a non relational datastore. It stores something close from JSON
called &lt;a href=&quot;http://bsonspec.org&quot;&gt;BSON&lt;/a&gt;, which stands for Binary JSON. It is
schemaless.&lt;/p&gt;
&lt;p&gt;The trade-off to gain scalability and performance is that you have to give up
joins and transactions that relational databases provide.&lt;/p&gt;
&lt;h3 id=&quot;crud&quot;&gt;CRUD&lt;/h3&gt;
&lt;p&gt;In MongoDB vocabulary:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Create is &lt;code&gt;insert&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Read is &lt;code&gt;find&lt;/code&gt; (analogous to &lt;code&gt;count&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Update is &lt;code&gt;update&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Delete is &lt;code&gt;remove&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Table is &lt;code&gt;collection&lt;/code&gt;. &lt;code&gt;_id&lt;/code&gt; is created by default.&lt;/p&gt;
&lt;h2 id=&quot;mongo-shell&quot;&gt;Mongo Shell&lt;/h2&gt;
&lt;p&gt;MongoShell is basically a JavaScript interpreter. You’ll be able to CRUD data
but also run simple JavaScript instructions.&lt;/p&gt;
&lt;p&gt;Features include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Autocompletion via the &lt;code&gt;TAB&lt;/code&gt; key&lt;/li&gt;
&lt;li&gt;Support of &lt;code&gt;.&lt;/code&gt; and &lt;code&gt;[]&lt;/code&gt; notation for JavaScript objects&lt;/li&gt;
&lt;li&gt;Support of BSON datatypes&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Connextion to the shell: mongo&lt;/p&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&amp;gt; show dbs&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&amp;gt; use mydb&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&amp;gt; for (i = 0; i &amp;lt; 3; i++) print(&quot;Hello World&quot;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;Hello World&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;Hello World&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;Hello World&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&amp;gt; help&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&amp;gt; obj = { &quot;a&quot; : 1, &quot;b&quot;: &quot;hello&quot;, &quot;c&quot;: [&quot;apple&quot;, &quot;tomatoes&quot;]}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&amp;gt; NumberInt(1)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&amp;gt; NumberLong(1)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&amp;gt; new Date()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&amp;gt; exit&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;query-language&quot;&gt;Query Language&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;_id&lt;/code&gt; is returned by default with queries. &lt;code&gt;pretty()&lt;/code&gt; helps formatting answers
in a readable way. The second argument tells MongoDB the name of the fields we
want to fetch.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&amp;gt; db.collection.findOne()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&amp;gt; db.collection.findOne({&quot;name&quot;: &quot;Jones&quot;})&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&amp;gt; db.collection.findOne({&quot;name&quot;: &quot;Jones&quot;}, {&quot;name&quot;: true, &quot;_id&quot;: false})&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&amp;gt; db.scores.find( { type: &quot;essay&quot;, score: 50 }, { student: true, _id: false } );&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;query-operators&quot;&gt;Query operators&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;{ $gt : 95 }&lt;/code&gt;: greather than (&amp;gt;, NOT &amp;gt;=)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;$gte&lt;/code&gt;, &lt;code&gt;$lt&lt;/code&gt;, &lt;code&gt;$lte&lt;/code&gt; are &lt;code&gt;&amp;gt;=&lt;/code&gt;, &lt;code&gt;&amp;lt;&lt;/code&gt; and &lt;code&gt;&amp;lt;=&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;$exists&lt;/code&gt;: &lt;code&gt;true&lt;/code&gt;/&lt;code&gt;false&lt;/code&gt; filter documents where the specified field exists or
not&lt;/li&gt;
&lt;li&gt;&lt;code&gt;$type&lt;/code&gt; (example: 2 for String, cf. &lt;a href=&quot;http://bsonspec.org&quot;&gt;BSON specifications&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;$regex&lt;/code&gt; (example: “^A$”)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&amp;gt; db.scores.find( { type: { $exists: true } } );&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;prefix-query-operators&quot;&gt;Prefix Query operators&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;$or&lt;/code&gt; + array&lt;/li&gt;
&lt;li&gt;&lt;code&gt;$and&lt;/code&gt; + array (not as useful)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Tricky : db.scores.find( { score : { $gt : 50 }, score : { $lt : 60 } } ); #
only less than 60 are returned. Beware that $and is not used, but the 2nd score
field value is replacing the 1st score field value (this is kind of a normal
dictionary behavior).&lt;/p&gt;
&lt;h3 id=&quot;querying-inside-arrays&quot;&gt;Querying inside arrays&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Polymorphism&lt;/li&gt;
&lt;li&gt;&lt;code&gt;$all : [ elem1, elem2 ]&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;$in : [ enum1, enum2 ]&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;cursor-operations&quot;&gt;Cursor Operations&lt;/h3&gt;
&lt;p&gt;Processed on the server-side:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;sort&lt;/li&gt;
&lt;li&gt;limit&lt;/li&gt;
&lt;li&gt;skip&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;update-options&quot;&gt;Update options&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;set, unset&lt;/li&gt;
&lt;li&gt;push, pop, pull, pushAll, pullAll, addToSet&lt;/li&gt;
&lt;li&gt;upsert, multi&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;error-feedback&quot;&gt;Error feedback&lt;/h3&gt;
&lt;p&gt;db.runCommand( { getLastError: 1 } )&lt;/p&gt;
&lt;h3 id=&quot;dot-notation&quot;&gt;Dot notation&lt;/h3&gt;
&lt;p&gt;Don’t forget the double-quotes!&lt;/p&gt;
&lt;h2 id=&quot;performance&quot;&gt;Performance&lt;/h2&gt;
&lt;h3 id=&quot;basic-usage-of-indexes&quot;&gt;Basic Usage of Indexes&lt;/h3&gt;
&lt;h4 id=&quot;creating-an-index&quot;&gt;Creating an index&lt;/h4&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;db.collection.ensureIndex( { my_key: 1 }, opts ) # 1 is ascending, -1 is descinding&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;opts&lt;/code&gt; can be:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;missing&lt;/li&gt;
&lt;li&gt;&lt;code&gt;{ unique: true }&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;{ unique: true, dropDups: true }&lt;/code&gt; (RISKY!)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;{ sparse: true }&lt;/code&gt; (RISKY!)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Indexes can be created in the background.&lt;/p&gt;
&lt;h4 id=&quot;finding-existing-indexex&quot;&gt;Finding existing indexex&lt;/h4&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;db.system.indexes.find()&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;or&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;db.collection.getIndexes()&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;dropping-an-index&quot;&gt;Dropping an index&lt;/h4&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;db.collection.dropIndex( { my_key: 1 } )&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;fine-tuning&quot;&gt;Fine Tuning&lt;/h3&gt;
&lt;h4 id=&quot;explain&quot;&gt;Explain&lt;/h4&gt;
&lt;p&gt;Adding &lt;code&gt;.explain()&lt;/code&gt; on a query produces a document explaining how the request
was executed. Some of the most relevant information of this document are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;cursor&lt;/code&gt;: it tells you if an index was used (&lt;code&gt;BtreeCursor&lt;/code&gt;) or not
(&lt;code&gt;BasicCursor&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;millis&lt;/code&gt;: it tells you how long the request took in milliseconds&lt;/li&gt;
&lt;li&gt;&lt;code&gt;indexOnly&lt;/code&gt;: it tells you if the index was enough to return the result of the
request&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;size-of-an-index&quot;&gt;Size of an index&lt;/h4&gt;
&lt;p&gt;Calling &lt;code&gt;.stats()&lt;/code&gt; on a collection gives you a document with some interesting
information. One particularly important information is the size of your index
(you want your index to fit inside the memory) that you can also get directly
via &lt;code&gt;.totalIndexSize()&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&quot;profiling&quot;&gt;Profiling&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;http://docs.mongodb.org/manual/reference/method/db.setProfilingLevel/&quot;&gt;http://docs.mongodb.org/manual/reference/method/db.setProfilingLevel/&lt;/a&gt;&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;db.system.profile.find({millis: { $gt: 1000 }}).sort({ts: -1})&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;a href=&quot;http://docs.mongodb.org/manual/reference/program/mongotop/&quot;&gt;http://docs.mongodb.org/manual/reference/program/mongotop/&lt;/a&gt;&lt;/p&gt;
</content:encoded><category>MongoDB</category></item><item><title>Setting up a VPN Server with Mac OS X Mavericks</title><link>https://www.mickf.net/tech/setting-up-a-vpn-server-on-mavericks/</link><guid isPermaLink="true">https://www.mickf.net/tech/setting-up-a-vpn-server-on-mavericks/</guid><pubDate>Wed, 30 Oct 2013 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;My company needed a way for people to access a local network server from home.
The solution was to set up a VPN. That was fun and not that hard but I still ran
into a couple of issues.&lt;/p&gt;
&lt;h2 id=&quot;why-a-vpn&quot;&gt;Why a VPN?&lt;/h2&gt;
&lt;p&gt;In case you’re still wondering what a VPN is at this point, let me explain.&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;Without a VPN&quot; title=&quot;Without a VPN&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;772&quot; width=&quot;772&quot; height=&quot;293&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Fvpn-explain-1.CMXo7nwM.png&amp;amp;w=800&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;p&gt;The typical usage of a VPN in a professional context is to create a bridge
between your enterprise network and the rest of the Internet. And if the bridge
can be secured, it’s better.&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;With a VPN&quot; title=&quot;With a VPN&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;820&quot; width=&quot;820&quot; height=&quot;400&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Fvpn-explain-2.109S_RDi.png&amp;amp;w=800&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;h2 id=&quot;os-x-serverapp&quot;&gt;OS X Server.app&lt;/h2&gt;
&lt;p&gt;Our local server is a Mac Mini that was running Mountain Lion at the time. After
some research, I realized the easiest solution to set up the VPN access was to
use the OS X Server app (17,99€), which required the latest version of OS X
&lt;em&gt;aka&lt;/em&gt; Mavericks.&lt;/p&gt;
&lt;p&gt;After the app was installed, I was pleasantly surprised that the app included a
step-by-step tutorial to setup its VPN feature. However, here are some tips that
could help:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;make sure to create “local network users” and not “local users”&lt;/li&gt;
&lt;li&gt;make sure &lt;strong&gt;not&lt;/strong&gt; to create a local directory for your VPN users&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you run into errors such as:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;DSAuth plugin: MPPE key required, but its retrieval failed.&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;or:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;CHAP peer authentication failed for clinteastwood&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;you may not have followed these two guidelines and I would invite you to watch
&lt;a href=&quot;http://www.youtube.com/watch?v=gG8HcsQuyjI&quot;&gt;this very helpful video&lt;/a&gt; as support.&lt;/p&gt;
&lt;h2 id=&quot;configuring-your-set-top-box&quot;&gt;Configuring your set-top box&lt;/h2&gt;
&lt;h3 id=&quot;port-forwarding&quot;&gt;Port Forwarding&lt;/h3&gt;
&lt;p&gt;The OS X Server.app’s tutorial is pretty clear about what you should do with
your Internet provider box: ports 500, 1701 and 4500 should be redirected to
your server.&lt;/p&gt;
&lt;p&gt;With my Orange box though, I ran into a problem: the port 1701 could not be
redirected at all. The message in the admin console was just: “reserved port”
and I found no way to change that.&lt;/p&gt;
&lt;p&gt;In my case, the somewhat satisfactory solution was to configure the VPN server
for both L2TP and PPTP protocols.&lt;/p&gt;
&lt;p&gt;PPTP is less secured than L2TP, but it will do the job.&lt;/p&gt;
&lt;h3 id=&quot;local-dns&quot;&gt;Local DNS&lt;/h3&gt;
&lt;p&gt;The default for OS X Server’s VPN access is to use &lt;code&gt;192.168.1.1&lt;/code&gt; as the local
DNS server, using a &lt;code&gt;.home&lt;/code&gt; domain to address the different machines of your
LAN.&lt;/p&gt;
&lt;p&gt;If you want to use names for your machines instead of their local IP adresses,
make sure that you assigned names for your different machines in your local
network on this &lt;code&gt;192.168.1.1&lt;/code&gt; machine.&lt;/p&gt;
&lt;p&gt;In addition, you should probably assign static local IP adresses to your
different machines as well.&lt;/p&gt;
&lt;p&gt;Be aware too, that you should avoid creating conflicts between the VPN network
and a typical home network for instance, where all local IPs could start by
&lt;code&gt;192.168.1.***&lt;/code&gt;. Perhaps creating a VPN with IP like &lt;code&gt;192.168.11.***&lt;/code&gt; for
instance could be a good idea.&lt;/p&gt;
&lt;h3 id=&quot;dynamic-ip&quot;&gt;Dynamic IP&lt;/h3&gt;
&lt;p&gt;In my case, Orange wouldn’t let me have a fixed IP address for my box. I
considered creating an account with a dynamic DNS service provider but I thought
it was a little overpriced and probably not necessary.&lt;/p&gt;
&lt;p&gt;Eventually, I realized that my registrar, &lt;a href=&quot;http://www.gandi.net&quot;&gt;Gandi&lt;/a&gt;, provided an XML-RPC
based API that could modify your DNS records. Then I found the script I needed:
&lt;a href=&quot;https://github.com/Chralu/gandyn&quot;&gt;gandyn&lt;/a&gt; (python 3) that I just installed on my Mac, and scheduled to
run every 5 minutes via &lt;code&gt;launchctl&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;So far, so good. The VPN is up and working correctly. Once connected, I can
access any machines of the LAN via a &lt;code&gt;machine.home&lt;/code&gt; address in my browser. I’ll
try to open a ticket to Orange support so that they may open the 1701 port of
their boxes so that I can used the more secured L2TP protocol in the future.&lt;/p&gt;
&lt;p&gt;Feel free to submit any addition/correction/remark on this post &lt;a href=&quot;https://github.com/dirtyhenry/tech-articles/issues&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;
</content:encoded><category>Virtual Private Network</category><category>macOS</category></item><item><title>Code Reviews, a Checklist</title><link>https://www.mickf.net/tech/code-review-checklist/</link><guid isPermaLink="true">https://www.mickf.net/tech/code-review-checklist/</guid><pubDate>Thu, 01 Aug 2013 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Reviewing code from fellow developers should be considered a best practice.
While its main goal is to make sure your teammate didn’t lose track of what a
good software developer should do, it can also help the reviewer extend his
knowledge of a project and get inspired by other’s code.&lt;/p&gt;
&lt;h2 id=&quot;5-golden-rules&quot;&gt;5 Golden Rules&lt;/h2&gt;
&lt;p&gt;Things to have in mind/check when you review code include these 5 golden rules:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The code compiles on the reviewer’s environment without warnings and tests
are not broken.&lt;/li&gt;
&lt;li&gt;The new code implements the bug fix/feature it was supposed to.&lt;/li&gt;
&lt;li&gt;The code remains &lt;a href=&quot;http://en.wikipedia.org/wiki/Don%27t_repeat_yourself&quot;&gt;DRY&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Things are kept small and simple, with a clear separation of concerns: &lt;a href=&quot;http://en.wikipedia.org/wiki/Single_responsibility_principle&quot;&gt;“each
class should do only one thing, and do that one thing well”&lt;/a&gt;. If you don’t
get what the new code is doing, something’s wrong.&lt;/li&gt;
&lt;li&gt;The new code is tested.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;how-to-review-code&quot;&gt;How to review code?&lt;/h2&gt;
&lt;p&gt;My team is using &lt;a href=&quot;https://github.com/nvie/gitflow&quot;&gt;GitFlow&lt;/a&gt; on our own Git servers (i mean “no GitHub”, so no
“pull request”). My way to actually review code is the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Checkout the branch to review&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Identify what is the delta between this branch and its base branch (let’s say
&lt;code&gt;develop&lt;/code&gt;)&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;First, get the base revision tag:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;git merge-base branch-to-review develop&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;ee682bdaf3a578a8de647006b500c87ca72c7ffc&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Then, use your diff tool to visualize what changed (i personally use
&lt;a href=&quot;http://www.kaleidoscopeapp.com/&quot;&gt;Kaleidoscope&lt;/a&gt;)&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;git difftool ee682bdaf3a578a8de647006b500c87ca72c7ffc HEAD&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Give the review developer some feedback, ask questions about what is not clear&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If necessary, fix the code by yourself if changes are fast to implement
(letting the other know what you’re doing) or in pair programming with the
reviewee if things are heavier&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Merge the code on the base branch&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Deploy on your staging environment to make sure things are ok&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Clean up Git branches behind you&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;shell&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;git&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; branch&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; -d&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; branch-to-review&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;git&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; push&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; origin&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; :branch-to-review&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;a-note-about-testing&quot;&gt;A note about testing&lt;/h2&gt;
&lt;p&gt;Reviewing code that doesn’t include tests can be disappointing for a reviewer
and adding some tests after an implementation feels like cheating. Here is a
quote from Daniel Eggert - from the excellent &lt;a href=&quot;http://www.objc.io/issue-1/testing-view-controllers.html&quot;&gt;objc.io&lt;/a&gt; - that both reviewers
and reviewees should have in mind when reviewing/developing:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Tests should help us speed up development and make things more fun. &lt;code&gt;[...]&lt;/code&gt;
Generally, if you find something difficult to test, that’s a hint that your
design may be broken and that you should refactor some of it. &lt;code&gt;[...]&lt;/code&gt; You’ll
get diminishing returns as you add more tests. First and foremost, add simple
tests. Branch into more sophisticated territory as you start to feel
comfortable with it.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id=&quot;links&quot;&gt;Links&lt;/h2&gt;
&lt;p&gt;Other resources discuss the subject:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://lifehacker.com/all-code-is-bad-so-dont-stress-if-yours-sucks-1569821801&quot;&gt;All Code Is Bad, So Don’t Stress If Yours Sucks&lt;/a&gt; (added in May 2014)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;I’ll try to add some examples and additions to this page as I process code
reviews in the future. Again, feel free to get in touch to provide some feedback
and as &lt;a href=&quot;https://github.com/dirtyhenry/tech-articles/blob/master/_posts/2013-08-01-code-review-checklist.md&quot;&gt;this page is open source and available on GitHub&lt;/a&gt;, pull requests are
welcome. I’ll review them with a great pleasure.&lt;/p&gt;
</content:encoded><category>Code review</category></item><item><title>7 tips to create a safe and consistent backup strategy as a Mac user</title><link>https://www.mickf.net/tech/backup-tips/</link><guid isPermaLink="true">https://www.mickf.net/tech/backup-tips/</guid><pubDate>Sun, 17 Mar 2013 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;I’ve recently found myself in a very uncomfortable situation: my backup external
hard drive (HDD) failed! I’ve suddenly realized my hot tea-cup was really close
to my MacBook Pro. I drank my tea, put my laptop in a safe and started thinking
about my backup strategy. Was it safe enough? I did a bit of research on the
Internet and here are the results: 7 tips to create a safe and consistent backup
strategy as a Mac user.&lt;/p&gt;
&lt;h2 id=&quot;1-start-backing-up-with-time-machine&quot;&gt;1. Start backing up with Time Machine&lt;/h2&gt;
&lt;p&gt;Time Machine is just great and is way more than just a backup of your data.
Introduced in the Leopard version of Mac OS X, Time Machine is a great way to 1)
back up your Mac on an external HDD and 2) keep an history of your file system.
It is fast to set up, convenient to use, smart when dealing with storage space.
If you’re a Mac user and don’t use Time Machine, just start using it right now.
Get an external HDD with a little bigger storage than your computer’s and go
ahead (for instance, I have a 320 Go HDD on my laptop and use a 500 Go HDD for
Time Machine).&lt;/p&gt;
&lt;h2 id=&quot;2-and-back-up-in-the-cloud-as-well&quot;&gt;2. And back up in the cloud as well&lt;/h2&gt;
&lt;p&gt;If you’re a nomad user, you want to have your main Time Machine HDD with you all
the time. What happens if your bag gets stolen? A Time Machine backup is not
enough. You want another backup that you’re gonna keep away from your laptop
most of the time, and that you’ll never carry away with both your computer and
your primary Time Machine HDD.&lt;/p&gt;
&lt;p&gt;A few years ago, I gave different options a try:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;switching between 2 Time Machine HDD: that was not a good solution. It was
less convenient (switching and manually tell Time Machine you want to switch)
and i ended up having two Time Machine partially comprehensive backups rather
than one consistent as-comprehensive-as-can-be backup&lt;/li&gt;
&lt;li&gt;copying my TimeMachine backup to another hard drive every week or so: it
wasn’t super convenient. Based on &lt;a href=&quot;https://daringfireball.net/2010/03/ode_to_diskwarrior_superduper_dropbox&quot;&gt;Daring Fireball’s advices&lt;/a&gt;, I used
&lt;a href=&quot;https://www.shirt-pocket.com/SuperDuper/SuperDuperDescription.html&quot;&gt;SuperDuper!&lt;/a&gt; to do that, but the problem is that its incremental backups
algorithm couldn’t keep up with HDD the same size (a simple 2-pass algorithm:
remove what’s gone then add what’s new would have solved this problem but the
SuperDuper support people said it wasn’t their top priority)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Now, I’m using &lt;a href=&quot;https://www.backblaze.com/&quot;&gt;Backblaze&lt;/a&gt;’s cloud backup solution to keep a remote backup of
my HDD. Of course, this solution has some major drawbacks:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;it’s using a lot of your upload bandwidth&lt;/li&gt;
&lt;li&gt;the initial backup can take several months&lt;/li&gt;
&lt;li&gt;you need to hope Backblaze will still be around when your HDD fails&lt;/li&gt;
&lt;li&gt;it doesn’t keep an history of your files&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;But it also has big advantages:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;both upfront cost and long run cost are probably cheaper than investing in an
external HDD&lt;/li&gt;
&lt;li&gt;it’s safer cause it’s never at the same location than your primary HDD&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;3-create-a-media-center-hdd&quot;&gt;3. Create a Media Center HDD!&lt;/h2&gt;
&lt;p&gt;With my laptop, I have a recurring problem: a lack of space in the internal HDD.
To solve this permanently, I now try to keep my media files apart: music, photos
and movies are on a dedicated external HDD. This strategy has many good points:
you have a lot of space on your internal HDD (which is very convenient when you
use your computer in a professional context), you have a mediacenter HDD you can
bring to your friends’ houses or that you can plug in a TV set, you can use it
with a mediacenter server… It’s very useful.&lt;/p&gt;
&lt;p&gt;One disadvantage of this strategy is when your iTunes library is on this
external HDD and you want to synchronize your iOS devices when your mediacenter
HDD is not around. This requires a lot of manual work (sorting files you want to
have in a minimized iTunes library and files you want to have in the extensive
iTunes library). iOS 5 might help with this very soon.&lt;/p&gt;
&lt;h2 id=&quot;4-and-back-up-this-media-center-hdd&quot;&gt;4. And back up this Media Center HDD!&lt;/h2&gt;
&lt;p&gt;Now, what if this HDD fails? That’s right, here comes Backblaze again. That’s
your 3rd backup so far. You may think that’s a lot but if something bad happens,
you’ll be glad for the little extra-money you’ll have spent on those external
HDD.&lt;/p&gt;
&lt;h2 id=&quot;5-forget-cd-and-dvd&quot;&gt;5. Forget CD and DVD&lt;/h2&gt;
&lt;p&gt;CD and DVD backups belong to ancient times. You don’t want to do that anymore.
They’re fragile, require a lot of work to keep track of what file’s on which
disk. Imagine you backup these files you cherish on DVD. If your primary files
get corrupted for some reason, how will you remember where you stored it? How
can you be sure the DVD hasn’t quietly been damaged and became unreadable? Of
course, HDD fail too but when they fail, they’re not quiet. They let you know
they died. HDD are a bit over-dramatic but you should be grateful they are.&lt;/p&gt;
&lt;h2 id=&quot;6-think-of-what-youre-backing-up&quot;&gt;6. Think of what you’re backing up&lt;/h2&gt;
&lt;p&gt;I know storage is cheap. I know people can turn sentimental. But do you really
need to backup this animated GIF image that you thought was funny back in 2003?
Delete it. Don’t feel sad of the lack of backup. Keep on your HDD only the
things that deserve to be backed up.&lt;/p&gt;
&lt;h2 id=&quot;7-and-one-last-tiny-usb-key-backup-for-the-road&quot;&gt;7. And one last tiny USB key backup for the road&lt;/h2&gt;
&lt;p&gt;On the opposite, some files are VERY important and you really don’t want to lose
them or you want them with you all the time. Just get a USB key and &lt;a href=&quot;https://support.apple.com/fr-fr/guide/disk-utility/dskutl35612/mac&quot;&gt;build a
safe encrypted backup&lt;/a&gt; of files that really matter: password files, bank
accounts files, critical professional documents…&lt;/p&gt;
&lt;p&gt;Now I think you can feel safe about your data.&lt;/p&gt;
&lt;h2 id=&quot;additional-links&quot;&gt;Additional links:&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://www.macgeneration.com/unes/voir/130252/un-guide-de-la-sauvegarde&quot;&gt;a backup strategy (in french) by MacGeneration.com&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://web.archive.org/web/20130104061728/http://www.emptyage.com/post/28679875595/yes-i-was-hacked-hard&quot;&gt;this alarming post&lt;/a&gt; is another proof that backing up is very important.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://marco.org/2012/08/04/mat-hacked&quot;&gt;Marco Ament’s comments&lt;/a&gt; are also very valuable.&lt;/li&gt;
&lt;/ul&gt;
</content:encoded><category>macOS</category><category>Backup</category></item><item><title>Bookmarklets for Jira OnDemand</title><link>https://www.mickf.net/tech/making-scrum-cards-from-jira-with-jquery-and-css/</link><guid isPermaLink="true">https://www.mickf.net/tech/making-scrum-cards-from-jira-with-jquery-and-css/</guid><pubDate>Fri, 04 Jan 2013 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Sometimes you run out of Post-Its. Shit happens. Let’s keep the task board busy
anyway…&lt;/p&gt;
&lt;p&gt;It happened to me in real-life. We just agreed on our Sprint backlog and are
willing to display it proudly on our walls but… there’s no Post-Its left.&lt;/p&gt;
&lt;p&gt;If you’re using OnDemand Jira, here is an option to help you.&lt;/p&gt;
&lt;h2 id=&quot;the-magic-of-jquery-and-css&quot;&gt;The Magic of jQuery and CSS&lt;/h2&gt;
&lt;p&gt;Click &lt;a href=&quot;https://dirtyhenry.github.io/jira-to-agile-cards/&quot;&gt;here&lt;/a&gt; to access the
two bookmarklets I created for OnDemand Jira.&lt;/p&gt;
&lt;p&gt;⚠️ &lt;strong&gt;WTF?!&lt;/strong&gt; &lt;a href=&quot;https://en.wikipedia.org/wiki/Bookmarklet&quot;&gt;What’s a bookmarklet?!&lt;/a&gt;&lt;/p&gt;
&lt;h3 id=&quot;the-post-it-bookmarklet&quot;&gt;The Post-It Bookmarklet&lt;/h3&gt;
&lt;p&gt;Head on your OnDemand Jira instance, and choose a filter view. Click on the
&lt;code&gt;Post-It&lt;/code&gt; bookmarklet. Tada!&lt;/p&gt;
&lt;p&gt;You get a printable page that you can print, cut and paste on your task board!&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/scrum_board.png&quot; alt=&quot;A scrum board full of cards&quot; title=&quot;The beautiful final result&quot;&gt;&lt;/p&gt;
&lt;h3 id=&quot;the-burndown-chart-bookmarklet&quot;&gt;The Burndown Chart Bookmarklet&lt;/h3&gt;
&lt;p&gt;Refresh your page to get the usual filter view and click on the &lt;code&gt;Burndown Chart&lt;/code&gt;
bookmarklet. Depending on your issues’ statuses, you’re informed of how much is
done compared to your sprint overall point amount. (To work properly, the filter
view must show the optional &lt;code&gt;Story Points&lt;/code&gt; column).&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;Screenshot of the alert you get&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;534&quot; width=&quot;534&quot; height=&quot;267&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Fsprint-points.B3vjvP3q.png&amp;amp;w=512&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;h2 id=&quot;troubleshooting&quot;&gt;Troubleshooting&lt;/h2&gt;
&lt;p&gt;If the “tada” moment is more of a “nothing happened” moment, try to get some
context and yell at me
&lt;a href=&quot;https://github.com/dirtyhenry/jira-to-agile-cards/issues&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Full disclosure: other solutions could be:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://marketplace.atlassian.com/plugins/com.spartez.scrumprint.scrumplugin&quot;&gt;Agile Cards for JIRA plugin by Spartez&lt;/a&gt;
but you won’t be able to get it if you run the OnDemand version of Jira&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/jhollingworth/jira-cards&quot;&gt;This open-source Ruby gem&lt;/a&gt; by
jhollingworth&lt;/li&gt;
&lt;/ul&gt;
</content:encoded><category>Jira</category><category>Bookmarklet</category><category>jQuery</category><category>Scrum</category></item><item><title>Notes from Paris Hacker Meetup #4</title><link>https://www.mickf.net/tech/notes-from-paris-hacker-meetup-4/</link><guid isPermaLink="true">https://www.mickf.net/tech/notes-from-paris-hacker-meetup-4/</guid><pubDate>Mon, 02 Apr 2012 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Here are some random notes from the &lt;a href=&quot;https://www.meetup.com/datachaindc/events/53314342/&quot;&gt;Paris Hacker Meetup #4&lt;/a&gt;, hosted in
Joshfire’s great hall, a couple of weeks ago.&lt;/p&gt;
&lt;p&gt;The first talk was from &lt;a href=&quot;https://twitter.com/nitot&quot;&gt;Tristan Nitot&lt;/a&gt;, about the relevance of Mozilla
in the web today. Mozilla’s point of view is pretty straightforward: the web
needs a major non-profit actor to balance Apple/Google/Microsoft’s leadership.
Fair enough. Although I left Firefox for Google Chrome about two years ago, I
100% agree with this and keep an eye on Firefox’s new releases.&lt;/p&gt;
&lt;p&gt;Nitot also introduced and demoed &lt;a href=&quot;https://wiki.mozilla.org/B2G&quot;&gt;Mozilla’s Boot to Gecko project&lt;/a&gt;. I’m
afraid Mozilla is kind of late to give the mobile road a ride. If Nitot
mentioned a great interest from manufacturers and operators about this project
(the project’s homepage specifically mentioning “Customization for OEMs &amp;amp;
Operators”), he didn’t mention what would be the interest/difference from
potential end users. As a matter of fact, I see OEMs &amp;amp; operators as the evil
actors in the mobile world (all these shitty app layers that most non-hackers
users can’t get rid off) more than Apple or Google can be.&lt;/p&gt;
&lt;p&gt;Next was &lt;a href=&quot;https://twitter.com/michelbartz&quot;&gt;Michel Bartz&lt;/a&gt; for a talk about his high-traffic web experience.
The talk was both super interesting and entertaining: thumbs up. I had heard the
name of most of the mentioned tools but have never used them. So although I
can’t give valuable comments of these products, here’s the list in case it might
help somebody and for personal bookmarking:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://redis.io/&quot;&gt;Redis&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://nodejs.org/&quot;&gt;node.js&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.lighttpd.net/&quot;&gt;Lighttpd&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://nginx.org/&quot;&gt;nginx&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.heroku.com/&quot;&gt;heroku&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Last but not least, Sacha Greif introduced his really interesting &lt;a href=&quot;https://sachagreif.com&quot;&gt;&lt;em&gt;Step by Step
UI Design&lt;/em&gt; eBook&lt;/a&gt;, an eBook explaining how to design a UI, step by
step… Just realizing the title of the eBook is really good.&lt;/p&gt;
&lt;p&gt;Random list of things mentioned during the event :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://news.ycombinator.com/&quot;&gt;Hacker News&lt;/a&gt;: i was too ashamed to raise my
hand during the event but I had never heard of this site, shame on me, it’s
pretty cool&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://shop.oreilly.com/product/0636920018483.do&quot;&gt;&lt;em&gt;Machine Learning for Hackers&lt;/em&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://tauday.com&quot;&gt;The Tau Manifesto&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</content:encoded><category>Conference</category></item><item><title>Debugging Symbolic Links on iOS</title><link>https://www.mickf.net/tech/debugging-ios-symbolic-links/</link><guid isPermaLink="true">https://www.mickf.net/tech/debugging-ios-symbolic-links/</guid><description>Introducing a tool that will visually inspect the state of an iOS app filesystem.</description><pubDate>Tue, 20 Mar 2012 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Symbolic links are one of my favorite pragmatic best practice to manage a file
system. Last week, I had a bug to fix in an iOS app. Soon enough, symbolic links
became my number one suspect for the case. My problem was that Organizer has a
poor support of symbolic links and it’s not very helpful when you want to check
symbolic links targets on a full app file system.&lt;/p&gt;
&lt;p&gt;I had to develop some file system inspector code to help me debug the app and
this is what I want to share here. Before diving into the details, however, I
must emphasize a crucial lesson learned during the bug-fixing process:&lt;/p&gt;
&lt;p&gt;⚠️ Avoid Absolute Target Paths for Symbolic Links:&lt;/p&gt;
&lt;p&gt;In the intricate dance of app updates on the App Store, relying on absolute
target paths for symbolic links can lead to unexpected consequences. Your app’s
file system might waltz into a different home directory with each update,
causing potential chaos. As a precautionary measure, opt for relative paths to
ensure a smoother transition during updates.&lt;/p&gt;
&lt;p&gt;Anyway, I’ve created &lt;a href=&quot;https://github.com/dirtyhenry/swift-blocks&quot;&gt;a &lt;code&gt;FileSystemExplorer&lt;/code&gt; tool&lt;/a&gt;, that will help you
generate the following kind of output when you run it inside your app.&lt;/p&gt;
&lt;p&gt;Download &lt;code&gt;FileSystemExplorer&lt;/code&gt; here:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/dirtyhenry/swift-blocks/blob/main/Sources/ObjectiveBlocks/public/FileSystemExplorer.h&quot;&gt;&lt;code&gt;FileSystemExplorer.h&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/dirtyhenry/swift-blocks/blob/main/Sources/ObjectiveBlocks/FileSystemExplorer.m&quot;&gt;&lt;code&gt;FileSystemExplorer.m&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Notice the &lt;code&gt;---&amp;gt;&lt;/code&gt; and &lt;code&gt;-x-&amp;gt;&lt;/code&gt; arrows which might help you determine if items are
symbolic links and whether the file they target still exist or not. Please leave
a message if you found this bit of code helpful!&lt;/p&gt;
&lt;p&gt;Typical use case would probably to run &lt;code&gt;[FileSystemExplorer exploreFileSystem];&lt;/code&gt;
from your app’s delegate’s &lt;code&gt;application:didFinishLaunchingWithOptions:&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;|- Documents&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;|- help.html&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;   |- Archives&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;      |- 1321890697466 -x-&amp;gt; 1328706604700&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;      |- 1321890697467 ---&amp;gt; 1328706604701&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;      |- 1328697746363&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;         |- images&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;            |- screenshot.png&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;            |- icon.png&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;      |- 1328706604701&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;         |- export.xml&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;         |- html&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;            |- help.html&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;            |- index.html&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;|- MyApp.app&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;   |- etc&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;|- Library&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;   |- Caches&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;      |- com.mycompany.myapp&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;         |- Cache.db&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;   |- Preferences&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;      |- .GlobalPreferences.plist -x-&amp;gt; /Users/user/.../Library/Preferences/.GlobalPreferences.plist&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;      |- com.apple.PeoplePicker.plist ---&amp;gt; /Users/user/.../Library/Preferences/com.apple.PeoplePicker.plist&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;      |- com.mycompany.myapp.plist&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;|- tmp&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
</content:encoded><category>iOS</category><category>Xcode</category></item><item><title>Troubleshooting upgrading Ubuntu Server from Maverick to Natty</title><link>https://www.mickf.net/tech/troubleshooting-ubuntu-server-upgrade/</link><guid isPermaLink="true">https://www.mickf.net/tech/troubleshooting-ubuntu-server-upgrade/</guid><pubDate>Mon, 30 Jan 2012 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;This last weekend, I attempted to upgrade my &lt;a href=&quot;https://www.online.net/&quot;&gt;Dedibox&lt;/a&gt; running Ubuntu Server
from Maverick Meerkat (10.10) to Natty Narwhal (11.04). Initially, the
installation seemed successful: no error messages, a quick and straightforward
process. Then came the required reboot.&lt;/p&gt;
&lt;p&gt;Once the server restarted, nothing worked, including &lt;code&gt;ping&lt;/code&gt;, &lt;code&gt;ssh&lt;/code&gt;, and all
hosted websites.&lt;/p&gt;
&lt;p&gt;It took me a couple of hours to fix the server and get everything running again.
Here is what I did.&lt;/p&gt;
&lt;p&gt;I first found &lt;a href=&quot;https://web.archive.org/web/20110314143946/http://eyes.neuneuil.com/index.php/2010/01/31/187-dedibox-ne-boote-plus-suite-a-upgrade-kernel&quot;&gt;this URL&lt;/a&gt;, which provided the initial steps of the
process, but it didn’t work for me just yet:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sh&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;sudo&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; mkdir&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; /mnt&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; /md1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;sudo&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; mount&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; /dev/md1&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; /mnt/md1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;sudo&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; mount&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; /dev/md0&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; /mnt/md1/boot&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;sudo&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; chroot&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; /mnt/md1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;update-grub&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Nevertheless, it helped me identify that grub was indeed the problem. I then
followed &lt;a href=&quot;https://help.ubuntu.com/community/Grub2?action=recall&amp;amp;rev=199#ChRoot&quot;&gt;these guidelines&lt;/a&gt; from Dedibox’s rescue mode. A final step was
missing, which I found from studying &lt;a href=&quot;https://forum.ubuntu-fr.org/viewtopic.php?id=444506&quot;&gt;this URL&lt;/a&gt;:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;shell&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;sudo&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; grub-install&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now, everything was back to normal: the server booted correctly, and Natty was
up and running. Thanks David B. for the support!&lt;/p&gt;
</content:encoded><category>Ubuntu</category><category>DevOps</category></item><item><title>First Hackathon Experience: Introducing Green Room Radio</title><link>https://www.mickf.net/tech/introducing-green-room-radio/</link><guid isPermaLink="true">https://www.mickf.net/tech/introducing-green-room-radio/</guid><pubDate>Sun, 20 Nov 2011 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Yesterday, I went to my first Hackathon: the AT&amp;amp;T Mobile App Hackathon in
Boston. It was a very fun event (thanks to the organizers) that I recommend to
every people interested in new technologies, being a developer or not.&lt;/p&gt;
&lt;p&gt;My team was composed of Alki (from &lt;a href=&quot;https://wattnow.org/&quot;&gt;wattnow&lt;/a&gt;), Ming and Charles. Here was our
idea. Living in big cities, many gigs happen every night, mostly with local
bands you’re not familiar with. Exploring the local scene is an exciting
adventure but it requires a lot of work and can be time-consuming. What if an
app could automatically create and play a playlist of the bands playing in your
neighborhood tonight? We worked on that app. We called it Green Room Radio.&lt;/p&gt;
&lt;h2 id=&quot;geolocation--songkick--bandcamp&quot;&gt;Geolocation + Songkick + Bandcamp&lt;/h2&gt;
&lt;p&gt;Technically speaking, we created a native iOS app, running on iPad, iPhone and
iPod Touch executing the following tasks:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;geolocation of the user&lt;/li&gt;
&lt;li&gt;fetching of JSON data of all concerts near the user position from the
&lt;a href=&quot;https://www.songkick.com/developer&quot;&gt;Songkick API&lt;/a&gt; (thanks to Sabrina for providing us an API key so quickly on
a saturday)&lt;/li&gt;
&lt;li&gt;fetching of JSON data from the artists playing from the &lt;a href=&quot;https://bandcamp.com/developer&quot;&gt;Bandcamp API&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;highlighting artists know from Bandcamp for which a track was available to be
streamed&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We started from scratch, wrote the first line of code at 1.30pm and by 7pm, were
ready for our demo of a functional-but-ugly app. Here are some screenshots:&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;Screenshot of the geolocation feature&quot; title=&quot;Geolocation and list of tonight&amp;#39;s concerts in the area&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;1024&quot; width=&quot;1024&quot; height=&quot;768&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Fscreenshot-green-room-radio-1.C4114YDz.png&amp;amp;w=1080&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;rezertezr&quot; title=&quot;rezr&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;1024&quot; width=&quot;1024&quot; height=&quot;768&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Fscreenshot-green-room-radio-2.CPmO-_-t.png&amp;amp;w=1080&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;h2 id=&quot;what-happens-next&quot;&gt;What happens next?&lt;/h2&gt;
&lt;p&gt;Of course, the app needs some design work. Then we’d love to get some feedback
from Songkick and Bandcamp. Eventually, we could add many new features:
integrating other services, featuring social sharing options, providing links to
purchase concert tickets or purchase music, etc.&lt;/p&gt;
&lt;p&gt;And as we love the name “Green Room Radio”, we’re also aware that it might be
pretty misleading for people who don’t know what a &lt;a href=&quot;https://en.wikipedia.org/wiki/Green_room&quot;&gt;green room&lt;/a&gt; is (I was
part of them) so we might have to find a new name for it.&lt;/p&gt;
&lt;p&gt;Hopefully, the app will end up on the App Store but in the meantime, if you want
to try this app, have some feedback to share, or a name suggestion, feel free to
contact me.&lt;/p&gt;
&lt;h3 id=&quot;more-links-about-the-event&quot;&gt;More links about the event&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;del&gt;Recap post from Alex Donn&lt;/del&gt; (edit: 💀 link)&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.facebook.com/media/set/?set=a.272239499489444.63625.151603081553087&amp;amp;type=1&quot;&gt;Facebook photo bucket&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</content:encoded><category>Hackathon</category></item><item><title>Should I renew my Scrum Master certification?</title><link>https://www.mickf.net/tech/should-i-renew-my-scrum-master-certification/</link><guid isPermaLink="true">https://www.mickf.net/tech/should-i-renew-my-scrum-master-certification/</guid><pubDate>Sat, 11 Jun 2011 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;My Scrum Master certification, delivered by the Scrum Alliance, is expiring next
June 29th. I have two weeks left to decide if I want to renew it or not, being
aware that the renewal fee is $50 a year.&lt;/p&gt;
&lt;p&gt;Right now, I don’t think I want to renew it for the following reasons:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The certification can be obtained with a single 2 day training: it has not a
lot of value to me;&lt;/li&gt;
&lt;li&gt;In 2 years, people never got in touch with me via the Scrum Alliance website
(90% of my new professional connections come from LinkedIn and Viadeo, 10%
from this website);&lt;/li&gt;
&lt;li&gt;$50 a year is not that pricy in itself, but it is pricy given the benefits
it provides.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Feel free to let me know what you think on this subject but I’m going to
transition from a &lt;em&gt;Certified Scrum Master&lt;/em&gt; status to a &lt;em&gt;Formerly Certified Scrum
Master&lt;/em&gt; status.&lt;/p&gt;
</content:encoded><category>Scrum</category><category>Agile</category></item><item><title>My Top 5 iPad Applications</title><link>https://www.mickf.net/tech/my-ipad-top-5/</link><guid isPermaLink="true">https://www.mickf.net/tech/my-ipad-top-5/</guid><pubDate>Sun, 05 Jun 2011 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;iPad are getting more and more popular and my friends start asking me what apps
I recommend. Games apart, here are the ones I’m using the most (on an iPad
usage, not iPhone usage).&lt;/p&gt;
&lt;h2 id=&quot;reeder&quot;&gt;Reeder&lt;/h2&gt;
&lt;p&gt;Reeder is my number 1 app on the iPad. That’s the one I’m using for my &lt;em&gt;morning
coffee&lt;/em&gt;, my daily RSS feeds review (and by the way, &lt;del&gt;I publish the highlight on
this website&lt;/del&gt;) (edit: I &lt;em&gt;used&lt;/em&gt; to publish…)&lt;/p&gt;
&lt;p&gt;I feel people are not using RSS enough. Come on people, use RSS feeds, they’re
awesome!&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;Reeder Screenshot&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;600&quot; width=&quot;600&quot; height=&quot;450&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Freeder-screenshot.DyVF-dXq.jpg&amp;amp;w=640&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;h2 id=&quot;flipboard&quot;&gt;Flipboard&lt;/h2&gt;
&lt;p&gt;Flipboard makes a digital magazine out of your Facebook or Twitter accounts.&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;Flipboard Screenshot&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;600&quot; width=&quot;600&quot; height=&quot;450&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Fflipboard-screenshot.BbEwgKwI.jpg&amp;amp;w=640&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;h2 id=&quot;instapaper&quot;&gt;Instapaper&lt;/h2&gt;
&lt;p&gt;Instapaper is a distraction-free web pages reeder. No matter how shitty the
original page typography is, Instapaper makes it beautiful, easy to read,
removing all the content that could distract you from the core content that
interests you (CSS, links, ad banners, …)&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;Instapaper Screenshot&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;600&quot; width=&quot;600&quot; height=&quot;450&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Finstapaper-screenshot.ClVDrur8.jpg&amp;amp;w=640&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;h2 id=&quot;canal&quot;&gt;CANAL+&lt;/h2&gt;
&lt;p&gt;This TV channel application is nicely made and allows to access all of Canal+
free contents. If you’re a subscriber, there’s even the possibility to watch the
TV live on the device.&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;Canal+ Screenshot&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;600&quot; width=&quot;600&quot; height=&quot;450&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Fcanal_plus_screenshot.CWuUpaEK.jpg&amp;amp;w=640&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;h2 id=&quot;allociné--imdb&quot;&gt;Allociné &amp;amp; IMDB&lt;/h2&gt;
&lt;p&gt;These 2 apps are great. Classic content: you get access to all their website
counterpart information, plus some nice features involving geolocation, etc.&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;Allociné and IMDB Screenshot&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;600&quot; width=&quot;600&quot; height=&quot;377&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Fallocine_imdb_screenshot.BOdETZKm.jpg&amp;amp;w=640&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;h2 id=&quot;and-two-more-for-the-road&quot;&gt;And two more for the road:&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Friendly: the substitute of an official Facebook app&lt;/li&gt;
&lt;li&gt;Flickpad Pro: browsing of pictures from your Facebook and Flickr contacts&lt;/li&gt;
&lt;/ul&gt;
</content:encoded><category>iPad</category></item><item><title>Foot et information design, vol. 4</title><link>https://www.mickf.net/tech/quatrieme-tp-d-information-design/</link><guid isPermaLink="true">https://www.mickf.net/tech/quatrieme-tp-d-information-design/</guid><pubDate>Wed, 23 Mar 2011 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;a href=&quot;https://www.mickf.net/tech/premiers-pas-en-design-de-l-information/&quot;&gt;Volume 1&lt;/a&gt; | &lt;a href=&quot;https://www.mickf.net/tech/second-tp-d-information-design-toujours-sur-l-equipe-de-france/&quot;&gt;Volume 2&lt;/a&gt; | &lt;a href=&quot;https://www.mickf.net/tech/troisieme-tp-d-information-design/&quot;&gt;Volume 3&lt;/a&gt; | Volume 4&lt;/p&gt;
&lt;p&gt;Les matches de l’équipe de France sont toujours l’occasion de m’entraîner à
l’information design. Je pense en être arrivé à une étape décisive.&lt;/p&gt;
&lt;p&gt;En attendant sa publication (il me reste 2, 3 trucs à régler concernant la
license des polices utilisées pour les diffuser en font-face), voici quelques
screenshots de l’état de la chose.&lt;/p&gt;
&lt;h2 id=&quot;le-html&quot;&gt;Le HTML&lt;/h2&gt;
&lt;p&gt;&lt;img alt=&quot;HTML code&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;458&quot; width=&quot;458&quot; height=&quot;409&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Ffff-selection-by-mick-html-code.DhxX2uSn.png&amp;amp;w=512&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;p&gt;Le HTML est selon moi ok pour du web sémantique. Lors du dernier exercice,
&lt;a href=&quot;https://twitter.com/felixaverlant/status/36127907222913024&quot;&gt;un commentateur Twitter m’avait répondu&lt;/a&gt;
:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Ce n’est pas vraiment du web sémantique […] Plutôt de la visu
d’informations.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Ce sur quoi je ne suis pas d’accord à 100%. Je pense que le HTML sépare
clairement mise en forme et contenu, et que le contenu est structuré de façon
interprétable. Par contre, il est peut-être vrai que je n’utilise pas toutes les
balises les plus précises, notamment celles introduites dans HTML5, mais toute
aide sur ce point sera la bienvenue.&lt;/p&gt;
&lt;h2 id=&quot;la-feuille-de-style&quot;&gt;La feuille de style&lt;/h2&gt;
&lt;p&gt;Je parlais de la séparation contenu/style. Pour illustrer ce propos, voici le
HTML tel qu’il est rendu dans Chrome quand la feuille de style n’est pas activée
:&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;Before CSS&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;294&quot; width=&quot;294&quot; height=&quot;466&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Ffff-selection-before-css.CpsrLJCz.png&amp;amp;w=320&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;p&gt;Maintenant, voici la même page HTML, toujours dans Chrome, cette fois avec la
feuille de style activée :&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;After CSS&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;600&quot; width=&quot;600&quot; height=&quot;438&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Ffff-selection-after-css.zAFi5om9.png&amp;amp;w=640&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;p&gt;Où sont passées les photos des joueurs dans cette seconde version ? J’y viens…&lt;/p&gt;
&lt;h2 id=&quot;interaction-via-popovers&quot;&gt;Interaction via popovers&lt;/h2&gt;
&lt;p&gt;Dans &lt;a href=&quot;https://www.mickf.net/tech/troisieme-tp-d-information-design/&quot;&gt;mon dernier post à ce sujet&lt;/a&gt;, je promettais d’améliorer le design de
la page en terme d’interactivité. C’est le sujet sur lequel je me suis le plus
penché lors de cette session.&lt;/p&gt;
&lt;p&gt;Le prénom d’un joueur, sa photo, son club, son âge sont des informations de
seconde importance dans mon exercice. En outre, le plupart des lecteurs
potentiels de cette page les connaissent de toute façon. Il n’est donc pas
nécessaire de les afficher par défaut, mais il est souhaitable de pouvoir y
accéder facilement malgré tout.&lt;/p&gt;
&lt;p&gt;J’ai donc choisi de proposer ces informations lors du survol du nom d’un joueur
par la souris :&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;Popover&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;383&quot; width=&quot;383&quot; height=&quot;237&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Ffff-selection-popover.C8qHKdVy.png&amp;amp;w=400&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;p&gt;Le terme consacré pour ce genre de fenêtre volante est &lt;em&gt;popover&lt;/em&gt; ou &lt;em&gt;tooltip&lt;/em&gt; et
voici les ressources qui m’ont aidé à le réaliser :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://kitgrose.tumblr.com/post/524802936/popover-tooltips-in-html-css&quot;&gt;&lt;em&gt;Popover&lt;/em&gt; tooltips in HTML/CSS&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://forum.alsacreations.com/topic-4-37258-1.html&quot;&gt;Forum d’Alsacréations&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;bilan&quot;&gt;Bilan&lt;/h2&gt;
&lt;p&gt;Le gros-oeuvre est terminé sur cet exercice. Encore quelques retouches par ci,
par là (réglage des questions des droits et des licenses, tests
multi-navigateurs, tests sur iPhone/iPad, etc.) et je publierai tout ça sur le
web. Stay tuned et n’hésitez pas à partager vos impressions dans les
commentaires !&lt;/p&gt;
</content:encoded><category>Data</category></item><item><title>Foot et information design, vol. 3</title><link>https://www.mickf.net/tech/troisieme-tp-d-information-design/</link><guid isPermaLink="true">https://www.mickf.net/tech/troisieme-tp-d-information-design/</guid><pubDate>Wed, 09 Feb 2011 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;a href=&quot;https://www.mickf.net/tech/premiers-pas-en-design-de-l-information/&quot;&gt;Volume 1&lt;/a&gt; | &lt;a href=&quot;https://www.mickf.net/tech/second-tp-d-information-design-toujours-sur-l-equipe-de-france/&quot;&gt;Volume 2&lt;/a&gt; | Volume 3 | &lt;a href=&quot;https://www.mickf.net/tech/quatrieme-tp-d-information-design/&quot;&gt;Volume 4&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Quelques mois après mon dernier exercice, je profite du match France-Brésil pour
un nouveau TP.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://www.mickf.net/tech/second-tp-d-information-design-toujours-sur-l-equipe-de-france/&quot;&gt;Lors de l’exercice précédent&lt;/a&gt;, j’avais fabriqué une infographie de
l’équipe de France à la main : à partir de mes données, j’avais ouvert mon
Photoshop et fait le placement des joueurs à la main.&lt;/p&gt;
&lt;p&gt;C’est joli mais ça manque d’intéraction possible. Aussi, le sujet de mon nouveau
TP était : puis-je faire la même chose en HTML ?&lt;/p&gt;
&lt;p&gt;Le HTML présente de nombreux avantages :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;on peut y insérer du
&lt;a href=&quot;https://fr.wikipedia.org/wiki/Web_s%C3%A9mantique&quot;&gt;web sémantique&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;on peut y ajouter de l’interactivité&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Aujourd’hui, je me suis principalement intéressé au web sémantique. Le résultat
est le suivant (screenshot de Flickr) :&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;L’Equipe de France A sélectionnée par Laurent Blanc pour France-Brésil (amical)&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;915&quot; width=&quot;915&quot; height=&quot;700&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Ffff-selection-by-mick-html.DTkxy37o.png&amp;amp;w=800&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;p&gt;Moins joli, mais prometteur, je l’améliorerai d’un point de vue design et
intéractivité lors du prochain match de l’équipe de France !&lt;/p&gt;
&lt;p&gt;Je ne partage pas encore le HTML, car il n’est pas d’assez bonne qualité pour le
moment, mais voici un screenshot du code source, afin de vous donner une idée du
web sémantique que j’y ai introduit (là aussi, il peut être largement améliorée)
:&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;Preview du HTML&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;418&quot; width=&quot;418&quot; height=&quot;509&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Ffff-selection-by-mick-html-preview.am3f7CyX.png&amp;amp;w=400&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://www.mickf.net/tech/quatrieme-tp-d-information-design/&quot;&gt;→ Volume 4&lt;/a&gt;&lt;/p&gt;
</content:encoded><category>Data</category></item><item><title>iOS et keyboardType</title><link>https://www.mickf.net/tech/ios-et-keyboardtype/</link><guid isPermaLink="true">https://www.mickf.net/tech/ios-et-keyboardtype/</guid><pubDate>Thu, 03 Feb 2011 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Comme j’ai cherché une page qui ressemblerait à celle-ci et que je ne l’ai pas
trouvée, voici ma compilation “à quoi ressemble tel type de clavier d’iOS selon
la valeur de &lt;code&gt;UIKeyboardType&lt;/code&gt; ?”.&lt;/p&gt;
&lt;p&gt;Bien sûr, ce travail est très limité :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;je montre seulement les touches accessibles via la vue principale du clavier&lt;/li&gt;
&lt;li&gt;je montre seulement la version iPhone en orientation portrait&lt;/li&gt;
&lt;li&gt;je montre seulement les types de clavier non deprecated sur le SDK 4.2&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Mais quand même, ça peut être utile.&lt;/p&gt;
&lt;p&gt;(s’il existe une page similaire faisant davantage référence, n’hésitez pas à en
faire part dans les commentaires)&lt;/p&gt;
&lt;h2 id=&quot;uikeyboardtypedefault&quot;&gt;UIKeyboardTypeDefault&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;Use the default keyboard for the current input method.&lt;br&gt;
Available in iOS 2.0 and later.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;img alt=&quot;UIKeyboardTypeDefault&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;327&quot; width=&quot;327&quot; height=&quot;223&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Fkeyboard-UIKeyboardTypeDefault.C8KCR_be.png&amp;amp;w=320&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;h2 id=&quot;uikeyboardtypeasciicapable&quot;&gt;UIKeyboardTypeASCIICapable&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;Use a keyboard that displays standard ASCII characters.&lt;br&gt;
Available in iOS 2.0 and later.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;img alt=&quot;UIKeyboardTypeASCIICapable&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;327&quot; width=&quot;327&quot; height=&quot;224&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Fkeyboard-UIKeyboardTypeASCIICapable.B1_mQn0L.png&amp;amp;w=320&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;h2 id=&quot;uikeyboardtypenumbersandpunctuation&quot;&gt;UIKeyboardTypeNumbersAndPunctuation&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;Use the numbers and punctuation keyboard.&lt;br&gt;
Available in iOS 2.0 and later.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;img alt=&quot;UIKeyboardTypeNumbersAndPunctuation&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;327&quot; width=&quot;327&quot; height=&quot;222&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Fkeyboard-UIKeyboardTypeNumbersAndPunctuation.Bw6vPMyK.png&amp;amp;w=320&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;h2 id=&quot;uikeyboardtypeurl&quot;&gt;UIKeyboardTypeURL&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;Use a keyboard optimized for URL entry. This type features “.”, “/”, and
“.com” prominently.&lt;br&gt;
Available in iOS 2.0 and later.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;img alt=&quot;UIKeyboardTypeURL&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;328&quot; width=&quot;328&quot; height=&quot;225&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Fkeyboard-UIKeyboardTypeURL.Wy7r5sF-.png&amp;amp;w=320&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;h2 id=&quot;uikeyboardtypenumberpad&quot;&gt;UIKeyboardTypeNumberPad&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;Use a numeric keypad designed for PIN entry. This type features the numbers 0
through 9 prominently. This keyboard type does not support
auto-capitalization.&lt;br&gt;
Available in iOS 2.0 and later.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;img alt=&quot;UIKeyboardTypeNumberPad&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;327&quot; width=&quot;327&quot; height=&quot;225&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Fkeyboard-UIKeyboardTypeNumberPad.DSI_IXKW.png&amp;amp;w=320&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;h2 id=&quot;uikeyboardtypephonepad&quot;&gt;UIKeyboardTypePhonePad&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;Use a keypad designed for entering telephone numbers. This type features the
numbers 0 through 9 and the &lt;code&gt;*&lt;/code&gt; and &lt;code&gt;#&lt;/code&gt; characters prominently. This keyboard
type does not support auto-capitalization.&lt;br&gt;
Available in iOS 2.0 and later.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;img alt=&quot;UIKeyboardTypePhonePad&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;326&quot; width=&quot;326&quot; height=&quot;224&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Fkeyboard-UIKeyboardTypePhonePad.BNYtkeGj.png&amp;amp;w=320&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;h2 id=&quot;uikeyboardtypenamephonepad&quot;&gt;UIKeyboardTypeNamePhonePad&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;Use a keypad designed for entering a person’s name or phone number. This
keyboard type does not support auto-capitalization.&lt;br&gt;
Available in iOS 2.0 and later.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;img alt=&quot;UIKeyboardTypeNamePhonePad&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;328&quot; width=&quot;328&quot; height=&quot;222&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Fkeyboard-UIKeyboardTypeNamePhonePad.DJBYPwL2.png&amp;amp;w=320&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;h2 id=&quot;uikeyboardtypeemailaddress&quot;&gt;UIKeyboardTypeEmailAddress&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;Use a keyboard optimized for specifying email addresses. This type features
the “@”, “.” and space characters prominently.&lt;br&gt;
Available in iOS 2.0 and later.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;img alt=&quot;UIKeyboardTypeEmailAddress&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;329&quot; width=&quot;329&quot; height=&quot;224&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Fkeyboard-UIKeyboardTypeEmailAddress.B3wljab2.png&amp;amp;w=320&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;h2 id=&quot;uikeyboardtypedecimalpad&quot;&gt;UIKeyboardTypeDecimalPad&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;Use a keyboard with numbers and a decimal point.&lt;br&gt;
Available in iOS 4.1 and later.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;img alt=&quot;UIKeyboardTypeDecimalPad&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;327&quot; width=&quot;327&quot; height=&quot;222&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Fkeyboard-UIKeyboardTypeDecimalPad.DHiBGzY8.png&amp;amp;w=320&amp;amp;q=100&quot;&gt;&lt;/p&gt;
</content:encoded><category>iOS</category><category>UIKit</category></item><item><title>Le bilan du Morning Coffee</title><link>https://www.mickf.net/tech/le-bilan-du-morning-coffee/</link><guid isPermaLink="true">https://www.mickf.net/tech/le-bilan-du-morning-coffee/</guid><pubDate>Sun, 26 Dec 2010 00:00:00 GMT</pubDate><content:encoded>&lt;h2 id=&quot;incident&quot;&gt;Incident&lt;/h2&gt;
&lt;p&gt;&lt;img src=&quot;https://imgs.xkcd.com/comics/incident.png&quot; alt=&quot;Incident by xkcd&quot;&gt;&lt;/p&gt;
&lt;p&gt;(via &lt;a href=&quot;https://xkcd.com/838/&quot;&gt;xkcd&lt;/a&gt;)&lt;/p&gt;
&lt;h2 id=&quot;comic-sans-criminal&quot;&gt;Comic Sans Criminal&lt;/h2&gt;
&lt;p&gt;Je suis un maniaque de la typographie, de la présentation d’information et de la
forme en général. Si vous voulez me mettre hors de moi, montrez-moi simplement
au choix :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;une affiche faite sans ironie où figurent les petites images de la Clipart
Gallery de Microsoft,&lt;/li&gt;
&lt;li&gt;la même chose avec au moins 3 ou 4 polices d’écriture différentes&lt;/li&gt;
&lt;li&gt;un slideshow PowerPoint avec des transitions en étoile, en volet ou que
sais-je encore&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Chez les web-designers, la même chose existe pour la police Comic Sans. L’un
d’entre eux a réalisé le site
&lt;a href=&quot;https://comicsanscriminal.com/&quot;&gt;Comic Sans Criminal&lt;/a&gt;, tout simplement génial.&lt;/p&gt;
&lt;p&gt;Daring Fireball parle aussi cette semaine de
&lt;a href=&quot;https://daringfireball.net/2010/12/title_junk&quot;&gt;la bonne manière de renseigner les balises &amp;lt;title&amp;gt; des sites web&lt;/a&gt;.
Intéressant (et je suis d’accord avec lui, ce site le prouve).&lt;/p&gt;
&lt;p&gt;(via &lt;a href=&quot;https://daringfireball.net&quot;&gt;Daring Fireball&lt;/a&gt;)&lt;/p&gt;
&lt;h2 id=&quot;animation-avec-google-docs&quot;&gt;Animation avec Google Docs&lt;/h2&gt;
&lt;p&gt;Une manière d’être hyper créatif, même avec des outils sans fonctionnalités
hyper évoluées : &lt;a href=&quot;https://youtu.be/bt9F7tKcZcU&quot; title=&quot;une animation de 89 secondes en 450 slides Google Docs&quot;&gt;une animation de 1 minute et 29 secondes faite de 450 slides
Google Docs&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;(via
&lt;a href=&quot;https://flowingdata.com/2010/12/22/epic-animation-in-google-docs/&quot;&gt;flowingdata&lt;/a&gt;)&lt;/p&gt;
&lt;h2 id=&quot;mes-nouveaux-flux-rss&quot;&gt;Mes nouveaux flux RSS&lt;/h2&gt;
&lt;p&gt;Encore une fois, la visite de Daring Fireball m’a fait découvrir un nouveau site
qui va enrichir mon morning coffee : &lt;a href=&quot;https://www.moss.fm/&quot;&gt;Olly Moss&lt;/a&gt;,
responsable de ce
&lt;a href=&quot;https://www.threadless.com/shop/@threadless/design/hell-maybe/home/fine-art-print&quot;&gt;très beau diagramme de Venn&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&quot;set-dicônes-gratuit&quot;&gt;Set d’icônes gratuit&lt;/h2&gt;
&lt;p&gt;Se rendre
&lt;a href=&quot;https://www.smashingmagazine.com/2010/12/free-icon-set-for-web-developers-coded/&quot;&gt;ici&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;(via Webdesigner Depot)&lt;/p&gt;
</content:encoded><category>Typography</category></item><item><title>Ignorer des fichiers d&apos;un projet XCode dans SVN</title><link>https://www.mickf.net/tech/ignorer-des-fichiers-d-un-projet-xcode-dans-svn/</link><guid isPermaLink="true">https://www.mickf.net/tech/ignorer-des-fichiers-d-un-projet-xcode-dans-svn/</guid><pubDate>Wed, 27 Oct 2010 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;À chaque nouveau projet XCode que j’insère dans mon SVN, une tâche est toujours
la même : demander à SVN d’ignorer le répertoire &lt;code&gt;build&lt;/code&gt;, et mes fichiers de
configuration personnels.&lt;/p&gt;
&lt;p&gt;Ces fichiers/dossiers n’ont a priori rien à faire sur un SVN, et il est
confortable de demander à son client, svnX par exemple, de ne plus les afficher
à tout bout de champ.&lt;/p&gt;
&lt;p&gt;Voilà, étape par étape, la procédure à effectuer, dans un Terminal.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;configurer un éditeur de texte (mon préféré étant emacs):&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sh&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;export&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; SVN_EDITOR&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;emacs&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;aller à la racine de votre projet XCode, et entrer :&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sh&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;svn&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; propedit&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; svn:ignore&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; .&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;là, votre éditeur s’ouvre : tapez simplement &lt;code&gt;build&lt;/code&gt; puis quittez votre
éditeur&lt;/li&gt;
&lt;li&gt;aller dans votre dossier &lt;code&gt;&amp;lt;Projet&amp;gt;.xcodeproj&lt;/code&gt; : des fichiers de configuration
personnels se trouvent ici et ne doivent pas être ajoutés au SVN
&lt;code&gt;cd Projet.xcodeproj&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;entrer à nouveau :&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sh&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;svn&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; propedit&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; svn:ignore&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; .&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;puis quand votre éditeur s’ouvre, tapez une séquence de type &lt;code&gt;mick.*&lt;/code&gt; pour
chaque utilisateur présent dans le répertoire&lt;/li&gt;
&lt;li&gt;commiter ces modifications de propriété sur le SVN : svnX ne vous embêtera
plus avec eux.&lt;/li&gt;
&lt;/ul&gt;
</content:encoded><category>Subversion</category><category>Xcode</category></item><item><title>Foot et information design, vol. 2</title><link>https://www.mickf.net/tech/second-tp-d-information-design-toujours-sur-l-equipe-de-france/</link><guid isPermaLink="true">https://www.mickf.net/tech/second-tp-d-information-design-toujours-sur-l-equipe-de-france/</guid><pubDate>Mon, 04 Oct 2010 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;a href=&quot;https://www.mickf.net/tech/premiers-pas-en-design-de-l-information/&quot;&gt;Volume 1&lt;/a&gt; | Volume 2 | &lt;a href=&quot;https://www.mickf.net/tech/troisieme-tp-d-information-design/&quot;&gt;Volume 3&lt;/a&gt; | &lt;a href=&quot;https://www.mickf.net/tech/quatrieme-tp-d-information-design/&quot;&gt;Volume 4&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Quelques semaines après &lt;a href=&quot;https://www.mickf.net/tech/premiers-pas-en-design-de-l-information/&quot;&gt;ma première tentative d’information design&lt;/a&gt;, les
mêmes causes impliquent les mêmes conséquences : la nouvelle sélection de
Laurent Blanc me redonne de l’inspiration pour un nouveau TP !&lt;/p&gt;
&lt;p&gt;Cette fois, la lecture de l’Équipe et, plus particulièrement, celle du tableau
ci-dessous m’a donné l’idée de chercher un moyen plus adapté de présenter la
sélection.&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;Présentation de la sélection dans le journal L’Équipe&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;500&quot; width=&quot;500&quot; height=&quot;525&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Ffff-selection-by-lequipe.2f_TywYA.png&amp;amp;w=512&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;p&gt;Le résultat est le suivant :&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/fff-selection-by-mick.png&quot; alt=&quot;L’Equipe de France A sélectionnée par Laurent Blanc pour France-Roumanie et France-Luxembourg (qualifications Euro 2012)&quot;&gt;&lt;/p&gt;
&lt;p&gt;L’infographie est construite de la façon suivante :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;chaque joueur est &lt;strong&gt;placé selon son poste&lt;/strong&gt;, ou l’un de ses postes possibles&lt;/li&gt;
&lt;li&gt;la &lt;strong&gt;taille de la police&lt;/strong&gt; utilisée dépend du temps de jeu que le joueur a
obtenu en équipe de France depuis que Blanc en est le sélectionneur : de 24 pt
de hauteur pour un joueur sans temps de jeu à 72 pt de hauteur pour un joueur
avec 270 minutes de temps de jeu sur ces 3 matches&lt;/li&gt;
&lt;li&gt;la saturation de &lt;strong&gt;la couleur du texte&lt;/strong&gt; représente l’expérience relative du
joueur en équipe de France : d’une saturation de 0% (blanc) pour les joueurs
sans sélection à une saturation de 100% (bleu intense) pour les joueurs à 59
sélections (nombre de sélection de Malouda, le joueur le plus capé de cette
sélection)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Ainsi, en comparant les deux sources d’information, on a :&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;strong&gt;Information&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Tableau de L’Équipe&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Infographie&lt;/strong&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Nom du joueur&lt;/td&gt;
&lt;td&gt;oui&lt;/td&gt;
&lt;td&gt;oui&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Poste du joueur&lt;/td&gt;
&lt;td&gt;imprécis&lt;/td&gt;
&lt;td&gt;précis&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Club du joueur&lt;/td&gt;
&lt;td&gt;oui&lt;/td&gt;
&lt;td&gt;non&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Âge du joueur&lt;/td&gt;
&lt;td&gt;oui&lt;/td&gt;
&lt;td&gt;non&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Nb de sélection&lt;/td&gt;
&lt;td&gt;oui&lt;/td&gt;
&lt;td&gt;couleur du texte&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Nb de buts&lt;/td&gt;
&lt;td&gt;oui&lt;/td&gt;
&lt;td&gt;non&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Nb de joueurs par poste&lt;/td&gt;
&lt;td&gt;imprécis&lt;/td&gt;
&lt;td&gt;précis&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Tps de jeu récent&lt;/td&gt;
&lt;td&gt;non&lt;/td&gt;
&lt;td&gt;oui&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Le tableau de l’Equipe continue de donner plus d’information que l’infographie
mais cette information supplémentaire est difficilement lisible.&lt;/p&gt;
&lt;p&gt;L’infographie, quant à elle, offre &lt;strong&gt;une analyse&lt;/strong&gt; de la sélection en lecture
immédiate :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;les noms les plus grands sont ceux du domaine défensif : (Rami, Mexès, Mvila,
Clichy, Sagna, Lloris) : l’effort de Blanc se concentre pour l’instant à
construire une défense stable&lt;/li&gt;
&lt;li&gt;noms de petite taille et multitude de noms de taille similaire au milieu et en
attaque : ces deux secteurs de jeu sont en chantier&lt;/li&gt;
&lt;li&gt;la couleur des noms est majoritairement blanche, même pour les noms de grande
taille : l’inexpérience globale est marquante, surtout si on comparait cette
infographie à une infographie similaire pour une sélection précédente (celle
de la coupe du monde par exemple, où les noms de grande taille seraient de
couleur bien plus foncée)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;L’infographie présente malgré tout des défauts et quelques axes d’améliorations
possibles. Ainsi, contrairement au tableau qui a une contrainte forte : son
exploitabilité au format papier, l’infographie, pouvant s’en affranchir,
pourrait être &lt;strong&gt;interactive&lt;/strong&gt; et apporter, par exemple, les informations
manquantes du tableau lors du clic ou du survol d’un nom de joueur.&lt;/p&gt;
&lt;p&gt;N’hésitez pas à me faire part de vos remarques, bonnes ou mauvaises, dans les
commentaires.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://www.mickf.net/tech/troisieme-tp-d-information-design/&quot;&gt;→ Volume 3&lt;/a&gt;&lt;/p&gt;
</content:encoded><category>Data</category></item><item><title>Foot et information design, vol. 1</title><link>https://www.mickf.net/tech/premiers-pas-en-design-de-l-information/</link><guid isPermaLink="true">https://www.mickf.net/tech/premiers-pas-en-design-de-l-information/</guid><pubDate>Fri, 27 Aug 2010 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Volume 1 | &lt;a href=&quot;https://www.mickf.net/tech/second-tp-d-information-design-toujours-sur-l-equipe-de-france/&quot;&gt;Volume 2&lt;/a&gt; | &lt;a href=&quot;https://www.mickf.net/tech/troisieme-tp-d-information-design/&quot;&gt;Volume 3&lt;/a&gt; | &lt;a href=&quot;https://www.mickf.net/tech/quatrieme-tp-d-information-design/&quot;&gt;Volume 4&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Le design de l’information (ou plus naturellement, même quand on est français,
&lt;em&gt;information design&lt;/em&gt;) est « l’art et la science de la préparation de
l’information afin qu’elle puisse être utilisée par les êtres humains avec
efficience et efficacité » (citation de [Wikipedia][1]).&lt;/p&gt;
&lt;p&gt;Plus concrètement, c’est l’habileté à présenter des informations de façon
graphique et le plus immédiatement lisible possible. Les enseignants
l’introduisent souvent grâce à la formule consacrée « un schéma vaudra mieux
qu’un long discours ».&lt;/p&gt;
&lt;p&gt;Bref, c’est un art/science qui m’intéresse beaucoup en ce moment puisqu’il est
au cœur des tendances actuelles des technologies de l’information.&lt;/p&gt;
&lt;p&gt;Aussi, je tente actuellement d’y faire mes premiers pas et aujourd’hui, j’ai
exécuté des travaux pratiques autour de… la sélection de l’équipe de France
faite par Laurent Blanc pour les qualifications à l’Euro 2012.&lt;/p&gt;
&lt;p&gt;Partout dans la presse sportive, le débat est le suivant : après le mondial, à
quoi va ressembler l’équipe de Blanc ? Quels mondialistes vont être
sanctionnés ? Quels joueurs ont convaincu leur sélectionneur en Norvège ? etc.
Et je trouvais qu’il manquait un bon vieux diagramme de Venn pour formaliser
tout ça. Dont acte.&lt;/p&gt;
&lt;p&gt;Le résultat me fait un peu rougir - le diagramme était bien plus beau dans ma
tête - mais après tout, c’était une première fois et je pense qu’il est
finalement assez honorable :&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;Diagramme de Venn de la 1ère sélection post-mondial 2010&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;1280&quot; width=&quot;1280&quot; height=&quot;1024&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Ffff-venn-diagram.CIq8Dx3H.png&amp;amp;w=1080&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;p&gt;N’hésitez pas à me faire part de vos commentaires et si l’information design
vous intéresse, je vous recommande le site suivant : [flowingdata.com][2].&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://www.mickf.net/tech/second-tp-d-information-design-toujours-sur-l-equipe-de-france/&quot;&gt;→ Volume 2&lt;/a&gt;&lt;/p&gt;
</content:encoded><category>Data</category></item><item><title>A Same Website for Desktop and Mobile</title><link>https://www.mickf.net/tech/same-site-for-desktop-and-mobile/</link><guid isPermaLink="true">https://www.mickf.net/tech/same-site-for-desktop-and-mobile/</guid><description>An experiment to build a scaffold for a responsive website that works well on both desktop and mobile.</description><pubDate>Sat, 07 Aug 2010 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Internet is turning mobile. So what should I do then? Make a desktop version and
a mobile version of my website? Not really. CSS at the rescue.&lt;/p&gt;
&lt;h2 id=&quot;fluid-grids&quot;&gt;Fluid Grids&lt;/h2&gt;
&lt;p&gt;The first thing to do is to use &lt;a href=&quot;https://alistapart.com/article/fluidgrids/&quot;&gt;&lt;em&gt;fluid grids&lt;/em&gt;&lt;/a&gt;, which means using only
relative sizes in your CSS, instead of absolute ones. You can setup sizes
relative to the default browser font size, to the parent HTML blocks, etc.&lt;/p&gt;
&lt;p&gt;With this kind of relative sizing, when the user changes the size of the
browser, all the elements keep the same proportions.&lt;/p&gt;
&lt;h2 id=&quot;media-queries&quot;&gt;Media Queries&lt;/h2&gt;
&lt;p&gt;But what if a screen size gets to this critical point where keeping the same
aspect and proportion is not relevant anymore? Then, you should use &lt;a href=&quot;https://alistapart.com/article/responsive-web-design/&quot;&gt;&lt;em&gt;media
queries&lt;/em&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Here again, this is a CSS technique that you can use to reorganize the layout of
your webpage upon certain conditions. For instance, if the width of the browser
is below a certain size, you can give up a column layout and switch to a
single-column layout where blocks are placed one upon another.&lt;/p&gt;
&lt;h2 id=&quot;fluid-images&quot;&gt;Fluid Images&lt;/h2&gt;
&lt;p&gt;Of course, this is not enough and new issues are going to rise when you’re going
to put images, or YouTube embeds inside your pages.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://unstoppablerobotninja.com/entry/fluid-images/&quot;&gt;Some stuff&lt;/a&gt; can help (the CSS &lt;code&gt;max-width&lt;/code&gt; attribute for instance), but it’s
not universally supported yet.&lt;/p&gt;
&lt;h2 id=&quot;what-about-ios&quot;&gt;What about iOS?&lt;/h2&gt;
&lt;p&gt;What’s interesting me most here is not Internet Explorer-compatibility though,
but making websites that look good on iOS devices, the iPhone and the iPad. I’ve
tried to give these techniques a try and here it is:&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;A grid layout&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;1020&quot; width=&quot;1020&quot; height=&quot;289&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Fgrid.DlIOGPar.png&amp;amp;w=1080&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;p&gt;This is a 10-column layout of 82px each, separated by 20px gutters. With 2
outside gutters of 12px each, we get a grid defined by a default width of
1024px.&lt;/p&gt;
&lt;p&gt;To setup my CSS correctly, some math are required:&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;Some grid math&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;657&quot; width=&quot;657&quot; height=&quot;313&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Fgrid-math.3GP6mGop.png&amp;amp;w=640&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;p&gt;Then I had all I needed to build the &lt;a href=&quot;https://www.mickf.net/tech/assets/grid.css&quot;&gt;CSS&lt;/a&gt; for &lt;a href=&quot;https://www.mickf.net/tech/assets/grid-demo/&quot;&gt;this demo page&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;This demo page renders as follow on the iPhone, portrait and landscape:&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;Grid page rendering on an iPhone with portrait orientation&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;320&quot; height=&quot;480&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Fgrid-portrait.9qX7y86F.jpg&amp;amp;w=320&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;Grid page rendering on an iPhone with landscape orientation&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;480&quot; width=&quot;480&quot; height=&quot;320&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Fgrid-landscape.Cem5noth.jpg&amp;amp;w=512&amp;amp;q=100&quot;&gt;&lt;/p&gt;
</content:encoded><category>CSS</category><category>Responsive design</category><category>Web Publishing</category></item><item><title>Analyse d’un tableau de bord du gouvernement des États-Unis</title><link>https://www.mickf.net/tech/analyse-d-un-tableau-de-bord-du-gouvernement-des-etats-unis/</link><guid isPermaLink="true">https://www.mickf.net/tech/analyse-d-un-tableau-de-bord-du-gouvernement-des-etats-unis/</guid><pubDate>Tue, 03 Aug 2010 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Le gouvernement fédéral américain a un projet original et intéressant : proposer
sur un site web ouvert à tous &lt;a href=&quot;https://itdashboard.gov/&quot;&gt;un tableau de bord de ses dépenses dans le monde
des TIC&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Encore plus intéressant, des gens de Juice Analytics ont qualifié ce tableau de
bord et &lt;a href=&quot;https://web.archive.org/web/20100905152901/https://www.juiceanalytics.com/writing/better-federal-it-dashboard/&quot;&gt;livrent leur analyse sur leur site web&lt;/a&gt;. Celle-ci est très
intéressante et propose même une proposition de tableau de bord amélioré.&lt;/p&gt;
&lt;p&gt;À noter que cette même entreprise propose un White Paper &lt;a href=&quot;https://web.archive.org/web/20110131162438/http://www.juiceanalytics.com/white-papers-guides-and-more/&quot;&gt;&lt;em&gt;A Guide to Creating
Dashboards People Love to Use&lt;/em&gt;&lt;/a&gt;.&lt;/p&gt;
</content:encoded><category>Data</category></item><item><title>Expression régulière matchant les URL par John Gruber</title><link>https://www.mickf.net/tech/expression-reguliere-matchant-les-url-par-john-gruber/</link><guid isPermaLink="true">https://www.mickf.net/tech/expression-reguliere-matchant-les-url-par-john-gruber/</guid><pubDate>Thu, 29 Jul 2010 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;John Gruber a publié sur son fameux blog, Daring Fireball, un post contenant une
expression régulière devant matcher toute URL.&lt;/p&gt;
&lt;p&gt;Ça peut s’avérer assez pratique.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://daringfireball.net/2010/07/improved_regex_for_matching_urls&quot;&gt;An Improved Liberal, Accurate Regex Pattern for Matching URLs&lt;/a&gt;&lt;/p&gt;
</content:encoded><category>Regular expression</category></item><item><title>Top 5 des outils du développeur indépendant</title><link>https://www.mickf.net/tech/top-5-des-outils-du-developpeur-independant/</link><guid isPermaLink="true">https://www.mickf.net/tech/top-5-des-outils-du-developpeur-independant/</guid><pubDate>Mon, 26 Jul 2010 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Réaliser des produits logiciels le plus efficacement possible en tant
qu’indépendant ne peut se faire sans quelques outils permettant de gérer son
effort. Voici mon top 5 des outils que j’utilise en tant qu’indépendant !&lt;/p&gt;
&lt;h2 id=&quot;1-things&quot;&gt;1. Things&lt;/h2&gt;
&lt;p&gt;Things est un logiciel de gestion de tâches, très simple mais très performant,
qui repose sur la méthodologie &lt;a href=&quot;https://fr.wikipedia.org/wiki/Getting_Things_Done&quot;&gt;&lt;em&gt;GTD&lt;/em&gt;&lt;/a&gt; (&lt;em&gt;Getting Things Done&lt;/em&gt;). Auparavant,
j’utilisais le logiciel gratuit iGTD, mais son développeur, Bartek, a ensuite
cessé de maintenir le logiciel pour rejoindre l’équipe de… Things.&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;A screenshot of Things&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;596&quot; width=&quot;596&quot; height=&quot;479&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Fthings-screenshot.TMOdqb1m.png&amp;amp;w=640&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;p&gt;Sommairement, le GTD repose sur les principes suivants :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Se libérer sur le champ des idées qui nous arrivent en tête ou des actions qui
doivent être réalisées&lt;/li&gt;
&lt;li&gt;Identifier les items de sa todo liste par projet (par exemple : est-ce que ça
concerne le développement de tel logiciel ou l’organisation des vacances) et
par contexte (doit être faite au téléphone ? nécessite un accès internet ?)&lt;/li&gt;
&lt;li&gt;Parcourir régulièrement sa todo liste pour actualiser les priorités et les
échéances de ses tâches.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Things permet de faire ça très efficacement, surtout lorsqu’on utilise aussi la
version mobile de l’application, disponible sur iOS, et qui se synchronise via
wifi avec la version bureau de l’application.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://culturedcode.com/things/&quot;&gt;Things by Cultured Code&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;(En outre, pour ne rien gâcher, Cultured Code, l’éditeur du soft, a &lt;a href=&quot;https://culturedcode.com/status/&quot;&gt;quelques
idées assez innovantes en matière de dashboarding&lt;/a&gt;)&lt;/p&gt;
&lt;h2 id=&quot;2-timeboxed&quot;&gt;2. TimeBoxed&lt;/h2&gt;
&lt;p&gt;TimeBoxed est une application extrêmement simple : c’est un minuteur pour Mac OS
X, idéal pour le time boxing, c’est-à-dire définir un intervalle de temps pour
travailler sur une tâche donnée.&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;A screenshot of TimeBoxed&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;366&quot; width=&quot;366&quot; height=&quot;103&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Ftimeboxed-screenshot.g4Z88LxX.png&amp;amp;w=400&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;p&gt;Associé à GTD, le time boxing est une excellente technique pour combattre les
tendances à la procrastination, dont plusieurs articles de blog font l’apologie,
parmi lesquels :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://litemind.com/time-boxing/&quot;&gt;15 Time Boxing Strategies to Get Things Done&lt;/a&gt;;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.qualitystreet.fr/2007/11/14/le-timeboxing-cest-super-mais/&quot;&gt;Le timeboxing, c’est super mais…&lt;/a&gt;;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://luc-jeanniard.blogspot.com/2009/12/la-puissance-du-time-boxing.html&quot;&gt;La puissance du time boxing&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Malgré son prix un peu élevé, TimeBoxed est un outil vraiment utile et qui aide
à maîtriser son temps.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://www.macg.co/news/voir/136527/timeboxed-joue-la-montre&quot;&gt;TimeBoxed&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;3-klok&quot;&gt;3. Klok&lt;/h2&gt;
&lt;p&gt;Klok est une application de time tracking, qui aide à tracer ses activités de la
semaine et, si besoin, à en faire le reporting.&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;A screenshot of the Klok software&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;478&quot; width=&quot;478&quot; height=&quot;312&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Fklok-screenshot.D0OXzjLm.png&amp;amp;w=512&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;p&gt;Bien que son usage soit particulièrement utile dans les grosses sociétés où des
relevés d’activité sont régulièrement demandés aux collaborateurs, c’est aussi
un outil essentiel pour le travailleur indépendant (voire l’étudiant) afin
d’analyser l’utilisation faite de son temps de travail.&lt;/p&gt;
&lt;p&gt;En outre, pour ne rien gâcher, Klok, qui repose sur Abode Air, a un graphisme
très réussi et propose une version gratuite.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://getklok.com/&quot;&gt;Klok&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;4-bugzilla&quot;&gt;4. Bugzilla&lt;/h2&gt;
&lt;p&gt;Un outil de bug tracking est également totalement indispensable. Plusieurs
concurrents open source offrent les mêmes services que Bugzilla, notamment
Mantis, et j’ai d’ailleurs choisi ce logiciel de manière un peu triviale : je
tenais juste une occasion de l’essayer.&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;A screenshot of the Bugzilla software&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;930&quot; width=&quot;930&quot; height=&quot;475&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Fbugzilla-screenshot.DGbOwsEN.png&amp;amp;w=800&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;p&gt;Le bug tracking est indispensable à n’importe quelle activité de développement
d’un produit, qu’il soit logiciel ou autre, même lorsque cette activité est
réalisée en solo. C’est un outil complémentaire aux outils de management de
tâches (comme Things) en ce qu’il permet de gérer un cycle de vie de ses items
(nouveau, assigné, en cours, fermé, validé), ainsi que (et surtout !) leur
historisation.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://www.bugzilla.org&quot;&gt;Bugzilla&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;5-svn&quot;&gt;5. SVN&lt;/h2&gt;
&lt;p&gt;Un outil de gestion de version post-CVS, de type SVN ou GIT, est indispensable
et rarement utilisé de manière optimale. Même si l’usage de ces logiciels est
courant, il est important de rappeler leur utilité et leurs règles de bon usage.&lt;/p&gt;
&lt;p&gt;Le tagging est une activité essentielle qui permet de pouvoir gérer proprement
les retours en arrière, souvent nécessaires dans une activité de développement
logiciel. Grâce à SVN, les multiples répertoires “sources”, “sources2”,
“sources-temp”, “sources-old” n’ont plus de raison d’être sur des postes de
développement : l’outil gère tous ces besoins d’historisation du code à notre
place.&lt;/p&gt;
&lt;p&gt;Là encore, l’usage de systèmes de gestion de version, même dans une pratique en
solo me semble indispensable. Des commits fréquents, basés sur la réalisation de
tâches unitaires (par exemple, un item de Bugzilla), permet d’avoir un suivi du
code source très clair et la quasi assurance que chaque révision est
fonctionnelle. En outre, le respect de ces bonnes pratiques participent aussi à
optimiser son temps de travail.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://code.google.com/archive/p/svnx/&quot;&gt;svnX&lt;/a&gt; (un client SVN sous Mac OS X)&lt;/p&gt;
&lt;h2 id=&quot;remarques&quot;&gt;Remarques&lt;/h2&gt;
&lt;p&gt;Les outils recensés dans cette page sont donc des outils de :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;task management&lt;/li&gt;
&lt;li&gt;time boxing&lt;/li&gt;
&lt;li&gt;time tracking&lt;/li&gt;
&lt;li&gt;bug tracking&lt;/li&gt;
&lt;li&gt;revision control&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Quelques suites logicielles existent permettant de gérer tous ces points (de
type Atlassian). Je n’en parle pas ici pour deux raisons :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;malgré leur qualité apparente, je n’ai jamais eu l’occasion de tester ces
logiciels, la plupart du temps payants;&lt;/li&gt;
&lt;li&gt;en tant qu’utilisateur unique, je préfère maximiser le nombre d’applications
qui tournent sur un poste client, permettant plus facilement un travail
nomade.&lt;/li&gt;
&lt;/ul&gt;
</content:encoded><category>Productivity</category><category>Subversion</category></item><item><title>Apple Design Awards 2010</title><link>https://www.mickf.net/tech/apple-design-awards-2010/</link><guid isPermaLink="true">https://www.mickf.net/tech/apple-design-awards-2010/</guid><pubDate>Tue, 22 Jun 2010 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Lors de la WWDC 2010, Apple a consacré ses &lt;a href=&quot;https://developer.apple.com/design/awards/&quot;&gt;Apple Design Awards&lt;/a&gt; aux
applications iPhone et iPad uniquement, délaissant le Mac mais promettant d’y
revenir bientôt (&lt;a href=&quot;https://arstechnica.com/gadgets/2010/06/2010-ars-design-award-winners-for-mac-os-x-software/&quot;&gt;Ars se chargeant de se substituer à Apple sur ce point&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;Le &lt;a href=&quot;https://en.wikipedia.org/wiki/Apple_Design_Awards#2010&quot;&gt;palmarès&lt;/a&gt; est le suivant :&lt;/p&gt;
&lt;h2 id=&quot;applications-iphone&quot;&gt;Applications iPhone&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;20 Minute Meals - Jamie Oliver, par Zolmo&lt;/li&gt;
&lt;li&gt;Articles, par Sophiestication&lt;/li&gt;
&lt;li&gt;Brushes, par Steve Sprangs&lt;/li&gt;
&lt;li&gt;Doodle Jump, par Lima Skye, LLC.&lt;/li&gt;
&lt;li&gt;Real Racing, par Firemint&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;applications-ipad&quot;&gt;Applications iPad&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Financial Times iPad Edition, par The Financial Times Ltd.&lt;/li&gt;
&lt;li&gt;Flight Control HD, par Firemint&lt;/li&gt;
&lt;li&gt;Pinball HD, par OOO Gamepron&lt;/li&gt;
&lt;li&gt;Star Walk - Interactive Astronomy Guide, par Vito Technology Inc.&lt;/li&gt;
&lt;li&gt;TabToolkit, par Agile Partners&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Dans les prochains jours, ce blog présentera chacune de ces applications,
qu’Apple présente comme celles qui définissent les standards à prendre en compte
ces prochains mois.&lt;/p&gt;
</content:encoded><category>iOS</category><category>Apple</category></item><item><title>Balsamiq Sketching/Mockup Tool</title><link>https://www.mickf.net/tech/balsamiq-sketching-mockup-tool/</link><guid isPermaLink="true">https://www.mickf.net/tech/balsamiq-sketching-mockup-tool/</guid><pubDate>Wed, 28 Apr 2010 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Un autre outil de mockup iPhone (et autres) :
&lt;a href=&quot;https://balsamiq.com/wireframes/&quot;&gt;https://balsamiq.com/wireframes/&lt;/a&gt;&lt;/p&gt;
</content:encoded><category>Wireframe</category><category>iOS</category></item><item><title>Converting .flac files to .mp3</title><link>https://www.mickf.net/tech/converting-flac-files-to-mp3/</link><guid isPermaLink="true">https://www.mickf.net/tech/converting-flac-files-to-mp3/</guid><description>How I managed to convert `.flac` files to `.mp3` files on Mac OS X.</description><pubDate>Sat, 09 Jan 2010 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;A solution to convert &lt;code&gt;.flac&lt;/code&gt; files to &lt;code&gt;.mp3&lt;/code&gt; files from the command line:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;install &lt;code&gt;lame&lt;/code&gt; and &lt;code&gt;flac&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;move the &lt;code&gt;.flac&lt;/code&gt; files into one directory;&lt;/li&gt;
&lt;li&gt;from that directory, run the following bash script:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; file &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; *.flac&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;  do&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; $(flac&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; -cd&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;$file&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; |&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; lame&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; -h&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; &quot;${&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;file&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;%&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;flac&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;}.mp3&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;done&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;On Mac OS X, the most convenient options to install &lt;code&gt;lame&lt;/code&gt; and &lt;code&gt;flac&lt;/code&gt; are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;compiling from source to install &lt;a href=&quot;https://lame.sourceforge.io/&quot;&gt;lame&lt;/a&gt;;&lt;/li&gt;
&lt;li&gt;the &lt;a href=&quot;https://sourceforge.net/projects/flac/files/flac-darwin/&quot;&gt;Flac tools package&lt;/a&gt; to install &lt;code&gt;flac&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
</content:encoded><category>Bash</category></item><item><title>Jamais trop tard pour mettre des tags avec SVN</title><link>https://www.mickf.net/tech/jamais-trop-tard-pour-mettre-des-tags-avec-svn/</link><guid isPermaLink="true">https://www.mickf.net/tech/jamais-trop-tard-pour-mettre-des-tags-avec-svn/</guid><pubDate>Tue, 29 Dec 2009 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Quand on livre une application logicielle, l’usage veut que l’on &lt;em&gt;tague&lt;/em&gt; le code
source qui lui correspond dans son système de gestion de version. Oui mais
voilà, des fois, on n’a pas le temps alors on ne le fait pas. Qu’à cela ne
tienne, il n’est jamais trop tard pour bien faire et voici la méthode que j’ai
utilisée pour taguer a posteriori, sur mon dépôt de source Subversion, des
versions livrées il y a plusieurs semaines.&lt;/p&gt;
&lt;h2 id=&quot;prérequis&quot;&gt;Prérequis&lt;/h2&gt;
&lt;p&gt;Cette opération ne fonctionne que si les hypothèses suivantes sont vérifiées :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;le code packagé a été commité sur le système de gestion de version;&lt;/li&gt;
&lt;li&gt;les dates de livraison des logiciels sont connues, au moins de façon
approximative.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;1ère-étape-identifier-les-numéros-de-révision&quot;&gt;1ère étape : identifier les numéros de révision&lt;/h2&gt;
&lt;p&gt;Pour identifier les numéros de révision, il faut utiliser la commande suivante :&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;svn log &amp;lt;chemin-du-source-à-examiner&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Le résultat de cette commande permet d’identifier les numéros de révision et les
dates associées de tous les commit réalisés sur le source examiné. A partir des
dates de livraison, on sait alors à quel numéro de révision la livraison
correspond.&lt;/p&gt;
&lt;h2 id=&quot;2ème-étape-taguer-les-révisions-identifiées&quot;&gt;2ème étape : taguer les révisions identifiées&lt;/h2&gt;
&lt;p&gt;Pour cela, utiliser la commande suivante :&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;svn copy -r &amp;lt;num-revision&amp;gt; &amp;lt;chemin-source&amp;gt; &amp;lt;chemin-cible&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Pour rappel aux utilisateurs de SVN, la convention veut que :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;le chemin source soit le répertoire &lt;code&gt;trunk&lt;/code&gt; ou un sous-répertoire du
répertoire &lt;code&gt;branches&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;le chemin cible soit un sous-répertoire du répertoire &lt;code&gt;tags&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
</content:encoded><category>Subversion</category></item><item><title>1er diagnostic de performance sur Windows XP</title><link>https://www.mickf.net/tech/1er-diagnostic-de-performance-sur-windows-xp/</link><guid isPermaLink="true">https://www.mickf.net/tech/1er-diagnostic-de-performance-sur-windows-xp/</guid><pubDate>Tue, 10 Nov 2009 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Les lenteurs inexpliquées sur un ordinateur ont de quoi exaspérer les
utilisateurs d’ordinateurs novices en matière de technique. Cette page a pour
but de les aider à trouver une première réponse à la question : &lt;strong&gt;“pourquoi mon
ordinateur est-il si lent ?”&lt;/strong&gt;&lt;/p&gt;
&lt;h2 id=&quot;le-gestionnaire-des-tâches-à-la-rescousse&quot;&gt;Le gestionnaire des tâches à la rescousse&lt;/h2&gt;
&lt;p&gt;La 1ère étape consiste à ouvrir l’onglet &lt;em&gt;Performances&lt;/em&gt; du &lt;em&gt;Gestionnaire des
tâches&lt;/em&gt; grâce au raccourci clavier &lt;code&gt;Ctrl + Shift + Echap&lt;/code&gt;. Sur cette page se
trouvent plusieurs indicateurs clé…&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Utilisation de l’UC&lt;/strong&gt; : il s’agit du taux d’utilisation du processeur de
l’ordinateur en temps-réel. Si la valeur est grande, en permanence au-delà de
80% par exemple, alors votre ordinateur a trop de travail pour assurer des
performances satisfaisantes. Verdict : votre ordinateur n’est pas assez
puissant pour vos besoins ou alors vous le surchargez de travail (fermer
quelques applications doit vous aider à améliorer les performances).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Utilisation du fichier&lt;/strong&gt; : il s’agit de la mémoire RAM nécessaire pour que
vos applications &lt;em&gt;tournent bien&lt;/em&gt;. Pour connaître la quantité de RAM de votre
ordinateur, allez dans &lt;em&gt;Système&lt;/em&gt; dans le &lt;em&gt;Panneau de configuration&lt;/em&gt;. Votre
quantité de RAM y est affichée. Si la valeur du gestionnaire de tâches est
proche de la valeur du panneau de configuration, votre ordinateur n’a pas
assez de mémoire : il vous faut fermer quelques applications.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;le-processeur-et-la-mémoire-pour-les-nuls&quot;&gt;Le processeur et la mémoire pour les nuls&lt;/h2&gt;
&lt;p&gt;Le processeur et la mémoire sont deux ressources critiques d’un ordinateur. Pour
se figurer ce que cela représente, imaginez un ouvrier devant assembler une
maquette de voiture sur un plan de travail. Pour chaque assemblage, il doit
aller chercher les pneus, carrosserie, etc. dans un stock, les ramener sur son
plan de travail puis une fois qu’il a toutes les pièces sous les yeux, il peut
les assembler :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;le processeur est la vitesse avec laquelle l’ouvrier agit&lt;/strong&gt;. Par exemple,
plus ses bras sont rapides, plus il peut assembler de voitures;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;la mémoire est la taille de son plan de travail&lt;/strong&gt;. Si son plan de travail ne
lui permet pas d’avoir toutes les pièces unitaires sous les yeux, il va
nécessairement mettre davantage de temps à assembler une voiture.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;et-après&quot;&gt;Et après ?&lt;/h2&gt;
&lt;p&gt;Bien sûr, des problèmes de performance peuvent avoir d’autres origines qu’un
manque de processeur ou de mémoire. Mais dès lors, les choses se compliquent :
entrées/sorties, problèmes réseaux, malwares, on passe à des choses nettement
plus compliquées à identifier et à résoudre…&lt;/p&gt;
&lt;p&gt;PS: &lt;a href=&quot;https://www.macg.co/news/voir/171621/pourquoi-mon-mac-est-il-si-lent&quot;&gt;Une piste pour la même chose avec Mac OS X&lt;/a&gt;.&lt;/p&gt;
</content:encoded><category>Windows</category></item><item><title>Using Subversion with Mac OS X</title><link>https://www.mickf.net/tech/installing-subversion-with-mac-os-x/</link><guid isPermaLink="true">https://www.mickf.net/tech/installing-subversion-with-mac-os-x/</guid><description>Configure a SVN repository on a Mac: create, edit config files. A cheat sheet for svnadmin and svnserve.</description><pubDate>Sun, 17 May 2009 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;strong&gt;💡 Update:&lt;/strong&gt; You should probably use Git rather than Subversion nowadays.&lt;/p&gt;
&lt;p&gt;To create a repository:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;svnadmin&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; create&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; ~/Documents/MySVN&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;Edit the &lt;code&gt;conf/&lt;/code&gt; files:
&lt;ul&gt;
&lt;li&gt;into &lt;code&gt;svnserve.conf&lt;/code&gt;, remove comments before:
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;anon-access = read&lt;/code&gt;,&lt;/li&gt;
&lt;li&gt;&lt;code&gt;auth-access = write&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;and &lt;code&gt;password-db = passwd&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;add a user/password into &lt;code&gt;passwd&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;To run your SVN server, run:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;svnserve&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; -d&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; -r&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; ~/Documents/MySVN&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
</content:encoded><category>Subversion</category><category>macOS</category></item><item><title>Excel: exporting a chart as a PNG image</title><link>https://www.mickf.net/tech/excel-exportation-d-un-graphe-sous-forme-d-image/</link><guid isPermaLink="true">https://www.mickf.net/tech/excel-exportation-d-un-graphe-sous-forme-d-image/</guid><pubDate>Thu, 12 Feb 2009 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;This Excel macro will help you export a chart to a PNG file to &lt;code&gt;d:/temp&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;Sub exportChartAsPNG()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;Dim ChartName As String&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;Dim File As String&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;ChartName = ActiveChart.Name&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;File = &quot;d:/temp/&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;ActiveChart.Export Filename:=File &amp;amp; ChartName &amp;amp; &quot;.png&quot;, FilterName:=&quot;PNG&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;End Sub&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
</content:encoded><category>Excel</category><category>VBA</category><category>Windows</category></item><item><title>How to Add a JAR to a Local Maven Repository?</title><link>https://www.mickf.net/tech/ajouter-un-jar-a-votre-repository-maven-local/</link><guid isPermaLink="true">https://www.mickf.net/tech/ajouter-un-jar-a-votre-repository-maven-local/</guid><pubDate>Wed, 14 Jan 2009 00:00:00 GMT</pubDate><content:encoded>&lt;h2 id=&quot;the-command&quot;&gt;The command&lt;/h2&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;shell&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;mvn&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt; install:install-file&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;  -Dfile=&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;path-to-file&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;  -DgroupId=&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;group-id&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;  -DartifactId=&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;artifact-id&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;  -Dversion=&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;version&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;  -Dpackaging=&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;packaging&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;why-we-need-it&quot;&gt;Why we need it&lt;/h2&gt;
&lt;p&gt;Not every JAR is available on Maven repositories by default. That makes sense
since not every JAR is made to be public. However, if a JAR is required to
compile your project, it might be necessary to add this JAR to your local
repository.&lt;/p&gt;
&lt;p&gt;More details can be found on this &lt;a href=&quot;https://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html&quot;&gt;Guide to installing 3rd party JARs&lt;/a&gt;.&lt;/p&gt;
</content:encoded><category>Java</category><category>Maven</category></item></channel></rss>