<?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 J. Cookie (they/them) on Medium]]></title>
        <description><![CDATA[Stories by J. Cookie (they/them) on Medium]]></description>
        <link>https://medium.com/@j5cookie?source=rss-fe348c9b94b1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*wLZyYQo0gyHazLhVOp_caQ@2x.jpeg</url>
            <title>Stories by J. Cookie (they/them) on Medium</title>
            <link>https://medium.com/@j5cookie?source=rss-fe348c9b94b1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 06:23:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@j5cookie/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[3D Models from 2D Illustrations Using Copilot and Meshy]]></title>
            <link>https://j5cookie.medium.com/3d-models-from-2d-illustrations-using-copilot-and-meshy-928261dc88d4?source=rss-fe348c9b94b1------2</link>
            <guid isPermaLink="false">https://medium.com/p/928261dc88d4</guid>
            <category><![CDATA[3d-modeling]]></category>
            <category><![CDATA[illustration]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[J. Cookie (they/them)]]></dc:creator>
            <pubDate>Thu, 11 Dec 2025 23:25:35 GMT</pubDate>
            <atom:updated>2025-12-11T23:25:35.464Z</atom:updated>
            <content:encoded><![CDATA[<p>I recently had the need to develop a 3D model, for printing and possible animation, from a 2D illustration.</p><p>I did some searching and it looked at the time like MS Copilot AI could do the job, with no costs. Win!</p><h3>2D to 3D-Like</h3><p>I signed onto Copilot and added my illustration to the prompt. I wrote the text portion of the prompt instructing Copilot to create a 3D model of the ghost.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/709/1*6jLVOK3m7-E5ot4dAt_KrA@2x.jpeg" /></figure><p>Illustration by Rob Bursk from <a href="https://www.etsy.com/shop/RobsOccult">Rob’s Occult</a></p><blockquote>Make a 3d model from this image of a ghost</blockquote><p>Copilot generated this image from the illustration:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*rgtBdMyCEkKmWF0nw6tXxQ@2x.jpeg" /></figure><p>I continued my prompts to the AI to tweak the results and get closer to what I wanted.</p><p>When I asked Copilot to provide a model to download, I discovered that it was not able to provide one.</p><p>However, I had the suspicion that this 3D-like illustration would prove a very good source for another AI that could actually generate 3D file formats like STL, OBJ, etc.</p><h3>3D-Like Source to 3D Model</h3><p>My first attempt at converting the Copilot version into a model was done in the experimental Copilot 3D application. It actually did an excellent job, barring the fact that it only gave my 8 eyed ghost 6 eyes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*Jct3ff2yIjUQ_P8mNZQ09w@2x.jpeg" /></figure><p>Copilot 3D model</p><p>After some research, I ended up using Meshy.ai and its version 6 preview to generate my model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*x5x1RX2kdykAs01diKKBkA@2x.jpeg" /></figure><p>Meshy 6 Preview Model</p><p>The model shown went through several iterations of the whole process, but illustrates the results you can achieve with a little bit of effort.</p><p>I hope that you can add this process to your toolset and also get good results.</p><p>Meshy.ai offers a free month to me and you if you use my <a href="https://www.meshy.ai/?utm_source=referral-program&amp;utm_medium=link&amp;utm_content=J0WAJ3">referral link</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=928261dc88d4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Scoping TailwindCSS ‘Preflight’ for Injected Apps]]></title>
            <link>https://j5cookie.medium.com/scoping-tailwindcss-preflight-for-injected-apps-c30152f6dd8d?source=rss-fe348c9b94b1------2</link>
            <guid isPermaLink="false">https://medium.com/p/c30152f6dd8d</guid>
            <category><![CDATA[tailwind-css]]></category>
            <category><![CDATA[browser-extension]]></category>
            <category><![CDATA[scopes]]></category>
            <dc:creator><![CDATA[J. Cookie (they/them)]]></dc:creator>
            <pubDate>Thu, 10 Jul 2025 18:06:43 GMT</pubDate>
            <atom:updated>2025-07-10T18:06:43.822Z</atom:updated>
            <content:encoded><![CDATA[<p>TailwindCSS’ ‘preflight’ styles resets CSS properties, such as making all img tags display: block, to give you a clean canvas to start your design with.</p><p>That’s great, but when you’re injecting your own script and UI into an existing site, those ‘preflight’ styles can cause significant challenges.</p><p>In order to get around them, we need to scope the preflight styles to a particular element, while leaving the rest of the TailwindCSS styles alone.</p><p>Building on the explanation of ‘preflight’ <a href="https://tailwindcss.com/docs/preflight">here</a>, we split up our import of TailwindCSS. Instead of the simple:</p><pre>@import &#39;tailwindcss&#39;;</pre><p>We expand it, and wrap our scoping selector around the ‘preflight’.</p><pre>@layer theme, base, components, utilities;<br><br>@import &quot;tailwindcss/theme.css&quot; layer(theme);<br>#extension-root {<br>  @import &quot;tailwindcss/preflight.css&quot; layer(base);<br>}<br>@import &quot;tailwindcss/utilities.css&quot; layer(utilities);</pre><p>I hope this tip helps you in your attempts to integrate TailwindCSS with an injected app such as a browser extension content script.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c30152f6dd8d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Client-side Side Effects, useActionState, Next.js: A Custom Hook]]></title>
            <link>https://j5cookie.medium.com/client-side-side-effects-useactionstate-next-js-a-custom-hook-624fb9ef2a7b?source=rss-fe348c9b94b1------2</link>
            <guid isPermaLink="false">https://medium.com/p/624fb9ef2a7b</guid>
            <category><![CDATA[useactionstate]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[redux]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[nextjs]]></category>
            <dc:creator><![CDATA[J. Cookie (they/them)]]></dc:creator>
            <pubDate>Thu, 22 May 2025 22:17:54 GMT</pubDate>
            <atom:updated>2025-05-22T22:28:03.898Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-cVmKbnSZur81fvOJKQbxw.jpeg" /></figure><p>I’m still working on my Next.js project and encountered some more difficulties. How could I conveniently produce side effects to run on the client-side that are triggered by state changes made by server-side code?</p><p>My server-side code … action functions run by useActionState as a result of a user submitting a form.</p><pre>export function LoginForm() {<br>  const [state, formAction, isPending] = useActionState(doLogin, {});<br><br>  return (<br>    &lt;form action={formAction}&gt;<br>      &lt;button type=&quot;submit&quot;&gt;Log In&lt;/button&gt;<br>    &lt;/form&gt;<br>  );<br>}</pre><p>The side effects in my case: redux state updates.</p><p>Initially I tried to put the dispatch calls inside the doLogin function, but of course that doesn’t work because of the separation of client and server code execution.</p><p>The answer is our trusty useEffect hook friend, with the state as a dependency.</p><pre>export function LoginForm() {<br>  const dispatch = useDispatch();<br>  const [state, formAction, isPending] = useActionState(doLogin, {});<br><br>  useEffect(() =&gt; {<br>    dispatch(onLogin(state));<br>  }, [state]);<br><br>  return (<br>    &lt;form action={formAction}&gt;<br>      &lt;button type=&quot;submit&quot;&gt;Log In&lt;/button&gt;<br>    &lt;/form&gt;<br>  );<br>}</pre><p>That little gem wasn’t too hard to find, but still didn’t come up easily in my searches.</p><p>But I wasn’t too happy with the resultant code, because I’m probably going to be doing things like this quite a bit.</p><p>So I made a custom hook which extends useActionState and introduces callbacks into the equation. And of course it is done in TypeScript with generics :)</p><pre>import { useActionState, useEffect, useState } from &#39;react&#39;;<br><br>export type UseActionStateWithCallbacksParams&lt;T, U = void&gt; = {<br>    action: Parameters&lt;(typeof useActionState&lt;T&gt;)&gt;[0];<br>    initialState: Parameters&lt;(typeof useActionState&lt;T&gt;)&gt;[1];<br>    callbacks?: ((state: T) =&gt; U)[];<br>    permalink?: Parameters&lt;(typeof useActionState&lt;T&gt;)&gt;[2];<br>};<br><br>/*<br> A hook which combines `useActionState` with a `useEffect` to run callbacks<br> every time that the state changes.  An array of results is returned as part<br> of the output of the function.<br><br> Other than using a params object, this hook is backwards compatible with<br> `useActionState`, because `callbacks` may be undefined or empty.<br> */<br>export const useActionStateWithCallbacks =<br>    &lt;T, U = void&gt;(params: UseActionStateWithCallbacksParams&lt;T, U&gt;):<br>        [T, () =&gt; void, boolean, U[]] =&gt; {<br>    const { action, callbacks, initialState, permalink } = params;<br>    const [state, formAction, isPending] = useActionState&lt;T&gt;(action, initialState, permalink);<br>    const [results, setResults] = useState&lt;U[]&gt;([]);<br><br>    useEffect(() =&gt; {<br>        if (!callbacks?.length) {<br>            return;<br>        }<br>        setResults(callbacks.map(callback =&gt; callback(state)));<br>    }, [callbacks, setResults, state]);<br><br>    return [state, formAction, isPending, results];<br>};</pre><p>I hope that you can find this custom hook useful in your own projects. If you do, please respond and let me know!</p><p>Any changes to the code and additional utility hooks will be placed in my repository at <a href="https://github.com/j5bot/cooksHooks">https://github.com/j5bot/cooksHooks</a>.</p><p>Happy coding!</p><p>Source <a href="https://www.flickr.com/photos/jonavi/37509663536/in/photolist-Z9AQ9Q-XKWMmC-oX6s8F-m5bt3s-7n4MH9-6chpd-XKWMvq-7Swvfb-9ef5n1-24GAJut-c3Gm4o-dsFSCq-ogyP8L-nX1W7y-21YTgZU-2hYy4TM-54cb7f-2hiTBHE-JQXMXq-2gTmtuG-2h5RvAM-chnocy-uh4B5-SCRAWH-4mtmNu-24mW3Eo-8gRm8b-229B8Ch-8daNqn-4FVobe-JEeqx-cmVtij-6z9EJA-poEku-q7WzHc-2nrCDM-dkH41d-2sCRX3-fobWwC-2nw2db-2syuz4-d3X8cN-8py4hy-bvFPKQ-5sSPHp-574kYr-bEsvgJ-5mtDYG-KvNaa-a51GCe">photo by Jose Navarro</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=624fb9ef2a7b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Next.js Dynamic Imports from CDN]]></title>
            <link>https://j5cookie.medium.com/next-js-dynamic-imports-from-cdn-669e829d9540?source=rss-fe348c9b94b1------2</link>
            <guid isPermaLink="false">https://medium.com/p/669e829d9540</guid>
            <category><![CDATA[cdn]]></category>
            <category><![CDATA[dynamic-import]]></category>
            <category><![CDATA[nextjs]]></category>
            <dc:creator><![CDATA[J. Cookie (they/them)]]></dc:creator>
            <pubDate>Mon, 19 May 2025 21:44:53 GMT</pubDate>
            <atom:updated>2025-05-19T22:00:05.868Z</atom:updated>
            <content:encoded><![CDATA[<p>I’ve recently been working on a project in Next.js and experiencing build problems.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vjZ28HvUrvGBgz6a2xrYyQ.jpeg" /></figure><p>As part of the project, I’m leveraging my <a href="https://github.com/react-barcode-scanner/components">@react-barcode-scanner/components</a> package, which in turn uses <a href="https://github.com/undecaf/barcode-detector-polyfill">@undecaf/barcode-detector-polyfill</a> as a fallback if one’s browser doesn’t support the BarcodeDetector API.</p><p>When attempting to run/build the new app, I recevied errors like these, when using Turbopack:</p><pre>Code generation for chunk item errored<br>An error occurred while generating the chunk item [project]/node_modules/.pnpm/@undecaf+barcode-detector-polyfill@0.9.21/node_modules/@undecaf/barcode-detector-polyfill/dist/main.js [app-client] (ecmascript)<br><br>Caused by:<br>- the chunking context (unknown) does not support external modules (request: https://cdn.jsdelivr.net/npm/@undecaf/zbar-wasm@0.9.15/dist/main.js)<br><br>Debug info:<br>- An error occurred while generating the chunk item [project]/node_modules/.pnpm/@undecaf+barcode-detector-polyfill@0.9.21/node_modules/@undecaf/barcode-detector-polyfill/dist/main.js [app-client] (ecmascript)<br>- Execution of &lt;ModuleChunkItem as EcmascriptChunkItem&gt;::content_with_async_module_info failed<br>- Execution of EcmascriptModuleContent::new failed<br>- the chunking context (unknown) does not support external modules (request: https://cdn.jsdelivr.net/npm/@undecaf/zbar-wasm@0.9.15/dist/main.js)</pre><p>Or this, with Turbopack turned off:</p><pre>Module build failed: UnhandledSchemeError: Reading from &quot;https://cdn.jsdelivr.net/npm/@undecaf/zbar-wasm@0.9.15/dist/main.js&quot; is not handled by plugins (Unhandled scheme).<br>Webpack supports &quot;data:&quot; and &quot;file:&quot; URIs by default.<br>You may need an additional plugin to handle &quot;https:&quot; URIs.</pre><p>When searching for answers based on keywords from the errors, I wasn’t able to find a solution.</p><p>Eventually I dug up the urlImports option, which is added into nextjs.config.js, nested under experimental configuration key.</p><p>(<a href="https://nextjs.org/docs/app/api-reference/config/next-config-js/urlImports">API Reference</a>)</p><p>Specify one or more URLs in a string array as the value for the option, and your dynamic imports from CDNs will begin to work.</p><p>This is the config that I added:</p><pre>const nextConfig = {<br>  // ...<br>  experimental: {<br>    urlImports: [&#39;https://cdn.jsdelivr.net/&#39;],<br>  },<br>};</pre><p>I hope this quick article helps some of you out there who encounter the same problems importing from CDNs with Next.js.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=669e829d9540" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ghostbusters: the Spirit Life-Size, Zap & Blast Mashup Wand]]></title>
            <link>https://j5cookie.medium.com/merging-a-spirit-life-size-wand-and-zap-and-blast-proton-blaster-0912455ae5e8?source=rss-fe348c9b94b1------2</link>
            <guid isPermaLink="false">https://medium.com/p/0912455ae5e8</guid>
            <category><![CDATA[wand]]></category>
            <category><![CDATA[ghostbusters]]></category>
            <category><![CDATA[toý]]></category>
            <category><![CDATA[spirit-halloween-store]]></category>
            <dc:creator><![CDATA[J. Cookie (they/them)]]></dc:creator>
            <pubDate>Mon, 22 Apr 2024 20:07:09 GMT</pubDate>
            <atom:updated>2024-10-11T17:15:43.055Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zod273yhHFE0VuNk4Hoj1A.jpeg" /><figcaption>Finished Spirit Life-Size, Zap &amp; Blast Mash-Up Wand</figcaption></figure><p>I wanted to have a neutrona wand that I could hand over to kids (and adults) when taking photos without being too worried that they would break it.</p><p>I asked around and a fellow <a href="https://ghostbustersva.com/">Ghostbusters Virginia</a> member was kind enough to give me his no-longer-needed Spirit Life-Size wand.</p><p>My first idea was simply to wire up the light inside and leave it at that.</p><p>Then I found out that the Hasbro Ghostbusters Zap &amp; Blast Proton Blaster was on sale at Walmart. This little spud has a lot of sounds and functions, similar even to the Spengler / 1984 wands that cost $100 or more.</p><p>I was hoping to score it for $13 like some others, but I ended up having to pay $25 for it. Anywho…</p><p>Here’s how to integrate the electronics from your Zap &amp; Blast into your spare Spirit Life-Size Neutrona Wand.</p><figure><img alt="Ghostbusters Hasbro Zap and Blast Proton Blaster" src="https://cdn-images-1.medium.com/max/640/1*XJar8TGjGv4T8xFmNjjnNA.jpeg" /><figcaption>Zap and Blast</figcaption></figure><p>Other stuff you’ll need…</p><h4>Parts &amp; Materials</h4><ul><li>Mini toggle switch</li><li>Thin gauge wire (can use excess wire from Spirit wand if available)</li><li>Heat shrink tube</li><li>Three AAA or three AA battery pack</li><li>Electrical tape</li></ul><h4>Tools</h4><ul><li>Rotary tool (aka Dremel)</li><li>Small drill bit</li><li>Saw rotary bit</li><li>Cutting rotary bit</li><li>Hobby / small hand saw</li><li>Wire cutters</li><li>Wire stripper</li><li>Soldering iron &amp; solder</li><li>Hot glue gun and glue</li></ul><h4>Optional</h4><ul><li>Second mini toggle switch</li><li>Super glue or other glue</li><li>Hook-and-loop dots or strips</li></ul><p>Electronics-wise, the Zap &amp; Blast has:</p><ul><li>Activation button (also referred to here as ‘power up’, which triggers when you pull the front piece forward)</li><li>Mode button and multicolor mode LED</li><li>Some top button that they call ‘Charge’ that makes noises?</li><li>A trigger “Intensify” button</li><li>‘Tip’ tube with lights (4 LEDs)</li></ul><p>The Spirit wand has:</p><ul><li>On/off button (momentary)</li><li>Slo-Blo / fire button (momentary)</li><li>‘Tip’ tube with single light</li></ul><p>Inside, the Zap &amp; Blast has:</p><ul><li>Mode button and LED board</li><li>Main board</li><li>Speaker</li><li>3 small boards, each with a momentary switch (activation, top, trigger)</li></ul><p>Let’s see a photo of the Zap &amp; Blast main board, with the wires labelled</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fBtA43PgeqvjgIuaKqbUEg.jpeg" /></figure><h4>Disassembling the Wands</h4><p>Disassemble the Zap &amp; Blast.</p><p>We’ll keep the clear and silver tubes from the mode switch.</p><p>Otherwise, this thing is a goner. I wouldn’t bother keeping the screws or anything safe.</p><p>Carefully disassemble the life-size wand. Keep the screws safe. You don’t need to take off the left-side activate / intensify box if you don’t plan on trying to put an “Intensify” switch inside of it.</p><h4>Preparing Before Electronics</h4><p><strong>Mode Light Hole</strong></p><p>Use a screwdriver / drill / dremel / whatever to pop the top ORANGE ‘button’ out of the top of the life-size wand.</p><p>Drill / cut through the ‘frame’ around the internal cube-like thing under the ‘button’. After you’re done, it should look something like this…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hHSfFVhxgsOJc3LMVHODHA.jpeg" /><figcaption>Mode Light Hole</figcaption></figure><p>Clean it up however much you want with a file or what have you, now or later.</p><p><strong>Switch Holes</strong></p><p>Here we’re going to make holes for the activation switch and an optional power switch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DFQm_BXEbMWMs2IcftCxuw.jpeg" /></figure><p>Unscrew one or both of the two fake toggle switches above the buttons.</p><p>Use your rotary tool saw to cut the interior post(s) down and leave a nice hole for your toggle switch(es).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*29JVvbWXyK-9xs6d-mRWwA.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5W-qHy8qqh-bXdZmDkh4JQ.jpeg" /></figure><p><strong>Mode Light Top</strong></p><p>Use your saw (not your rotary saw, because ouch!) to saw off the top of the clear portion of the mode switch. We’re going to glue that above the Mode Light Hole later.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3SSWCjLI12CRTwxXL_bbXQ.jpeg" /></figure><p><strong>Speaker Holes</strong></p><p>We’ll use our drill bit and rotary tool to drill some holes in between the ‘heat sink’ fins so that we can hear our speaker.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7tmWi90diWTZBlH5fvpbcw.jpeg" /></figure><p>Since the speaker is likely going to be mounted towards the front handle of the wand, you’ll want to start towards there (1st or 2nd fin) and do holes between the next 3 or 4 more fins. Try to make your first and last columns shorter to account for the round shape of the speaker. I didn’t really do this, so do better than your teacher, rookie!</p><p><strong>Tip Tube LEDs Channel</strong></p><p>Use a rotary tool bit like the one pictured to expand the hole in the tip tube of the life-size wand which previously accommodated the single LED into a channel that will allow the Zap &amp; Blast LED board to pass through. I intended to make the channel perpendicular to the mounting holes, but that didn’t work out. Do your own thing here!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WcDyUT4BYJJvxTX9cCCTcw.jpeg" /></figure><h4>Cuttin’ Wires</h4><p>Before we go any further, we’ll cut wires on the life-size wand and on the Zap &amp; Blast innards.</p><p><strong>Life-Size Wand</strong></p><ol><li>Cut the gray wire which goes from the Spirit Life-Size wand’s black (on/off) switch to the red switch, at the red switch. This means you’ll have black and gray wires on the black switch and red and white wires on the red switch.<br>See the photo later of life-size wand wiring to make sure you’re making the proper cut.</li><li>Cut the black, red, and white wires down to a manageable length. Something like 6–10 inches is probably good. Keep the excess wire to use later.</li><li>Keep the orange wires, which can be useful later.</li></ol><p><strong>Zap &amp; Blast</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X2n2mBiufLVsTRVRTs-9LA.jpeg" /><figcaption>Yellow ‘Power Up’ Wires</figcaption></figure><p>Cut the momentary switch off of the yellow wires (power up wires).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ljYLpYnhzRY93cFTxj0OOQ.jpeg" /></figure><p>Cut the wires connected to the mode board’s SW+ and SW- pads (mine are blue and purple wires). Leave some lead on the wires, in case you somehow cut the wrong ones and need to reconnect them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HucnqBl3Pm8fNEtjnJoNrg.jpeg" /></figure><p>Cut the blue wires from the main board to the trigger switch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QZXg9EBgqJYGlnzp6THm7g.jpeg" /></figure><h4>Electronics (Part the First)</h4><p>Before you do any soldering, remove the batteries.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-y4fHLRpCukW-yrdNnn-mQ.jpeg" /></figure><p>The above is the general plan for wiring. You’re not going to do final wiring yet, but you do want to lengthen the wire run in several places to make things easier later.</p><p><strong>Lengthening Wires</strong></p><p>Lengthen the wires from</p><ul><li>Mode switch (blue/purple attached to the main board)</li><li>On/off switch (gray wire attached to the Life-Size wand)</li></ul><p><strong>Adding Wires</strong></p><p>Add wires to your toggle switch(es).</p><p>For the ‘activate’ switch, use yellow wire if possible, or your orange wire from the Life-Size scrap.</p><p>Optionally, for the ‘power’ (not ‘power up’) switch, use red wire if possible (I used extra from the wire cut off of the Life-Size switch wire run).</p><h4>Mounting Stuff</h4><p>Before we start mounting things, let’s see a photo of the finished ‘main’ mounting…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5WuIXiGTCoiw39VcXhmaVg.jpeg" /></figure><p>You’ll want to bend the wires out from the main board so that this configuration is as easy as possible to achieve.</p><ul><li>mode board wires at the ‘front’ of the main board, towards the large cavity of the wand</li><li>tip LED wires at the ‘top’ of the main board, toward the ‘box’ side of the wand</li><li>speaker wires at the ‘bottom’ of the main board, toward the ‘heat sink’ side of the wand</li></ul><p>Heat ’em up! Get your glue gun warm and ready.</p><p><strong>Mode Board</strong></p><p>The mode board is the hardest piece to mount, since we have to do it from the top, so we’ll mount it first.</p><p>Noting that the wires must be facing ‘inward’ and not towards the shell of the wand, we’ll place the mode board with the LED facing down and as centered as possible in the mode light hole.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LZEqK0LAhJZ8DjmFGbpW1w.jpeg" /></figure><p>We’ll need to hold the board in place as we flip the wand over. With the other other hand, use your glue gun to glue the board in from the top. Keep the board pushing against the top and side of the inside as much as possible.</p><p>You’ll need to hold it in place until the glue dries enough to do that for you. The LED is plenty bright to shine through the glue, so don’t worry about that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jJEPm4j1uk8gFzI2nJ_Kew.jpeg" /></figure><p>When dry enough, flip the wand back over and glue down along the side of the wand, where it meets with the mode board. Just dump as much glue on there as you think might be needed. I think I only glued that one side down. You’ll also have to hold this while it cools.</p><p><strong>Main Board</strong></p><p>The main board mounts on top of a screw, between the big cavity in the top of the wand and the handle.</p><p>Before you go any further, you’ll need to make sure that screw can’t short out the board. Put some electrical tape on top of the screw.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S6YGHoyHs183Oj632QWqCA.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CreZMujMgyBvOoNEDbLwrg.jpeg" /></figure><p>Just dump hot glue down the four corner mounting holes in the main board. It isn’t conductive, so we don’t have to worry about shorting it with the glue. You’ll have to hold it down while it cools for the first one or two corners.</p><p><strong>Speaker</strong></p><p>The speaker is easy to mount. Just dump down hot glue between it and the side ‘wall’ and then glue down the other side.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g_lsLwJCXe11xvQaHWzSog.jpeg" /></figure><p><strong>Battery Pack</strong></p><p>I mounted my battery pack ‘tall’, with the main portion facing towards the outside, on the opposite side to the speaker (‘box’ side).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Obvd-SiBgbefmF6c_p7gHA.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7h9z0InL1rQqBpX-MoIjVg.jpeg" /></figure><p>To make it easier to remove and remount, I used hook-and-loop dots that I had around.</p><p><strong>Tip Tube Assembly</strong></p><p>For the tip tube, we’ll slide the LED board through the channel we cut earlier, inserting the outer silver tube from the Mode Switch into the front of the tube. We’ll fit the front of the LED board with the forward LED into the inside of the silver tube and position the silver switch tube just forward of the tip tube’s first silver ‘ring’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z_LpGlkloOfEKjkieeUn-w.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rQV3gD_xAi9tWAwrYJF6Jg.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*51DOzBGOff495e7aCxHPLA.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jLZEIkatKCKeEN1yGURWow.jpeg" /></figure><p>To actually get it attached to the wand, we’ll need to cut the post which goes through the mounting holes. This photo shows it cut down, but not quite short enough. Use your rotary or other tool to shave it down just a little bit if you need to.</p><p><strong>Tip Tube Mounting</strong></p><p>Here is a photo of the mounted tip tube.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-dtgxizWRCLOKlDfOB0NWg.jpeg" /></figure><p>Yep, that’s mounted. You’ll have hot glued the ever-lovin’ snot out of it, but CAREFULLY making sure that it will still close at the end of the process.</p><h4>Mode Light Switch Cover</h4><p>The last assembly bit you’ll do is to glue the mode light cover on top of the mode light hole.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TtKBTZrnqb96CiumNOT2lA.jpeg" /></figure><p>Clean up any excess hot glue on top of the wand and glue that thing down.</p><h4>Electronics (Part the Second)</h4><p>Before you do any soldering, remove the batteries.</p><p>Finished wiring inside the case…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZLSSHgFiLUEwJOI_7ea7nw.jpeg" /></figure><p>The general steps for attaching the switch wiring to the main board is:</p><ol><li>Slip some heat shrink tube over one of the wires</li><li>Twist the wires together so that the exposed wire is between the two insulated pieces of wire. If the exposed wire is twisted perpendicular to the insulated wire, you won’t be able to get your heat shrink tubing over the exposed wiring.</li><li>Solder the exposed wire together.</li><li>Slide / push the heat shrink tubing over the exposed wire.</li><li>Use a heat gun or the tip of your hot glue gun to shrink the tubing. (I do this step after all of the soldering is complete.</li></ol><p>Once again, here is the general wiring diagram:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-y4fHLRpCukW-yrdNnn-mQ.jpeg" /></figure><p><strong>Step 1: Mode Switch</strong></p><p>From the Spirit Life-Size wand’s black (on/off) switch … <br>on the left when you’re looking down at the top of the wand… <br>red and white wires to the wires attached to the blue/purple mode switch wires when you lengthened those.</p><p>In the below photos, this will be the black wires on the wand connected to the white wires on the electronics.</p><p><strong>Step 2: Intensify Switch</strong></p><p>From the Life-Size wand’s red (slo-blo) switch … <br>on the right when you’re looking down at the top of the wand… <br>to the blue trigger wires.</p><p>In the below photos, this will be the black and gray wires from the wand to the yellow wires from the electronics.</p><p>If you want to try to put an INTENSIFY switch in the left-hand box instead of reusing this switch … go with Gozer. I didn’t want to try.</p><p><strong>Step 3: Power / Activate Switches</strong></p><p>From the new toggle switch above the slow-blo button, to the yellow power up wires. You may also be connecting a second toggle switch between the red wires of the battery pack and the red wire of the electronics.<br>The battery switch would be the ‘bottom’ one and the activate switch would be the ‘top’ one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hz5QEeHX9xelML1709CN0A.jpeg" /></figure><h3>Test It.</h3><p>Before you close the Life-Size wand up, you should put the batteries in and bench test your wiring.</p><h4>Close It Up</h4><p>Make sure that if the battery pack has an on/off switch that it is left in the on position.</p><p>Now that you’re all wired and switched on, close up the case and screw it together.</p><h3>Test It.</h3><h3>Bust some ghosts!</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0912455ae5e8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dexie Typescript without Classes]]></title>
            <link>https://j5cookie.medium.com/dexie-typescript-without-classes-3fc2423997ca?source=rss-fe348c9b94b1------2</link>
            <guid isPermaLink="false">https://medium.com/p/3fc2423997ca</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[dexie]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[indexeddb]]></category>
            <dc:creator><![CDATA[J. Cookie (they/them)]]></dc:creator>
            <pubDate>Tue, 22 Nov 2022 13:47:03 GMT</pubDate>
            <atom:updated>2022-11-22T13:48:35.859Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*1NLB3WBPoLr5x3d9hCG5bQ.jpeg" /></figure><p>When I began working with the <a href="https://dexie.org/">Dexie</a> IndexedDB wrapper library, I was disappointed to see the instructions that directed you to subclass Dexie in order to use it with Typescript.</p><p>I would much prefer a composable pattern which didn’t use the syntactic sugar of ES classes.</p><p>Here is one technique for using Dexie and Typescript without classes.</p><p>TL;DR:</p><p><a href="https://codesandbox.io/s/dexie-typescript-without-classes-cockzm?file=/src/db/index.ts">Here’s a CodeSandbox.</a></p><p>We’ll start off by importing Dexie as BaseDexie , so we can re-export an extended, genericDexie type if we’d like to. We’ll create a type DexieTables that we can use to implement our generic.</p><pre>// db/index.ts<br><br>import BaseDexie from &#39;dexie&#39;;<br><br>type DexieTables = {};<br>export type Dexie&lt;T extends any = DexieTables&gt; = BaseDexie &amp; T;<br><br>export const db = new BaseDexie(&#39;j5bot&#39;) as Dexie;</pre><p>In a separate file, so things are composable, we create our first table/collection:</p><pre>// db/tables/friends.ts<br><br>import { Table } from &#39;dexie&#39;;<br><br>export type Friend = {<br>  id?: number;<br>  name: string;<br>  age: number;<br>};<br><br>export type FriendsTable = {<br>  friends: Table&lt;Friend&gt;;<br>};<br><br>export const friendsSchema = {<br>  friends: &#39;++id, name, age&#39;<br>};</pre><p>Next, we update db/index.ts to add our friends table.</p><pre>// db/index.ts<br><br>import BaseDexie from &#39;dexie&#39;;<br>import { friendsSchema, FriendsTable } from &#39;./tables/friends&#39;;<br><br>type DexieTables = FriendsTable;<br>export type Dexie&lt;T extends any = DexieTables&gt; = BaseDexie &amp; T;<br><br>export const db = new BaseDexie(&#39;j5bot&#39;) as Dexie;<br>const schema = Object.assign({}, friendsSchema);<br>db.version(1).stores(schema);</pre><p>For every table we have, we implement a file according to the db/tables/friends.ts pattern and then add the type and schema to db/index.ts as follows.</p><pre>// db/index.ts<br><br>import BaseDexie from &#39;dexie&#39;;<br><br>// import all of the table types and schemas<br>import { enemiesSchema, EnemiesTable } from &#39;./tables/enemies&#39;;<br>import {<br>  familyMembersSchema,<br>  FamilyMembersTable,<br>} from &#39;./tables/familyMembers&#39;;<br>import { friendsSchema, FriendsTable } from &#39;./tables/friends&#39;;<br><br>// add table types to union type<br>type DexieTables = <br>  &amp; EnemiesTable<br>  &amp; FamilyMembersTable<br>  &amp; FriendsTable;<br>export type Dexie&lt;T extends any = DexieTables&gt; = BaseDexie &amp; T;<br><br>export const db = new BaseDexie(&#39;j5bot&#39;) as Dexie;<br><br>// add schemas to array<br>const schema = Object.assign({},<br>  enemiesSchema,<br>  familyMembersSchema,<br>  friendsSchema,<br>);<br>db.version(1).stores(schema);</pre><p>All in all, this should provide you with a type safe, compositional pattern for using Dexie with Typescript without using classes.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3fc2423997ca" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Walmart.io Affiliate Signature Header Generation in NodeJS]]></title>
            <link>https://j5cookie.medium.com/walmart-io-affiliate-signature-header-generation-in-nodejs-79d6b24c440?source=rss-fe348c9b94b1------2</link>
            <guid isPermaLink="false">https://medium.com/p/79d6b24c440</guid>
            <category><![CDATA[signature]]></category>
            <category><![CDATA[walmart]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[rsa]]></category>
            <dc:creator><![CDATA[J. Cookie (they/them)]]></dc:creator>
            <pubDate>Sat, 15 Oct 2022 16:08:08 GMT</pubDate>
            <atom:updated>2022-10-16T16:57:30.756Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*qfpXKk_6IOQ9Mz-UBwKaJA.jpeg" /></figure><p>Annoyed with WM_SEC.AUTH_SIGNATURE like I was? Read on!</p><h4>TL;DR</h4><p>You can use the code in this <a href="https://gist.github.com/j5bot/8d2099f995f8df22f605864d728ee049">gist</a> to generate your Walmart Affiliate API headers.</p><p><em>NOTE</em>: if you have problems, try a Production consumer id.</p><p>I am working on a project with a friend which necessitates accessing the <a href="https://walmart.io/docs/affiliate/">Walmart Affiliate API</a>.</p><p>The documentation above references the additional headers which have to be added to each request, including an encrypted signature header.</p><p>They provide an <a href="https://walmart.io/docs/affiliate/onboarding-guide">example of generating the signature in Java</a>, but not in any other language.</p><p>But I’m not using Java for the back-end here, I’m using NodeJS. What to do?</p><p>First principles: this should be a solved problem. Time for a web search.</p><p>That led to this article on Medium — <a href="https://vandevliet.me/guide-how-to-use-the-walmart-affiliate-api-with-nodejs/">Guide: How to use the Walmart Affiliate API with NodeJS</a>. Awesome!</p><p>But I still had problems when I followed the guide, so with all due credit to <a href="https://vandevliet.me/author/jelle/">Jelle Van de Vliet</a>, the following is my expanded guide.</p><h3>Key Generation</h3><p>Getting started with the API requires generating public and private keys. For our example code, it is easier to have an unencrypted RSA private key. Following the <a href="https://walmart.io/key-tutorial">instructions that Walmart provides</a>, we’ll be left with some PKCS8 keys in `.pem` files.</p><p>We want a PKCS1 private RSA key to use with the NodeRSA package, so we’ll add an additional step. The complete ‘script’ follows:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7aff1cf2b1d2bc6e756aa075b26d9722/href">https://medium.com/media/7aff1cf2b1d2bc6e756aa075b26d9722/href</a></iframe><p>If you’ve already generated your key, this is the only command you’ll need:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f05feb4efb16c7823b9727c781b8162f/href">https://medium.com/media/f05feb4efb16c7823b9727c781b8162f/href</a></iframe><h3>Consumer ID Creation</h3><p>In order to use the API with the key pair you just generated, you’ll need to upload your public key (copied to your clipboard as the last command above, so repeat that command if you don’t have the key in your clipboard).</p><p>Walmart’s instructions on how to do this are fine … <strong>except</strong> … they don’t mention that the example API calls require <em>Production</em> Consumer IDs.</p><p>So when you upload your public key, choose the “Production” environment.</p><h3>Generating Headers to Sign API Requests</h3><p>The following is the code that I use to generate my Walmart Affiliate API request headers:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2c0628703f93802beaf7db5e62ba9882/href">https://medium.com/media/2c0628703f93802beaf7db5e62ba9882/href</a></iframe><p>To restate what is written in Jelle’s <a href="https://vandevliet.me/guide-how-to-use-the-walmart-affiliate-api-with-nodejs/">guide</a>, these are the required steps to generate the signature:</p><ol><li>Create a string concatenating the values which will be sent as WM_CONSUMER.ID , WM_CONSUMER.TIMESTAMP, and WM_SEC.KEY_VERSION — in that order — with a newline <em>after each item</em>.</li><li>Create an instance of NodeRSA , providing your private key.</li><li>Using the instance to .sign the signature source string, creating a buffer.</li><li>Encode the buffer as a base64 string in order to use it in your headers.</li></ol><p>Following creating the signature, you must create the headers. For ease, I do both at the same time.</p><p>Refer to this <a href="https://gist.github.com/j5bot/8d2099f995f8df22f605864d728ee049">gist</a> for a full example.</p><h3>Conclusion</h3><p>Once you can generate the signature header, you’re all set to use the Walmart.io Affiliate API.</p><p>Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=79d6b24c440" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using an Echo Show as an External Mac Display]]></title>
            <link>https://j5cookie.medium.com/using-an-echo-show-as-an-external-mac-display-744e35e6f036?source=rss-fe348c9b94b1------2</link>
            <guid isPermaLink="false">https://medium.com/p/744e35e6f036</guid>
            <category><![CDATA[amazon-echo-show]]></category>
            <category><![CDATA[airplay]]></category>
            <category><![CDATA[casting]]></category>
            <category><![CDATA[external-display]]></category>
            <category><![CDATA[echo-show]]></category>
            <dc:creator><![CDATA[J. Cookie (they/them)]]></dc:creator>
            <pubDate>Tue, 20 Sep 2022 15:11:09 GMT</pubDate>
            <atom:updated>2022-09-20T15:11:09.043Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*-AJse_QecPwVm2eUd77QjQ.jpeg" /></figure><h3>(Or Any Device with a Browser)</h3><p>While searching for a way to use my second generation Echo Show (10) as an external display for things like terminal, email, slack, etc. — I was not able to find any articles, but I eventually discovered the solution.</p><p>Combining the program <a href="https://deskreen.com/">Deskreen</a> with a virtual “dummy” display created by <a href="https://github.com/tml1024/FluffyDisplay/releases">FluffyDisplay</a> or <a href="https://betterdisplay.pro/">BetterDisplay</a> and using the Show’s built-in Silk browser.</p><p>Here’s how to get up and running using Deskreen and BetterDisplay, step by step.</p><p><strong>Preparation</strong></p><ul><li>Download <a href="https://github.com/pavlobu/deskreen/releases">Deskreen</a> for your platform — we’ll get Mac — as of this writing, Deskreen is at <a href="https://github.com/pavlobu/deskreen/releases/download/v2.0.3/Deskreen-2.0.3.dmg">version 2.0.3</a>.</li><li>Download <a href="https://betterdisplay.pro/">BetterDisplay</a>.</li><li>Gather resolution information about your device’s display. The Echo Show 10 (2nd generation) I’ll be using has a display resolution of 1280x800.</li></ul><p><strong>Creating the Dummy Display</strong></p><ul><li>Open BetterDisplay.</li><li>Click the BetterDisplay icon in the status bar.</li><li>Select “Create New Dummy” &gt; “Custom Aspect Ratio”.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/867/1*6nPsBCJZW8FVqyi42tf6Og.png" /></figure><ul><li>A dialog will appear with the text “Create a custom dummy” and two input boxes [16] x [9].</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/273/1*6YPmfKuoOyhqIwRfaTjyAQ.png" /></figure><ul><li>Enter your display’s width and height in the two inputs and select “OK”.</li><li>A new dialog will appear asking you whether you want to connect the new dummy. Click “Connect”.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/271/1*xQRQHfUleECdEh4NNlrbog.png" /></figure><ul><li>BetterDisplay will automatically create the display at 2x resolution, and I like to adjust that down to the native resolution with the slider in the BetterDisplay menu.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/268/1*1y6mn-lgW_71dM4hsCP_yg.png" /></figure><ul><li>Open “Display Preferences” and arrange your displays as desired. I recommend placing your dummy displays to the left or right of your normal displays.</li></ul><p><strong>Streaming the Display / Window</strong></p><ul><li>Open Deskreen.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/829/1*YPHpgI4dhBnyWB22CsFCKQ.png" /></figure><ul><li>Open the Silk browser on your Echo Show.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*akWQqMCMG3MtVr7Xp_kEhQ.png" /></figure><ul><li>Navigate to the URL shown on the Deskreen app window. In this case it is 192.168.0.15:3131/619990</li><li>You’ll see the Deskreen client page.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*jHWBh-2QeK6g4ZYwJ_AxxA.png" /></figure><ul><li>Go back to Deskreen.</li><li>A dialog appears asking you whether to allow the incoming connection from the Echo Show.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/412/1*nYslHcE1Uk5dj2oHWvrP1A.png" /></figure><ul><li>Click the “Allow” button.</li><li>Deskreen will show options to “Choose Entire Screen or App window you want to share”.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/1*oZlgkb36-64bXxC_D9yO8g.png" /></figure><ul><li>Choose the option you want.<br>If you plan on using your display for showing, for example, a terminal, I recommend sharing an “Application Window”.</li></ul><p><em>As of this writing, I have been unable to share multiple screens through Deskreen.</em></p><ul><li>If choosing “Entire Screen”, select the screen which corresponds to your dummy display created earlier.</li><li>Click on the green “Confirm” button.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/1*imPPQNnNwrg07Qfz9MPwVg.png" /></figure><ul><li>You will now see your dummy display shown on the Echo Show, along with a banner.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*Os6C04px12dLpuXxs2X-RQ.png" /></figure><ul><li>Click on the maximize icon to the right of the ⚙ icon to put the Echo Show browser into full screen mode.</li></ul><p><strong><em>If you see a black screen, click on the “Pause” button and then the “Play” button that replaces it and the display stream should begin again.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*08nvsU9mEf0o_V5B8AVilQ.png" /></figure><ul><li>Drag windows onto it and use the display as you would any other.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*bpOG78HXBBkRJx5wAXMy8w.png" /></figure><p>You will likely experience some lag (at least I do) due to network conditions and the like. Use the display accordingly!</p><p>You can use the various methods available to move windows between displays to manage what is shown on your Echo Show. I use the program <a href="https://rectangleapp.com/">Rectangle</a> and keyboard shortcuts.</p><p><strong>Other Devices</strong></p><p>The instructions are exactly the same for other devices with a browser, including older computers you may not have any other use for, etc.</p><p>Unfortunately the browser on my Kindle Oasis doesn’t seem to support WebRTC and Deskreen. Too bad.</p><p>For some devices, a native streaming method such as Sidecar or Airplay may be more performant. Experiment and see for yourself!</p><p><strong>Ideas for What to Display</strong></p><ul><li>Terminal windows (particularly log windows).</li><li>Activity Monitor.</li><li>Email windows.</li><li>Chat apps.</li><li>IDE floating windows.</li></ul><p>Enjoy using your Echo Show as an external display for your Mac!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=744e35e6f036" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Async array.reduce() in Typescript]]></title>
            <link>https://j5cookie.medium.com/async-array-reduce-in-typescript-e116ba1f3578?source=rss-fe348c9b94b1------2</link>
            <guid isPermaLink="false">https://medium.com/p/e116ba1f3578</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[arrays]]></category>
            <category><![CDATA[reduce]]></category>
            <category><![CDATA[async]]></category>
            <dc:creator><![CDATA[J. Cookie (they/them)]]></dc:creator>
            <pubDate>Fri, 08 Apr 2022 14:29:13 GMT</pubDate>
            <atom:updated>2022-04-09T08:20:12.143Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5bBAo1xDC7nb6Ik7EEs2BA.jpeg" /></figure><p>If you need to reduce an array, perhaps in order to map it onto an object, with one of the operations in the reducer being an asynchronous one, how exactly does that work, and how do you type it in Typescript?</p><p>(Scroll down for <strong>TL;DR</strong>)</p><p><a href="https://codesandbox.io/s/async-array-reduce-in-typescript-pd6z7f">All of the code in a sandbox.</a></p><p>First off, understand that in order to support asynchronous operations, your reducer has to return a promise. Let’s look at a simple reducer that reduces an array of key/value tuple (2-member arrays) into an object.</p><pre>const ourFavoriteFamilyArray = [<br>  [&quot;Homer&quot;, &quot;Homer Simpson&quot;],<br>  [&quot;Marge&quot;, &quot;Marge Simpson&quot;],<br>  [&quot;Lisa&quot;, &quot;Lisa Simpson&quot;],<br>  [&quot;Bart&quot;, &quot;Bart Simpson&quot;],<br>  [&quot;Maggie&quot;, &quot;Maggie Simpson&quot;]<br>];</pre><pre>const ourFavoriteFamily = ourFavoriteFamilyArray.reduce(<br>  (family, familyMember) =&gt; {<br>    family[familyMember[0]] = familyMember[1];<br>    return family;<br>  }, {}<br>);</pre><pre>console.log(&quot;1. Basic Reduce&quot;, ourFavoriteFamily);</pre><p>But we aren’t doing simple assignments … we need to do an asynchronous operation (like a fetch) on each value. So things get more interesting.</p><p>Here is the same reducer, but one that does asynchronous operations using Promises.</p><pre>const ourFavoriteFamilyArray = [<br>  [&quot;Homer&quot;, &quot;Homer Simpson&quot;],<br>  [&quot;Marge&quot;, &quot;Marge Simpson&quot;],<br>  [&quot;Lisa&quot;, &quot;Lisa Simpson&quot;],<br>  [&quot;Bart&quot;, &quot;Bart Simpson&quot;],<br>  [&quot;Maggie&quot;, &quot;Maggie Simpson&quot;]<br>];</pre><pre>const pretendThisIsAsync = (familyMember) =&gt; {<br>  return Promise.resolve(familyMember[1]);<br>};</pre><pre>const ourFavoriteFamilyMapPromise = ourFavoriteFamilyArray.reduce(<br>  (familyAccumulatorPromise, familyMember) =&gt; {<br>    return familyAccumulatorPromise.then((family) =&gt; {<br>      return pretendThisIsAsync(familyMember)<br>        .then((processedFamilyMember) =&gt; {<br>          family[familyMember[0]] = processedFamilyMember;<br>          return family;<br>        });<br>      });<br>}, Promise.resolve({}));</pre><pre>ourFavoriteFamilyMapPromise.then((family) =&gt; {<br>  console.log(&quot;2. Promise Reduce&quot;, family);<br>});</pre><p>That’s asynchronous, but is it async? We want this cleaner, right? We want to be able to type this with Typescript without going insane, right?</p><p>First, let’s refactor this to use async / await.</p><p>In the Promises version, we have to .then in order to log our final value. Let’s not do that.</p><pre>const ourFavoriteFamily = await ourFavoriteFamilyArray.reduce(...);<br>...<br>console.log(ourFavoriteFamily);</pre><p>Now let’s rip out that first .then in the reducer itself…</p><pre>const ourFavoriteFamily = await ourFavoriteFamilyArray.reduce(<br>  async (familyAccumulatorPromise, familyMember) =&gt; {<br>    const family = await familyAccumulatorPromise;<br>    return pretendThisIsAsync(familyMember).then(...);<br>}, Promise.resolve({}));</pre><p>Because we use an await inside of the reducer function, we have to mark it as async. We still have one more use of the non-async (Promise chain) .then in our reducer function. Let’s finish off the reducer by removing that.</p><pre>const ourFavoriteFamily = await ourFavoriteFamilyArray.reduce(<br>  async (familyAccumulatorPromise, familyMember) =&gt; {<br>    const family = await familyAccumulatorPromise;<br>    const processedFamilyMember =<br>      await pretendThisIsAsync(familyMember);<br>    family[familyMember[0]] = processedFamilyMember;<br>    return family;<br>}, Promise.resolve({}));</pre><p>Now that we’ve got a nice async / await function, let’s type it.</p><pre>type FamilyMember = [string, string];<br>// this is the type of your processed value<br>type ProcessedFamilyMember = string;<br>type FamilyArray = FamilyMember[];<br>type Family = Record&lt;string, ProcessedFamilyMember&gt;;</pre><pre>const ourFavoriteFamilyArray: FamilyArray = [<br>  [&quot;Homer&quot;, &quot;Homer Simpson&quot;],<br>  [&quot;Marge&quot;, &quot;Marge Simpson&quot;],<br>  [&quot;Lisa&quot;, &quot;Lisa Simpson&quot;],<br>  [&quot;Bart&quot;, &quot;Bart Simpson&quot;],<br>  [&quot;Maggie&quot;, &quot;Maggie Simpson&quot;]<br>];</pre><pre>const pretendThisIsAsync = async (familyMember: FamilyMember) =&gt; {<br> return await Promise.resolve(familyMember[1]);<br>};</pre><pre>const ourFavoriteFamily = await ourFavoriteFamilyArray.reduce(<br>  async (<br>    familyAccumulatorPromise,<br>    familyMember<br>  )=&gt; {<br>    const family = await familyAccumulatorPromise;<br>    const processedFamilyMember =<br>      await pretendThisIsAsync(familyMember);<br>    family[familyMember[0]] = processedFamilyMember;<br>    return family;<br>}, Promise.resolve({} as Family));</pre><pre>console.log(ourFavoriteFamily);</pre><h3>TL;DR</h3><p>In a typed, async / await array reducer:</p><ul><li>Your initializer should be a resolved Promise of the proper return type.</li><li>You must resolve the accumulator Promise by awaiting it, before you try to modify it.</li><li>You must awaityour asynchronous process.</li><li>You do not have to return a Promise from your reducer.</li><li>Your accumulator and initializer must be typed as a Promise.</li><li>If necessary, you must cast the initializer value.</li></ul><h3>Extra Credit: Exhaustively Typed</h3><pre>type FamilyMember = [string, string];<br>type ProcessedFamilyMember = string;<br>type FamilyArray = FamilyMember[];<br>type Family = Record&lt;string, ProcessedFamilyMember&gt;;</pre><pre>const ourFavoriteFamilyArray: FamilyArray = [<br>  [&quot;Homer&quot;, &quot;Homer Simpson&quot;],<br>  [&quot;Marge&quot;, &quot;Marge Simpson&quot;],<br>  [&quot;Lisa&quot;, &quot;Lisa Simpson&quot;],<br>  [&quot;Bart&quot;, &quot;Bart Simpson&quot;],<br>  [&quot;Maggie&quot;, &quot;Maggie Simpson&quot;]<br>];</pre><pre>const pretendThisIsAsync = async (familyMember: FamilyMember):<br>  Promise&lt;ProcessedFamilyMember&gt; =&gt; {<br>    return await Promise.resolve(familyMember[1]);<br>  };</pre><pre>const ourFavoriteFamily: Family = await <br>  ourFavoriteFamilyArray.reduce(<br>    async (<br>      familyAccumulatorPromise: Promise&lt;Family&gt;,<br>      familyMember: FamilyMember<br>    ): Promise&lt;Family&gt; =&gt; {<br>      const family = await familyAccumulatorPromise;<br>      const processedFamilyMember =<br>        await pretendThisIsAsync(familyMember);<br>      family[familyMember[0]] = processedFamilyMember;<br>      return family;<br>    }, Promise.resolve({} as Family)<br>  );</pre><pre>console.log(ourFavoriteFamily);</pre><p>Photo by <a href="https://pixabay.com/users/meetthephil-975016/">Phil Müller</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e116ba1f3578" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[White Space Alignment Insanity]]></title>
            <link>https://j5cookie.medium.com/stop-the-inline-b6c972c29eca?source=rss-fe348c9b94b1------2</link>
            <guid isPermaLink="false">https://medium.com/p/b6c972c29eca</guid>
            <category><![CDATA[constant]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[alignment]]></category>
            <category><![CDATA[rxjs]]></category>
            <category><![CDATA[marble-diag]]></category>
            <dc:creator><![CDATA[J. Cookie (they/them)]]></dc:creator>
            <pubDate>Thu, 24 Feb 2022 14:51:09 GMT</pubDate>
            <atom:updated>2022-03-04T11:15:33.719Z</atom:updated>
            <content:encoded><![CDATA[<h3>White Space Alignment Insanity: Losing Your Marbles?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mqApMFl5FftrjooBND5JsA.jpeg" /></figure><h3>… or Pretty Marble Diagram Test Constants … or Stop the Inline</h3><h3>Aligning (and Referencing) String Constants</h3><p>A peer of mine recently presented some code wherein they used whitespace to align string constants to make the relationship between them more apparent.</p><p>Out of what I assume was confusion, other developers asked about that whitespace use. I wanted to do something to make it more obvious and readable.</p><h3>TL;DR</h3><p>To declare, align, and reference constants, you can destructure an array or use a combination of objects and utility functions.</p><p>Read the <a href="#9a9c">examples at the end of the article</a> to learn more.</p><p>The specific use case was representing Observable streams as marble diagrams in order to test the output of RxJS operations. So the constants all had an equal fixed length.</p><p>Abstracted down to the string constants to protect the innocent, the code went something like this:</p><pre>const source = in(        &#39;a-----------|&#39;);<br>const operationInput = in(&#39;------------|&#39;);<br>const expected = out(     &#39;-----a------|&#39;;</pre><p>Someone asked about the whitespace, and my immediate thought was that the definition of the case variables (the constants) could be declared outside the functional code. I thought “Array”.</p><h4>Just An Array</h4><p>The obvious:</p><pre>const testCase = [<br>  &#39;a-----------|&#39; ,<br>  &#39;------------|&#39; ,<br>  &#39;-----a------|&#39; ,<br>];</pre><pre>const source = in(testCase[0]);<br>const operationInput = in(testCase[1]);<br>const expected = out(testCase[2]);</pre><p>This is basically fine, but using the array indexes isn’t as readable as I really want it. In truth, the original version is more readable.</p><p>This is the usage I wanted:</p><pre>const source = in(sourceIn);<br>const operationInput = in(operationInputIn);<br>const expected = out(expectedOut);</pre><p>Someone else suggested using an object, but I didn’t want the constants to be on two lines.</p><h4>Tuples</h4><p>I did a little grind on the problem. I considered tuples and a transform function:</p><pre>const testCase = mapTuples([<br>  [&#39;a-----------|&#39;, &#39;sourceIn&#39;],<br>  [&#39;------------|&#39; , &#39;operationInputIn&#39;],<br>  [&#39;-----a------|&#39; , &#39;expectedOut&#39;],<br>]);</pre><p>The related utility function:</p><pre>const mapTuples = (tupleList) =&gt; tupleList<br>  .reduce(<br>    (map, tuple) =&gt; Object.assign(map, { [tuple[1]]: tuple[0] })<br>  );</pre><p>The output:</p><pre>console.log(testCase);<br>-----<br>{<br>  sourceIn: &#39;a-----------|&#39;,<br>  operationInputIn: &#39;------------|&#39;,<br>  expectedOut: &#39;-----a------|&#39;,<br>}</pre><p>Then you would destructure it for readable usage:</p><pre>const { sourceIn, operationInputIn, expectedOut } = testCase;</pre><p>The code for using the constants is right.</p><p>But tuples. Not the most common pattern in Javascript/ECMAScript. I went on to use objects, but it later occurred to me that there was a tuple-like way to accomplish (some of) what I wanted that was dead simple. More on that later.</p><h4>Reverse Mapped</h4><p>Using objects, I flipped the script (ha!) and used the constants as the keys and the labels as the values. Sprinkle in some utility functions, inline the destructuring, and we have something!</p><pre>const { sourceIn, operationInputIn, expectedOut } = caseToObject({<br>  &#39;a-----------|&#39;: &#39;sourceIn&#39;,<br>  &#39;------------|&#39;: &#39;operationInputIn&#39;,<br>  &#39;-----a------|&#39;: &#39;expectedOut&#39;,<br>});</pre><p>The related utility functions:</p><pre>export const reverseMap = (map) =&gt;<br>  Object.entries(map)<br>    .reduce(<br>      (reverseMap, [key, value]) =&gt;<br>        Object.assign(reverseMap, { [value]: key }), {});</pre><pre>// an alias to abstract the implementation from the function name<br>export const caseToObject = reverseMap;</pre><p>Again, the code for using the constants is right.</p><p>BUT WAIT! I COMPLETELY FORGOT ABOUT DESTRUCTURING ARRAYS!</p><h3>Conclusion</h3><p>To repeat from earlier, this is the desired usage of the code:</p><pre>const source = in(sourceIn);<br>const operationInput = in(operationInputIn);<br>const expected = out(expectedOut);const source = in(sourceIn);</pre><h4>Destructuring an Array</h4><p>You can use this painfully easy method, and it is probably the best way for just a few lines in your test case:</p><pre>const [sourceIn, operationInputIn, expectedOut] = [<br>  &#39;a-----------|&#39;<br>  &#39;------------|&#39;<br>  &#39;-----a------|&#39;<br>];</pre><p>The desired code for using the constants is good.</p><h4>Reverse Mapping</h4><p>To provide labels inline with the constants, use a reverse mapping technique.</p><pre>const { sourceIn, operationInputIn, expectedOut } = caseToObject({<br>  &#39;a-----------|&#39;: &#39;sourceIn&#39;,<br>  &#39;------------|&#39;: &#39;operationInputIn&#39;,<br>  &#39;-----a------|&#39;: &#39;expectedOut&#39;,<br>});</pre><h3>Appendix: Utility Functions</h3><p>In case you are coming from the <strong>TL;DR</strong> or just want a quick reference, here are the utility functions used.</p><pre>// Tuples<br>export const mapTuples = (tupleList) =&gt; tupleList<br>  .reduce(<br>    (map, tuple) =&gt; Object.assign(map, { [tuple[1]]: tuple[0] })<br>  );</pre><pre>// Reverse Mapping<br>export const reverseMap = (map) =&gt;<br>  Object.entries(map)<br>    .reduce(<br>      (reverseMap, [key, value]) =&gt;<br>        Object.assign(reverseMap, { [value]: key }), {});</pre><pre>export const caseToObject = reverseMap;</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b6c972c29eca" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>