<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.9.3">Jekyll</generator><link href="https://kara.codes/feed.xml" rel="self" type="application/atom+xml" /><link href="https://kara.codes/" rel="alternate" type="text/html" /><updated>2023-05-22T17:03:20+00:00</updated><id>https://kara.codes/feed.xml</id><title type="html">Kara Codes!</title><subtitle>Hey, did you know?! Kara Codes! She also Loves, Learns, Builds, Talks, and Stans for her peoples! Come catch a glimpse of a Queer Woman of Color in Tech at Work.
Site built on jekyll by yours truly, with zest &amp; gusto!</subtitle><author><name>Kara Carrell</name></author><entry><title type="html">starting up again</title><link href="https://kara.codes/stuff/starting-up-again" rel="alternate" type="text/html" title="starting up again" /><published>2023-05-22T00:00:00+00:00</published><updated>2023-05-22T00:00:00+00:00</updated><id>https://kara.codes/stuff/starting-up-again</id><content type="html" xml:base="https://kara.codes/stuff/starting-up-again">&lt;p&gt;The last time I sincerely wrote on my blog was right before I started my job at TXI. Since then, I’ve done so much, learned so many new things, that I could’ve filled up my TIL category with heaps of fascinating stuff! I’ve risen from Apprentice, to Associate, to Consultant. I went from a W/S/C organizer, to the Board president, I’ve attempted to build a zine series. I’ve created and shared so many cool tools! I’ve worked on so many fascinating projects, and used all of my energy toward the success of my roles.&lt;/p&gt;

&lt;p&gt;First came excitement for something new, then came focus, then came guilt, then came shame, then came avoidance. It’s a sad and vulnerable thing to admit, but just as i’ve grown in my technological prowess, so have I grown in my emotional intelligence, mostly about myself. And with that, I put it in my goal to rekindle the praxis I had setup for myself to share what I learn, and keep a line open for getting to know me better, by way of this site. Its like, returning to a garden that’s been overtaken with plants and debris, and committing to care and nuture, because that garden is me, and I deserve the time and effort.&lt;/p&gt;

&lt;p&gt;The fun thing about this return is that it allowed me to revisit where I was when I last left. I actually had quite a bit of drafts about new and interesting things i’d learned, and have already created a list of things that I want to document my learning of. It gave me a moment to clear out the shame, give myself grace, and be proud of what i’ve accomplished in the past 5 years.&lt;/p&gt;

&lt;p&gt;My plan for my blog is to take a more routine approach of posting, and perhaps continue to utilize the path DBC started me on with technical &lt;em&gt;and&lt;/em&gt; cultural posts, which is exactly the kind of work I do now.&lt;/p&gt;

&lt;p&gt;So stay tuned, everyone! and stay excited, because finally, there’s more to come.&lt;/p&gt;</content><author><name>Kara Carrell</name></author><category term="update" /><category term="Cultural" /><category term="update" /><category term="gititgurl" /><category term="reflection" /><summary type="html">The last time I sincerely wrote on my blog was right before I started my job at TXI. Since then, I’ve done so much, learned so many new things, that I could’ve filled up my TIL category with heaps of fascinating stuff! I’ve risen from Apprentice, to Associate, to Consultant. I went from a W/S/C organizer, to the Board president, I’ve attempted to build a zine series. I’ve created and shared so many cool tools! I’ve worked on so many fascinating projects, and used all of my energy toward the success of my roles.</summary></entry><entry><title type="html">all about that Base64</title><link href="https://kara.codes/til/base64" rel="alternate" type="text/html" title="all about that Base64" /><published>2018-04-26T00:00:00+00:00</published><updated>2018-04-26T00:00:00+00:00</updated><id>https://kara.codes/til/base64-fun</id><content type="html" xml:base="https://kara.codes/til/base64">&lt;p&gt;Today I spent some time pairing with a colleague, and needed to build a signature for an API call they needed to make, 
so I took to the googles and learned a bit about how Ruby deals with Base64.&lt;/p&gt;

&lt;p&gt;If you’ve never heard of Base64, it’s a numeral system, or &lt;strong&gt;BASE&lt;/strong&gt;-ically a standard for counting. 
We’re most familiar with Base10 &lt;em&gt;i.e.&lt;/em&gt; counting to 10 then starting over &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;0123456789&lt;/code&gt;, or Base2 &lt;em&gt;i.e.&lt;/em&gt; the Binary system that computers use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;01&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Base64 uses uppercase letters, lowercase letters, numbers, AND a few symbols to get the job done!
&lt;img src=&quot;/pics/base64table.png&quot; alt=&quot;base64 table from wikipedia&quot; /&gt;&lt;/p&gt;

&lt;p&gt;In ruby, you can use the Module Base64 to encode or decode things!
Here’s an example:&lt;/p&gt;

&lt;div class=&quot;language-rb highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
&lt;span class=&quot;c1&quot;&gt;# First, the Base64 Module isn't in Core ruby, so you have to require it&lt;/span&gt;
 
&lt;span class=&quot;nb&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;base64&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;kp&quot;&gt;true&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# you can use the method #encode64 and give an argument, and see it translated to Base64!&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;enc&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Base64&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;encode64&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;kara is awesome&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;a2FyYSBpcyBhd2Vzb21l&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# you can even be super sleuth and double encode it! (&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;double_enc&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Base64&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;encode64&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;enc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;YTJGeVlTQnBjeUJoZDJWemIyMWwK&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Then to revert back to your original messages, you use the method #decode64&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;revert&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Base64&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;decode64&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;double_enc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;a2FyYSBpcyBhd2Vzb21l&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;plain&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Base64&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;decode64&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;revert&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;kara is awesome&quot;&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h2 id=&quot;sandbox&quot;&gt;Sandbox!&lt;/h2&gt;
&lt;iframe height=&quot;400px&quot; width=&quot;100%&quot; src=&quot;https://repl.it/@KaraAJC/MajorEmptyOctagon?lite=true&quot; scrolling=&quot;no&quot; frameborder=&quot;no&quot; allowtransparency=&quot;true&quot; allowfullscreen=&quot;true&quot; sandbox=&quot;allow-forms allow-pointer-lock allow-popups allow-same-origin allow-scripts allow-modals&quot;&gt;&lt;/iframe&gt;

&lt;h2 id=&quot;resources&quot;&gt;Resources&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://ruby-doc.org/stdlib-2.5.0/libdoc/base64/rdoc/Base64.html&quot;&gt;Ruby Module Base64&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Base64&quot;&gt;Wiki page for Base64&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Basecs Post on encoding&lt;a href=&quot;https://medium.com/basecs/hexs-and-other-magical-numbers-9785bc26b7ee&quot;&gt;Hexes and Other Magical Numbers&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;BaseCS Podcast&lt;a href=&quot;https://www.codenewbie.org/basecs&quot;&gt;S1 Ep2- What is Encoding?&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content><author><name>Kara Carrell</name></author><category term="til" /><category term="ruby" /><summary type="html">Today I spent some time pairing with a colleague, and needed to build a signature for an API call they needed to make, so I took to the googles and learned a bit about how Ruby deals with Base64.</summary></entry><entry><title type="html">cache it good, service worker</title><link href="https://kara.codes/til/event-request-caching" rel="alternate" type="text/html" title="cache it good, service worker" /><published>2018-01-16T00:00:00+00:00</published><updated>2018-01-16T00:00:00+00:00</updated><id>https://kara.codes/til/event-request-caching</id><content type="html" xml:base="https://kara.codes/til/event-request-caching">&lt;p&gt;Today, I’m back on my Grow With Google Scholarship course, learning about Caching.&lt;/p&gt;

&lt;p&gt;The service worker does it’s work best when it can take advantage of a cache of the requests/responses it gathers when you’re online, so it can facilitate getting you the best experience possible when you’re offline, or on what google says “LIE-fi”.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;The Cache interface provides a storage mechanism for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Request&lt;/code&gt; / &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Response&lt;/code&gt; object pairs that are cached, for example as part of the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ServiceWorker&lt;/code&gt; life cycle.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Here are a range of methods I learned about from the Cache API, and some notes on what they’re for:&lt;/p&gt;

&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
&lt;span class=&quot;c1&quot;&gt;// Open up a local Cache&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;caches&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;open&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;cache-name&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;cache&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;cache&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;})&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// Add a request/response pair to the cache&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;cache&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;put&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// Add a set of Req/Res pairs to the cache all at once&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;cache&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;addAll&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;/things&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;/stuff&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// get out a request promise, if it exists, from the cache&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;cache&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;match&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// get out a request promise, if it exists, from all the caches&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;caches&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;match&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// Delete a cache by its name&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;caches&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;delete&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;cacheName&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// Retrieve the caches names&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;caches&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;keys&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;resources&quot;&gt;Resources&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;MDN Docs &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/Cache&quot;&gt;Cache API&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Google Web Fundamentals &lt;a href=&quot;https://developers.google.com/web/fundamentals/primers/service-workers/#cache_and_return_requests&quot;&gt;Cache and Return Reqests&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content><author><name>Kara Carrell</name></author><category term="til" /><category term="grow-with-google" /><summary type="html">Today, I’m back on my Grow With Google Scholarship course, learning about Caching.</summary></entry><entry><title type="html">respondWith and Fetch Events</title><link href="https://kara.codes/til/fetch-events" rel="alternate" type="text/html" title="respondWith and Fetch Events" /><published>2018-01-12T22:04:15+00:00</published><updated>2018-01-12T22:04:15+00:00</updated><id>https://kara.codes/til/fetch-event-respond-with</id><content type="html" xml:base="https://kara.codes/til/fetch-events">&lt;p&gt;Today, in the continuation of my Grow With Google Udacity Scholarship, I learned about the Service Worker life cycle, and how to set up the service worker to HIJACK the requests!&lt;/p&gt;

&lt;p&gt;in particular, I learned about the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;respondWith&lt;/code&gt; method, which in its basic form looks like this:&lt;/p&gt;

&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
&lt;span class=&quot;nb&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;addEventListener&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;fetch&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;

    &lt;span class=&quot;nx&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;respondWith&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;I'm the body&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;status&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;headers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
          &lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;Content-Type&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;Text/Html&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
      &lt;span class=&quot;p&quot;&gt;})&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;this function takes a promise that resolves to a Response object, with a body blob and optionally an object filled with further config info for the response, like headers etc.&lt;/p&gt;

&lt;p&gt;more complex uses of this method will involve &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fetch&lt;/code&gt;, more promise configs like &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;async/await&lt;/code&gt;, or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;catch&lt;/code&gt; and some conditionals. I’m off to learn those now!&lt;/p&gt;

&lt;h2 id=&quot;resources&quot;&gt;Resources&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;MDN Docs: &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/Response/Response&quot;&gt;Response Object&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;MDN Docs: &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/Fetchevent/respondWith&quot;&gt;FetchEvent.respondWith()&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content><author><name>Kara Carrell</name></author><category term="til" /><category term="service-worker" /><category term="fetch-api" /><category term="web" /><category term="grow-with-google" /><summary type="html">Today, in the continuation of my Grow With Google Udacity Scholarship, I learned about the Service Worker life cycle, and how to set up the service worker to HIJACK the requests!</summary></entry><entry><title type="html">service workers</title><link href="https://kara.codes/til/service-workers-intro" rel="alternate" type="text/html" title="service workers" /><published>2018-01-10T00:00:00+00:00</published><updated>2018-01-10T00:00:00+00:00</updated><id>https://kara.codes/til/service-workers</id><content type="html" xml:base="https://kara.codes/til/service-workers-intro">&lt;p&gt;Today I was informed of my acceptance into the Grow With Google Scholarship in the Mobile Web Specialist track!🎉
&lt;img src=&quot;https://s3-us-west-2.amazonaws.com/udacity-email/Scholarships/GrowWithGoogleDeveloperChallengeScholarship.png?utm_medium=email&amp;amp;utm_campaign=sch_600_auto_ndxxx_accepted-gwg&amp;amp;utm_source=blueshift&amp;amp;utm_content=sch_600_auto_ndxxx_accepted-gwg&amp;amp;bsft_eid=0278905a-c28b-4a40-852e-38bdcbd095b7&amp;amp;bsft_clkid=e786d1c4-a79e-409d-a528-903cd2736f40&amp;amp;bsft_uid=04bccbf8-86ac-40af-ac38-755d2002eebd&amp;amp;bsft_mid=c618d3cd-9d86-4ccd-9959-ec0953394de6&amp;amp;bsft_txnid=cce569b8-09b2-4c78-9ea3-5a8a625bfa46&quot; alt=&quot;Udacity Scholarship Badge&quot; /&gt;&lt;/p&gt;

&lt;p&gt;I’ve got 3 months to hone my skills on new web development technologies, and the first few lessons are focused on &lt;strong&gt;Offline First&lt;/strong&gt; Development.&lt;/p&gt;

&lt;p&gt;I’d heard of the term in the past year, as Google did a PWA Tour, and I got to go to the Chicago event, but I’m happy to jump back into the concept of how the Service Worker API will help us get to an offline-first environment on the web.&lt;/p&gt;

&lt;p&gt;So two terms I’ve mentioned: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;offline-first&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;service worker&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Offline-First&lt;/strong&gt; is a way to consider what the web should do when there’s little, or no connectivity, that doesnt leave us with blank pages. There’s lots of data our devices hold onto when we interact with sites, why not make it so we’re taking advantage of that data in an offline environment? This is what offline-first guides us towards. Consider what the user should be able to do in little to no connectivity &lt;em&gt;first&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Service Workers&lt;/strong&gt; are how we get to do that. Because there are a few decisions that need to be made depending on what’s being requested and whether there’s something existing in cache or whether it can be fetched, a Service Worker is registered on the browser to facilitate that, so in the case that there is little/no connectivity, things can be pulled from cache, and the service worker can keep an eye on connectivity to fetch and sync new data as things come back online.&lt;/p&gt;

&lt;p&gt;You can access the Service Worker API through the Navigator object, which is basically the User Agent you’re interfacing with.&lt;/p&gt;

&lt;p&gt;On page load, you call the Navigator to register the service worker, and from there, the Service Worker listens to events, and dispatches actions depending on what you’ve asked it to do in any given network scenario.&lt;/p&gt;

&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
  &lt;span class=&quot;c1&quot;&gt;// Code from Mozilla's web docs: &lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;// https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// in your main.js&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;serviceWorker&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;navigator&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// Register a service worker hosted at the root of the&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// site using the default scope.&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;navigator&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;serviceWorker&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;register&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;/sw.js&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;registration&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;Service worker registration succeeded:&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;registration&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}).&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;catch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;Service worker registration failed:&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;Service workers are not supported.&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// in your sw.js&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;addEventListener&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;fetch&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;c1&quot;&gt;// magic goes here&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;resources&quot;&gt;Resources&lt;/h2&gt;
&lt;p&gt;I’m a visual learner, so I’ve appreciated the Udacity lessons so far, and I’ve enjoyed diving in a bit more into the following sites:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Mozilla Web Docs: &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers&quot;&gt;Using Service Workers tutorial&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Medium Article &lt;a href=&quot;https://medium.com/offline-camp/offline-first-the-decentralized-web-and-peer-to-peer-technologies-b05b7fb3bcdd&quot;&gt;Offline First: The decentralized web and peer-to-peer technologies&lt;/a&gt; (it’s a bit old, but fascinating! also there’s an OFFLINE CAMP?!)&lt;/li&gt;
  &lt;li&gt;a list of offline-first, Progressive Web Apps &lt;a href=&quot;https://pwa.rocks/&quot;&gt;PWA.Rocks!&lt;/a&gt; (My FAVE is paper planes!)&lt;/li&gt;
  &lt;li&gt;Google Developers Web Fundamentals: &lt;a href=&quot;https://developers.google.com/web/fundamentals/primers/service-workers/&quot;&gt;Intro to service workers&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content><author><name>Kara Carrell</name></author><category term="til" /><category term="offline-first" /><category term="PWA" /><category term="Web-APIs" /><category term="GrowWithGoogle" /><category term="Mobile-Web-Specialist" /><category term="Udacity" /><summary type="html">Today I was informed of my acceptance into the Grow With Google Scholarship in the Mobile Web Specialist track!🎉</summary></entry><entry><title type="html">gatsby static site generator</title><link href="https://kara.codes/til/gatsby" rel="alternate" type="text/html" title="gatsby static site generator" /><published>2018-01-08T00:00:00+00:00</published><updated>2018-01-08T00:00:00+00:00</updated><id>https://kara.codes/til/gatsby-static-site-generator</id><content type="html" xml:base="https://kara.codes/til/gatsby">&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;#GreatGatsby&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Today, I continued my research on JAMstacks and finally deployed something with netlify. I decided to go with Gatsby instead of Hugo, since it’s built for React, and I’d like to be able to build more on React.&lt;/p&gt;

&lt;p&gt;I went through gatsby’s opening tutorials, and it’s a pretty quick uptake on getting pages up and running!&lt;/p&gt;

&lt;p&gt;I’m also happy to note that it uses GraphQL, which I’m excited to get to know more about.&lt;/p&gt;

&lt;p&gt;My goal will be to build my mom a site that she can share her daily health tips, and hopefully make new friends here in Chicago. I’m not sure that this will be the final tool I’m looking for, but I’m excited to find out.&lt;/p&gt;

&lt;h2 id=&quot;resources&quot;&gt;Resources:&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.gatsbyjs.org/tutorial/&quot;&gt;Gatsby&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.netlify.com/&quot;&gt;Netlify&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content><author><name>Kara Carrell</name></author><category term="til" /><category term="gatsby" /><category term="jamstack" /><category term="react" /><category term="static" /><category term="cms" /><summary type="html">#GreatGatsby</summary></entry><entry><title type="html">Thats My JAMstack!</title><link href="https://kara.codes/til/jamstack" rel="alternate" type="text/html" title="Thats My JAMstack!" /><published>2017-12-30T00:00:00+00:00</published><updated>2017-12-30T00:00:00+00:00</updated><id>https://kara.codes/til/jamstack</id><content type="html" xml:base="https://kara.codes/til/jamstack">&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;#Delicioso&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In the process of researching various static site generators may be best for the relaunch of my organization United Latinx Pride’s website, I stumbled upon a site that talks about a stack I hadn’t heard of before.&lt;/p&gt;

&lt;h2 id=&quot;jamstack&quot;&gt;&lt;strong&gt;JAM&lt;/strong&gt;stack&lt;/h2&gt;

&lt;p&gt;The JAM stack consists of &lt;strong&gt;J&lt;/strong&gt;avascript, &lt;strong&gt;A&lt;/strong&gt;PIs, and &lt;strong&gt;M&lt;/strong&gt;arkup. There’s a whole community building around the JAMstack, and its uses.&lt;/p&gt;

&lt;p&gt;The site, &lt;a href=&quot;https://jamstack.org/&quot;&gt;https://jamstack.org/&lt;/a&gt; has a detailed look at the pros &amp;amp; cons of building with a JAMstack, and examples of a few well-made sites built with it.&lt;/p&gt;

&lt;p&gt;I’m really happy to hear an influx of folks seeing this combination of languages and frameworks as a viable and professional option, I think it lets folks build light and impactful things.&lt;/p&gt;

&lt;p&gt;In 2018, I’d like to be building more stuff with things like Airtable, Contentful, Hugo, Jekyll, and Netlify.&lt;/p&gt;

&lt;p&gt;Long live the JAMstack!&lt;/p&gt;

&lt;h3 id=&quot;resources&quot;&gt;Resources&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;Resources from JAMstack community: &lt;a href=&quot;https://jamstack.org/resources/&quot;&gt;https://jamstack.org/resources/&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Recent article on the JAMstack: &lt;a href=&quot;https://thenewstack.io/the-sweetness-of-jamstack-javascript-apis-and-markup/&quot;&gt;The Sweetness of JAMstack&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;This is one of my absolute favorite ways to explain a tech stack: Hamburgers! (and I really want to design a JAMstack sammich to add!): &lt;a href=&quot;https://www.thesoftwareguild.com/stack-infographic/#intro&quot;&gt;Build Your Own Tech Stack&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;If you’re looking for a static site generator to use, check out &lt;a href=&quot;https://www.staticgen.com/&quot;&gt;StaticGen&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content><author><name>Kara Carrell</name></author><category term="til" /><category term="infrastructure" /><category term="software" /><category term="development" /><category term="stacks" /><category term="javascript" /><category term="API" /><category term="Markup" /><summary type="html">#Delicioso</summary></entry><entry><title type="html">Convert your name to binary</title><link href="https://kara.codes/stuff/name-to-binary-converter" rel="alternate" type="text/html" title="Convert your name to binary" /><published>2017-12-14T00:00:00+00:00</published><updated>2017-12-14T00:00:00+00:00</updated><id>https://kara.codes/stuff/name-to-binary-converter</id><content type="html" xml:base="https://kara.codes/stuff/name-to-binary-converter">&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;#IDidAThing&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;I built this method to convert your name to binary, try it out!&lt;/p&gt;

&lt;iframe height=&quot;400px&quot; width=&quot;100%&quot; src=&quot;https://repl.it/@KaraAJC/nametobinary?lite=true&quot; scrolling=&quot;no&quot; frameborder=&quot;no&quot; allowtransparency=&quot;true&quot; allowfullscreen=&quot;true&quot; sandbox=&quot;allow-forms allow-pointer-lock allow-popups allow-same-origin allow-scripts allow-modals&quot;&gt;&lt;/iframe&gt;</content><author><name>Kara Carrell</name></author><category term="technical" /><summary type="html">#IDidAThing</summary></entry><entry><title type="html">Bitwise OR</title><link href="https://kara.codes/til/bitwise-or" rel="alternate" type="text/html" title="Bitwise OR" /><published>2017-12-13T00:00:00+00:00</published><updated>2017-12-13T00:00:00+00:00</updated><id>https://kara.codes/til/bitwise-or</id><content type="html" xml:base="https://kara.codes/til/bitwise-or">&lt;p&gt;Talking to a senior engineer the other day, I came across a line of code that looked something like this:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;items&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;inject&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;perm&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;v&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;permissions&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;(&lt;em&gt;PS this is gibberish ruby code I made up, don’t at me.&lt;/em&gt;)&lt;/p&gt;

&lt;p&gt;When I looked at the line, I thought, &lt;em&gt;OH, ruby uses pipe?!… is that what’s going on?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;And that’s when I learned about &lt;strong&gt;Bitwise OR&lt;/strong&gt;.&lt;/p&gt;

&lt;h2 id=&quot;bitwise-or&quot;&gt;Bitwise OR&lt;/h2&gt;

&lt;p&gt;In ruby, we know OR operator to look like &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;||&lt;/code&gt;. when you see &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;|&lt;/code&gt; you’re looking at a &lt;em&gt;Bitwise&lt;/em&gt; OR operator, and what it’s comparing, is a value, &lt;strong&gt;bit by bit&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If we looked at a more simple example, we can walk through bitwise comparison step by step:&lt;/p&gt;
&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# want to know a number's binary representation?&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# use to_s and give a base as the arguement&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;to_s&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;#=&amp;gt; &quot;1100&quot;&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;9&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;to_s&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;#=&amp;gt; &quot;1001&quot;&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# so, if we wanted to compare the binary representations of 12 and 9, the bitwise or operator will look at each bit (from right to left) and choose 1 if one or both bits are 1:&lt;/span&gt;

&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;12&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;9&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;s2&quot;&gt;&quot;1 1 0 0&quot;&lt;/span&gt;
&lt;span class=&quot;s2&quot;&gt;&quot;1 0 0 1&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;---------&lt;/span&gt;
 &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# guess what number this is?&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;bhet-why&quot;&gt;bhet, WHY?!&lt;/h2&gt;

&lt;p&gt;In the example I was reviewing with the senior engineer, we were looking at code dealing with permissions, which represented them as long, binary numbers to show whether a given person had the permission, er nah.&lt;/p&gt;

&lt;p&gt;Another use case that keeps coming up is “flags” that represent
state based on several conditions…&lt;/p&gt;

&lt;p&gt;An interesting case I’d love to dive into someday is how it’s used to deal with colors, getting RGB values, and the like…&lt;/p&gt;

&lt;p&gt;If you deal with a complicated set of IF THIS THEN THAT conditionals, maybe bitwise is worth using!&lt;/p&gt;

&lt;h2 id=&quot;resources&quot;&gt;Resources&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;Fascinating resource on Bitwise Operators: &lt;a href=&quot;https://www.calleerlandsson.com/rubys-bitwise-operators/&quot;&gt;Ruby’s Bitwise Operators by Calle Erlandsson&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Visual tutorial of Bitwise Operators, language agnostic, with useful practical applications of each: &lt;a href=&quot;https://code.tutsplus.com/articles/understanding-bitwise-operators--active-11301&quot;&gt;Understanding Bitwise Operators&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Stack Overflow thread of folks giving examples for when they’ve used Bitwise operators in real life!: &lt;a href=&quot;https://stackoverflow.com/questions/2096916/real-world-use-cases-of-bitwise-operators&quot;&gt;Real world use cases of bitwise operators&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content><author><name>Kara Carrell</name></author><category term="til" /><category term="base" /><category term="bitwise" /><category term="ruby" /><summary type="html">Talking to a senior engineer the other day, I came across a line of code that looked something like this:</summary></entry><entry><title type="html">State Design Pattern</title><link href="https://kara.codes/til/state-design-pattern" rel="alternate" type="text/html" title="State Design Pattern" /><published>2017-12-12T00:00:00+00:00</published><updated>2017-12-12T00:00:00+00:00</updated><id>https://kara.codes/til/state-design-pattern</id><content type="html" xml:base="https://kara.codes/til/state-design-pattern">&lt;p&gt;Today I got to have a fascinating conversation with a senior engineer about the &lt;strong&gt;State Design Pattern&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The State Pattern, &lt;a href=&quot;https://en.wikipedia.org/wiki/State_pattern&quot;&gt;according to Wikipedia&lt;/a&gt;, is a behavioral software design pattern that implements a state machine in an object-oriented way.&lt;/p&gt;

&lt;p&gt;If a given object’s behavior shifts quite a bit based on multiple states of being throughout run time, State Pattern may be for you!&lt;/p&gt;

&lt;p&gt;You might see the objects methods holding really heavy &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;if/else&lt;/code&gt; statements, based on the objects’ state, and the state pattern lets you extract that logic into a polymorphic, abstract class, that deals with what should happen, based on state, then in your original object, you can just call on that abstract class to return the appropriate action.&lt;/p&gt;

&lt;p&gt;Some examples for what I think might be good challenges for the State Pattern to help solve are:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Apple Trees&lt;/strong&gt; - Trees bear fruit at a certain age, and can do things based on various stages of their life…&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Game Of Life&lt;/strong&gt; - Cells can live or die based on the number of neighbors it has…&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Delivery&lt;/strong&gt; - A delicious snack can be delivered based on it’s various stages of being done, there being congruent availability between me and the delivery person… and the open status of the food place.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What are some examples you can think of, or have used the State Pattern on?&lt;/p&gt;</content><author><name>Kara Carrell</name></author><category term="til" /><category term="Gang-Of-Four" /><category term="OOP" /><category term="Design-Patterns" /><category term="GOF" /><summary type="html">Today I got to have a fascinating conversation with a senior engineer about the State Design Pattern.</summary></entry></feed>