<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by grork on Medium]]></title>
        <description><![CDATA[Stories by grork on Medium]]></description>
        <link>https://medium.com/@grork?source=rss-1ce68d1d88d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*vikc4qMbGje10oDy.jpg</url>
            <title>Stories by grork on Medium</title>
            <link>https://medium.com/@grork?source=rss-1ce68d1d88d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 09:49:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@grork/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Computers are a utility — they should behave like one]]></title>
            <link>https://medium.com/@grork/computers-are-a-utility-they-should-behave-like-one-833ff628749e?source=rss-1ce68d1d88d------2</link>
            <guid isPermaLink="false">https://medium.com/p/833ff628749e</guid>
            <category><![CDATA[windows]]></category>
            <category><![CDATA[computers]]></category>
            <category><![CDATA[rant]]></category>
            <category><![CDATA[apple]]></category>
            <dc:creator><![CDATA[grork]]></dc:creator>
            <pubDate>Sun, 21 Apr 2019 18:21:08 GMT</pubDate>
            <atom:updated>2020-07-08T22:26:29.943Z</atom:updated>
            <content:encoded><![CDATA[<h3>Computers are a utility — they should behave like one</h3><p><em>I’ve moved my blog, and the current version of this article can be found </em><a href="https://www.codevoid.net/ruminations/2019/04/21/computers-are-a-utility.html"><em>here</em></a><em>.</em></p><p>This post inspired by <em>yet again </em>going to pootle around on my personal “computers” at the weekend, and <em>yet again</em> <strong>one</strong> of them decides to just get “in the way” for nearly an hour before I can actually use it for the purpose intended.</p><p>Despite working in the tech industry, and spending 8 hours a day talking about software, technology, &amp; solutions to technically-inclined problems, I’m a sucker for punishment. I like write software at the weekend! Or <em>maybe </em>I just want a big display &amp; precision pointer — or I’m a luddite. <em>Whatever.</em></p><p>So, after a week of using mobile devices for personal internetting all week with nary an issue (I’m addicted to the internet), I open my devices on for the first time in a week — they’ve both been connected to power &amp; ethernet for that week — ready to get going on some programming problem or whatever I was going to do.</p><p><em>One</em> of them works fine 99% of the time. Sometimes, it takes a moment to catch up on messages; mostly it’s speedy and fine. <em>One </em>of them— oh boy — never works well until it’s had a few minutes to sort it self out. Then it decides to apply some update or something — which might not require a reboot, but still makes the device very unhappy. Then my IDE decides it needs an update, which often goes smoothly, but I wish it would do while it was asleep.</p><p>This puts me an hour in <em>before I’ve done anything meaningful. </em>This isn’t acceptable, and changes my relationship with technology when being used to do something enjoyable. It makes it a chore, and removes any joy.</p><p>This week it took me an hour to fix a non-functional device — I couldn’t <em>type and use the built in trackpad.</em> I then spent another 45 minutes cleaning up the almost full SSD, which I believe was causing the performance to drop off a cliff — partially removed windows feature update installers (looking at you $GetCurrent folder), and some other general non-user-created <em>slosh.</em></p><p>My two devices? An entry-level MacBook refurb with a Core-m3 CPU, and an entry-level Surface Laptop 2, with Core i5. Both 8gb of RAM.</p><p>Guess which one was the problematic device?</p><p>Yep, it’s a cliche: the Surface Laptop 2. It’s problems aren’t unique — these are general windows foibles, and have plagued windows for decades.</p><p>This swirls in my head, and I think about the current narrative about Apple’s neglection of the Mac. People will trot out the ‘I switched to Windows, and its so much better’; maybe their experiences really <strong>are</strong> much better. But I can’t match that; I just don’t have a <em>reliable</em> experience with my Windows devices any more.</p><p>To put it another way — I know when I come to my MacBook it’s going to behave like it did a week ago, or two weeks ago, or a month ago. I’ll open it up, it’ll be mostly-sync’d with all my content, and I’ll get into what I was <em>intending </em>to do right away. My Surface Laptop? Nope, I can’t say that. I know I’ll have to fiddle with something.</p><p>My MacBook is <em>predictable</em>, like a utility. My Surface is <em>unpredictable</em>, with no upside. It wasn’t cheaper, and it doesn’t <strong>behave</strong> any faster. Why should I continue to put energy into it when, to channel Marie Kondo, it doesn’t bring me <em>joy</em>.</p><h3>grork on Twitter</h3><p>Turned my 19H1 Surface Laptop 2 on for the first time in maybe a week. - IDs me &amp;amp; unlocks - ⌨️ &amp;amp; 🐭 don&#39;t work. I assume it&#39;s hung, but power key puts it in sleep/wakes - C-A-D does nothing - But wait, touch works! I&#39;ll reboot.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=833ff628749e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My Mixpanel client library Windows UWP]]></title>
            <link>https://medium.com/@grork/my-mixpanel-client-library-windows-uwp-786aa54eb635?source=rss-1ce68d1d88d------2</link>
            <guid isPermaLink="false">https://medium.com/p/786aa54eb635</guid>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[grork]]></dc:creator>
            <pubDate>Sun, 25 Feb 2018 01:31:14 GMT</pubDate>
            <atom:updated>2020-07-08T22:27:37.332Z</atom:updated>
            <content:encoded><![CDATA[<p><em>I’ve moved my blog, and the current version of this article can be found </em><a href="https://www.codevoid.net/ruminations/2018/02/25/My-mixpanel-client-library-windows-uwp.html"><em>here</em></a></p><p><em>tl;dr: </em>I needed a client for calling <a href="https://www.mixpanel.com/">Mixpanel</a>’s API to log telemetry. Existing ones were either C# or Javascript-Delivered-For-Websites. I wrote one C++. Find source <a href="https://github.com/grork/MixpanelClient">here</a>, and NuGet <a href="https://www.nuget.org/packages/Codevoid.Utilities.Mixpanel">here</a>.</p><p>In my ever ongoing (6 years!) development of an <a href="https://www.instapaper.com/">Instapaper</a> client for Windows, I reached the point where the app is very nearly done. But before I unleashed it on the world, I knew I need to add telemetry to the app. <em>But which service to send it to?</em></p><p>My first requirement was that it had a good library for UWP that was supported in Javascript — e.g. WWA/PWA. The primary motivation wasI didn’t want to add .net to it, since that was another runtime, another garbage collector, another large dependency.</p><p>Turns out <em>no one did that.</em> No one has written a C++ client, or a pure JS implementation meant for offline delivery (E.g. in package). So this set me off on a journey to build my own.</p><p>Thus my next requirement was a <em>well document</em> HTTP API: Turns out <em>those</em> are pretty rare too! After much searching I found Mixpanel:</p><ol><li>Great <a href="https://mixpanel.com/help/reference/http">Documentation</a></li><li>Good reference <a href="https://github.com/mixpanel/mixpanel-iphone">source</a> to understand those poorly captured peccadilloes</li></ol><p>And so I embarked on writing a C++/CX library for uploading to Mixpanel — and 1.5 years later, I’ve finished it, and published v1.0 to the world.</p><p>Things that happened along the way:</p><ol><li>Created a background work queue for processing items, and handing off to some other worker. Turns out there aren’t any good, simple ones for C++ — at least that I could find.</li><li>Learned all about using the stl threading primitives for my worker. I still don’t quite get why there isn’t “Mutex” in the STL that I can create and wait on till it’s signaled — since it really tries hard to take ownership on creation, and on obtaining the lock (rather than waiting to be signaled)</li><li>Created many unit tests to make sure I wasn’t a muppet. And proved that just because you have unit tests doesn’t mean you got it right (see the <a href="https://github.com/grork/MixpanelClient/commit/6d11f5a8260d855dfd0b563df8128b30d0a58e10">most recent unit test</a> I added)</li><li>Learned about creating &amp; publishing nuget packages, including getting an update published to the nuget <a href="https://github.com/NuGet/docs.microsoft.com-nuget/pull/711">documentation</a>.</li><li>Thought <em>way to deeply</em> about the overall architecture</li><li>Accepted the right thing to do was make private APIs visible to my test code to keep a <em>clean</em> public API</li></ol><p>Anyway, I hope it’s useful to someone that isn’t me, and I’m interested in feedback, and suggestions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=786aa54eb635" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Generating Sharable UWP Test Certs]]></title>
            <link>https://medium.com/@grork/generating-sharable-uwp-test-certs-f89491eeef07?source=rss-1ce68d1d88d------2</link>
            <guid isPermaLink="false">https://medium.com/p/f89491eeef07</guid>
            <category><![CDATA[uwp]]></category>
            <category><![CDATA[git]]></category>
            <dc:creator><![CDATA[grork]]></dc:creator>
            <pubDate>Sun, 25 Feb 2018 01:08:15 GMT</pubDate>
            <atom:updated>2020-07-08T22:28:13.392Z</atom:updated>
            <content:encoded><![CDATA[<p><em>I’ve moved my blog, and the current version of this article can be found </em><a href="https://www.codevoid.net/ruminations/2018/02/25/generating-sharable-uwp-test-certs.html"><em>here</em></a></p><p>Have you ever created a UWP project that you check into a Source Control system? Tried to build it on multiple devices, or share with a team? I’m pretty sure you’ve seen the warning from Visual Studio during build saying “Couldn’t find Foo_TemporaryKey.pfx” (*.pfx is in the default .gitignore), or “Cannot import the key file “Foo_TemporaryKey.pfx””.</p><p>I find this frustrating because it makes it difficult to get the quick check of “No warnings, or messages, I must be good” by looking at your output window.</p><p>Thanks to some stuff I had to figure out at <a href="http://www.microsoft.com/">work</a>, I found the right way to generate the keys/certs that you can check in, and don&#39;t require a password. This also has the advantage of working well in a build server environment.</p><p>know, I know “But it’s a cert! It’s super special!”. Sure, but these are your <strong>self-signed</strong> certs. These are used for, at worse, side loading on PC you own. They’re also unchained — there’s no real root cert, so you have to <em>install</em> them, which requires <em>admin rights</em>. There’s minimal spoofing risk, since I dearly hope you’re not using this for broad distribution.</p><p>Before you ask, these certs are only for signing the <em>package</em>, and when you publish through the store, the package is signed with a real cert from Microsoft, <em>not</em> this certificate.</p><p>Anyway, this is a <strong>tl;dr </strong>based on an <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/jj835832(v=vs.85).aspx">MSDN article</a>, which while it claims it is out of date (it probably is), it works:</p><ol><li>Open up a developer Command Prompt</li><li>Change to the directory where you want the files</li><li>Run makecert -sv &lt;a name&gt;.pvk -n “CN=SomeName” &lt;a name&gt;.cer -a sha256 /r /h 0 /eku “1.3.6.1.5.5.7.3.3,1.3.6.1.4.1.311.10.3.13”</li><li>When prompted, <em>don’t</em> enter a password — select ‘None’ (This is the key step to making this smooth</li><li>Then, in that same directory, run pvk2pfx -pvk &lt;a name&gt;.pvk -spc &lt;a name&gt;.cer -pfx &lt;a name&gt;.pfx</li><li>In VS, open the package.appxmanifest, and change to the packaging tab</li><li>Click ‘Choose Certificate…’</li><li>Select your file</li><li>BOOM!</li></ol><p><strong>Note</strong>: If you’re working in a git repository created by VS, it’s default .gitignore file excludes this file from being added to to the repo. You’ll need to use git on the command line to get it added/staged (ditto, for future updates):</p><pre>git add &lt;a name.pfx&gt; --force</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f89491eeef07" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The ogre at the end of the keyboard]]></title>
            <link>https://medium.com/@grork/the-ogre-at-the-end-of-the-keyboard-778d0e7eaf4a?source=rss-1ce68d1d88d------2</link>
            <guid isPermaLink="false">https://medium.com/p/778d0e7eaf4a</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[respect]]></category>
            <category><![CDATA[feedback]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[empathy]]></category>
            <dc:creator><![CDATA[grork]]></dc:creator>
            <pubDate>Fri, 07 Jul 2017 20:46:01 GMT</pubDate>
            <atom:updated>2020-07-08T22:29:12.454Z</atom:updated>
            <content:encoded><![CDATA[<p><em>I’ve moved my blog, and the current version of this article can be found </em><a href="https://www.codevoid.net/ruminations/2017/07/07/the-ogre-at-the-end-of-the-keyboard.html"><em>here</em></a></p><p>I’m not talking about trolls on Twitter, flunkies on Facebook, or the ill-informed on the internet that have you seeing red.</p><p>I’m talking about the calm, peaceful, genuine, and amenable human at the end of a pull request or code review. They just happen to come across as the biggest, most insensitive asshole that you’ve ever had the displeasure to communicate with. And they keep doing it. All the damn time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/1*2AOxvxyXYCSK4XMwet3IpA.gif" /></figure><p>But you can’t avoid these jerks. Pull Requests (nee, Code Reviews) are a fundamental part of software development. Its critical that they’re productive, welcoming, and inclusive. But they’re not:</p><h3>Stephanie Hurlburt on Twitter</h3><p>When you write and/or submit code for review, do you feel emotionally vulnerable? [poll]</p><p>Slack recently published a great article “<a href="https://slack.engineering/on-empathy-pull-requests-979e4257d158">On empathy &amp; Pull Requests</a>”. It’s sentiment reminded me of the constant battle between good &amp; evil that humans have as they give <em>&amp; </em>receive feedback in the little text boxes that appear all over pull requests. Those text boxes — so innocuous, so simple — provide a direct &amp; unshielded way to inflict harm straight to ones core, with but the tiniest barb.</p><h4>Humans aren’t telepathic</h4><p>When you’re reading that code from that peep millions of electrons (20 feet) away, you have the seed of an idea for a comment. You let it grow into a full formed textual representation of that idea, clear to everyone as to your intent, concern and fully conveyed context complete with subtle nuance.</p><p>Except it isn’t. It’s barely coherent, stripped of the tone in your voice, and <em>totally</em> lacking in those unconscious body language cues. You, in fact, sound like a insensitive &amp; uncaring tosser, who has barely taken the time to read and understand what is right in front of you.</p><p>On top of coming across less than favorably, you have failed to <em>actually</em> convey the point we’re originally trying to make. The code author is hurt &amp; angry, and you are annoyed that they can’t grasp such simple feedback. It’s so clear! <em>Right</em>?</p><p>Nope. Humans can’t replay exactly what the other person was thinking; we can’t read minds.</p><p>It’s clear that text isn’t the best form for conveying constructive feedback — without careful authorship, <a href="http://nautil.us/issue/50/emergence/why-you-need-emoji">it lacks all of the non-verbal cues that make us human</a>. But, it’s also the best we have in these situations.</p><p>This means you have to <em>overcompensate</em>. Not by writing <em>more</em>, but by writing <a href="http://www.printwand.com/blog/15-tips-for-writing-in-a-conversational-tone"><em>authentically</em></a>. Read it back — imagine standing next to yourself and saying the words you just typed in the most unflattering way possible. I know it wasn’t meant that way, but by <em>golly</em> it’ll be read that way. Then rewrite it. Use punctuation, <a href="http://nautil.us/issue/50/emergence/why-you-need-emoji">emoji</a>, symbols, links to make it sound like you <em>actually</em> meant it 😇.</p><p>A pull request is not the time to apply English 101, hoping you can make your teachers proud. Think more like those quirky back ‘n forth exchanges you read in your favourite novel.</p><h4>Really, humans aren’t telepathic</h4><p>You’ve written some fantastic, beautiful code. It’s the most <em>amazing</em> code; so simple to read &amp; understand that anyone can follow along like a children’s book.</p><p>Except no-one else can see the <a href="https://m.youtube.com/watch?v=7-GTcHZkfCs">matrix</a> you are seeing. They’ve not spent 3-days understanding all the complexities of this particular component. They haven’t understood the history that led you &amp; the code here. Or heard from the team wizard about why its fucked up the way it is, but it’s the least fucked up it could be.</p><p>To help with this, and to bring clarity to the 200 line &amp; 4 file change, you’ve added a clear message to your commit:</p><blockquote>Bug fixes &amp; adding feature wibble</blockquote><p>I mean, it’s clear from the code changes which bug fixes are present? And the Wibble.* files being added show exactly what the wibble feature is. Not only that, you’ve written copious inline code comments clarifying the <strong>why </strong>of the code, <em>right</em>? Thought not.</p><p>The commit &amp; pull request descriptions are your opportunity to tell a <strong>story</strong> about about the change. It’s a chance to provide information to code archeologists when you are no longer around (or on vacation). It’s a chance to provide clarity today, <em>right now,</em> for this change — for this <em>journey</em>.</p><p>Those details in the description, and in the code itself, are how you calm &amp; salve the ogre at the other end. By ensuring you’ve done your based here, they can be informed enough to provide the best possible feedback.</p><h4>They still can’t read your mind</h4><p>Even when you’ve written the 🎉<strong>best</strong>🎉 pull request message, and you’ve word-smithed your feedback to include just the right gif you still might come across as an ass. You tried your best, but some how something still got misunderstood.</p><p>Then, you, the reader, have to give them the benefit of the doubt. You <strong>have</strong> to assume that wasn’t their intent (if it was, find new coworkers &amp; collaborators). Assume they are sweetness &amp; light. Assume that the code is being authored with the best intentions &amp; motivation, it has reason &amp; logic behind it, and was intended to be that way for <em>good</em> reasons.</p><p>If you just can’t do that, go talk to the other person. 📞 them. IM them. Approach them from the side of <em>you</em> being the one at fault — not screaming down the pipe at them about being an insensitive arse. Chances are it’s just a small miscommunication.</p><p>Remember, most of all:</p><blockquote><strong>We’re all in this together.</strong></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=778d0e7eaf4a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Always be looking ahead. Not everyone is an asshole.]]></title>
            <link>https://medium.com/@grork/always-be-looking-ahead-not-everyone-is-an-asshole-79b48198a844?source=rss-1ce68d1d88d------2</link>
            <guid isPermaLink="false">https://medium.com/p/79b48198a844</guid>
            <dc:creator><![CDATA[grork]]></dc:creator>
            <pubDate>Mon, 29 May 2017 18:53:04 GMT</pubDate>
            <atom:updated>2020-07-08T22:30:11.272Z</atom:updated>
            <content:encoded><![CDATA[<p><em>I’ve moved my blog, and the current version of this article can be found </em><a href="https://www.codevoid.net/ruminations/2017/05/29/always-be-looking-ahead.html"><em>here</em></a></p><p>Recently, I was watching a talk by <a href="https://twitter.com/drance">Matt Drance </a>from his 2015 CocoaConf talk “<a href="https://vimeo.com/131824328">What The Race Track Taught Me About Software Development</a>”. I wanted to watch it because I’ve found his tweets &amp; writings in the past to be interesting &amp; thought provoking — that and I like to think I’m kinda a car guy. Race tracks? Software development? Sure, this should be fun!</p><p>It’s message is not so much that <em>racing</em> is the lens through which to view everything because, <em>gosh</em>, racing is just so <em>super fantastic</em>. It’s the <strong>perspective</strong> with which you view your work — no matter what that work is. Looking not at just today, or tomorrow, but next week, month, year <em>all</em> the time.</p><p>There are so many facets. The idea that the obvious direct path might not actually be the fastest is key— sometimes you’ve got to slow down to go faster. The idea that to move faster, add more features, and fix more bugs, you need to slow down a little to create a clearer path forward. This isn’t because slowing down gives you more time to work out <em>what’s next</em>, it’s because that speed reduction allows you to take a <strong>more direct path</strong> to your chosen destination. You can take the opportunity to approach the problem a little more radically <em>because</em> you’re not travelling 1,000 MPH towards oblivion.</p><blockquote>“The thing about fundamentals, is they scale. They work at any level”</blockquote><p>This perspective, this approach, this <em>skill</em> is something that once understood, and applied habitually, is able to be carried forward to larger problems. Matt calls out that if you <em>understand</em> the fundamental patterns, practices in a project with 20 files, you can apply them with equal competency to a project of 2,000 files. It scales — it’s all the same <em>perspective.</em></p><p>I was especially enamored towards the end where Mr. Drance brought in a clip where one racer adjusts the mirror of the racer close beside them, and says:</p><blockquote>“If you’re not trolling, you’re not friends”</blockquote><p>The clarification and reiteration that this is clearly between people who are <em>friends</em> but yet are able to <strong>compete</strong> and strive to excel at what they do; you don’t start a race with no intent of <em>racing</em>, but that doesn’t have to mean dog-eat-dog, and a culture of animosity.</p><p>The people we work with are all there to pull in the same direction — to move things forward, to make progress with whatever endeavor is being engaged in. Sure, there are different motivations, and different stories about why people are there, but it’s not just the best place to start from.</p><p>It’s the only way.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=79b48198a844" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[co_wait, C++/CX and the UI Thread]]></title>
            <link>https://medium.com/@grork/co-wait-c-cx-and-the-ui-thread-f9abd77350a3?source=rss-1ce68d1d88d------2</link>
            <guid isPermaLink="false">https://medium.com/p/f9abd77350a3</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[uwp]]></category>
            <category><![CDATA[windows-10]]></category>
            <dc:creator><![CDATA[grork]]></dc:creator>
            <pubDate>Tue, 17 Jan 2017 01:28:31 GMT</pubDate>
            <atom:updated>2020-07-08T22:31:25.363Z</atom:updated>
            <content:encoded><![CDATA[<p><em>I’ve moved my blog to a new location, and the current version of this article can be found </em><a href="https://www.codevoid.net/ruminations/2017/01/16/co-await-ui-thread.html"><em>here</em></a><em>.</em></p><p>I was working on some supporting code for my Windows 10 Instapaper client, and I ended up going down a rabbit hole of trying to understand the way that co_await works with the XAML/WinRT dispatcher. I ended up writing some sample code &amp; sharing on <a href="https://github.com/grork/CoAwaitUIThread">GitHub</a>. I’ve included the readme below, but the most up to date details will be on the <a href="https://github.com/grork/CoAwaitUIThread">repo</a>.</p><h3>Readme</h3><p>This project is an example of how to wrangle co_await with C++/CX into a situation where it can be used to enforce contuation of the work on the UI Thread.</p><h3>Usage</h3><p>You need to co_await onto the UI thread? (Or, any specific thread). To do that, you need to allocate the thread_context, and then await on that when you need to continue on the UI thread.</p><pre>#include “AwaitHelperWinRT.h”<br>ref class MyControl sealed // Allocate me on the UI thread<br>{<br>  await_asynchelper::thread_context ui_thread;<br>  event Windows::UI::Xaml::RoutedEventHandler^ MyEvent;<br>  concurrency::task&lt;void&gt; DoWork() // Call me somewhere else thats not the UI thread<br>  {<br>    co_await ExpensiveWork();<br>    co_await this-&gt;ui_thread;<br>    this-&gt;MyEvent(this, null); // Completes on UI thread<br>  }<br>}</pre><p>You can see simple usage of this in the app that is included here. Take a look, click both buttons, and hopefully that will help clarify whats going on.</p><h3>Background</h3><p>Normally, when working with the PPL, one would provide a <a href="https://msdn.microsoft.com/en-us/library/hh749968.aspx">continuation context</a> to the continuation specifying where that block would complete.</p><p>When working with co_routines &amp; co_await, the implementation of the PPL to co_await adapter defined in pplawait.h, will provide you behaviour similar to use_default. e.g. if you start on the UI thread, it’ll end on the UI thread. Great! But what if you need to ensure that while your work is initiated from any thread, you need it to get back to the UI thread? Turns out that is a pain in the rear.</p><p>Example 1</p><pre>task&lt;bool&gt; GetAnAnswer();</pre><pre>void MyWork()<br>{<br>    GetAnswer().then([] {<br>        // Will execute in the apartment where .then was invoked<br>    )); // Default it tast_continuation_context::use_default<br>}</pre><p>Example 2</p><pre>task&lt;bool&gt; GetAnAnswer();</pre><pre>void MyWork()<br>{<br>    GetAnswer().then([] {<br>        // Will execute wherever the PPL decides<br>    ), task_continuation_context::use_arbitary);<br>}</pre><p>Example 3</p><pre>task&lt;bool&gt; GetAnAnswer();</pre><pre>void MyWork()<br>{<br>    GetAnswer().then([] {<br>        // Will execute on the WinRT context, irrespective of where the prior task came from<br>    ), task_continuation_context::use_current);<br>}</pre><h4>co_await, co_routines</h4><p>At the time of writing, I don’t think I could claim to be an expert in the wonders of co_await &amp; friends. What I <em>do</em> know is that writing code using co_await is significantly cleaner &amp; easier to read than the PPL &amp; it’s promise-like syntax. Because of that I was using co_await in my code, and struggling understand where &amp; how the “continuation” of the co_routines were going to execute.</p><p>After some diving, and consultation on <a href="https://twitter.com/kennykerr/status/821086254443872256">twitter</a>, I think I understand enough to leverage some code from <a href="https://github.com/microsoft/cppwinrt">C++/WinRT</a>, to allow me to create the helper here.</p><h3>Resources</h3><p>I recommend watching these videos:<br><a href="https://www.youtube.com/watch?v=v0SjumbIips">Putting Coroutines to work with the windows runtime</a><br><a href="https://www.youtube.com/watch?v=8C8NnE1Dg4A">C++ Coroutines: Under the covers</a></p><p>Reading these blog posts:<br><a href="https://kennykerr.ca/2016/11/11/cppwinrt-fun-with-agility/">C++/WinRT: Fun With Agility</a><br><a href="https://blogs.msdn.microsoft.com/vcblog/2015/11/30/coroutines-in-visual-studio-2015-update-1/">coroutines in Visual Studio 2015 Update 1</a></p><p>If you’re feeling particularly inclined to go <em>deep</em>:</p><p><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0057r7.pdf">Wording for Coroutines (Or, the actual spec)</a><br><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0054r0.html">Coroutines: Reports from the field</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f9abd77350a3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[FileDeduper]]></title>
            <link>https://medium.com/@grork/filededuper-f5fcb10e7733?source=rss-1ce68d1d88d------2</link>
            <guid isPermaLink="false">https://medium.com/p/f5fcb10e7733</guid>
            <category><![CDATA[backup]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[grork]]></dc:creator>
            <pubDate>Sat, 07 Jan 2017 23:44:18 GMT</pubDate>
            <atom:updated>2020-07-08T22:32:09.493Z</atom:updated>
            <content:encoded><![CDATA[<p><em>I’ve moved my blog, and current version of this article can be found </em><a href="https://www.codevoid.net/ruminations/2017/01/07/file-deduper.html"><em>here</em></a></p><p>I’ve authored a tool called <a href="https://github.com/grork/FileDeduper">FileDeduper</a>, which scavenges a file system, MD5-hashes all the files, and then moves all the <em>duplicates </em>to a destination directory keeping the original tree structure. The intent with “move” rather than “delete” was to keep data rather than accidently delete it. Sure, the MD5 hash should mean this isn’t a risk, but you know, safety first.</p><p>The dataset that spurred me to write this tool was 2TB, with ~5.3 million files. Here are some interesting performance stats.</p><ul><li>Time to discover the files: 21min (3min 40s if file system was cached)</li><li>Time to hash all the files: 15hrs 37min</li><li>Duplicates found: 1.5 millon</li><li>Time to “move” 1.5million duplicates: 15hrs</li><li>Peak Memory usage: 4gb</li></ul><p>Tool is <a href="https://github.com/grork/FileDeduper">here</a>, and I hope someone other than me finds it useful one day.</p><h3>Why</h3><p>About a year ago, my dad passed away, and in the process of clearing out his things, I realized that one of the important things to make sure I got, was a copy of all of his <em>digital</em> files. <em>Sure</em><strong><em> </em></strong>where<strong> reams </strong>of physical documents too, and as my brother &amp; I sorted that all out we found lots of interesting things. But I knew that just as he kept meticulous copies of his <em>physical</em> paper, he did the same with his <em>digital </em>documents &amp; data.</p><p>So, while I was there, I made a backup of all of his local digital data to a 2TB portable USB drive, which it completely filled. I wasn’t sure what to <em>do</em> with 2TB of data, but I knew I wasn’t ready to start pulling it apart.</p><p>When I finally felt able to take a look at the drive a few months later, I realized how much there was, and he’d been using one of his drives “backup” for a set of automated backups. This meant regular snapshots of 1000s of the files (many unchanged). This left me with the challenge of working out what the <em>unique </em>set of files that contained the real data.</p><p>Being the software peep that I am, I concluded the answer was to write some software…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f5fcb10e7733" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>