<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Jason Hee</title>
    <description>The latest articles on DEV Community by Jason Hee (@jasonheecs).</description>
    <link>https://dev.to/jasonheecs</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F633450%2F2c8ea3bb-96d6-4e6c-b3ae-ca70b8f51b68.png</url>
      <title>DEV Community: Jason Hee</title>
      <link>https://dev.to/jasonheecs</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jasonheecs"/>
    <language>en</language>
    <item>
      <title>Training machine learning models to recognize fruits</title>
      <dc:creator>Jason Hee</dc:creator>
      <pubDate>Tue, 01 Dec 2026 02:35:09 +0000</pubDate>
      <link>https://dev.to/jasonheecs/training-machine-learning-models-to-recognize-fruits-1dme</link>
      <guid>https://dev.to/jasonheecs/training-machine-learning-models-to-recognize-fruits-1dme</guid>
      <description>&lt;p&gt;As part of a learning exercise, I've trained a couple of machine learning models to detect and recognize a wide variety of fruits. The models are loaded locally in the browser via WebGPU, and all detection is done client side, so no data gets sent outside of the client.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://fruitlens.app/" rel="noopener noreferrer"&gt;Try it out!&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://blog.jasonhee.com/content/media/2026/11/fruitlens-preview-1.mp4" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkqi84l2751iigdyfpwfw.jpg" alt="The fruitlens web app" width="608" height="1080"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The fruitlens web app&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Architecture
&lt;/h2&gt;

&lt;p&gt;I split the problem of recognizing fruits in a scene into 2 smaller separate problems.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Is there a fruit in the scene?&lt;/li&gt;
&lt;li&gt; If there is a fruit, what is the fruit?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For the first problem, a detector model reads each frame of the video feed and attempts to find any fruit-like object in the scene. Once found, we then move on to solve the second problem by using a classifier model to attempt to recognize the fruit object.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqwnqdzhn5m5qip7f85e1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqwnqdzhn5m5qip7f85e1.png" alt=" " width="800" height="231"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are two separate pipelines that train the detector and classifier models. Once trained, the models are then uploaded to a web server. The web app downloads the models to the client when a user visits the web app.&lt;/p&gt;

&lt;h2&gt;
  
  
  Evaluation Set
&lt;/h2&gt;

&lt;p&gt;Before talking about the training pipelines, a more pertinent question to be asked is: "How do we know if the detector and classifier are any good?"&lt;/p&gt;

&lt;p&gt;To answer that question, I scored the classifier and detector against a set of 20 real photos of fruit. These photos are marked manually to indicate exactly where each piece of fruit is, and what fruit it is. These photos form the evaluation set, which every version of the classifier and detector will be scored against. This will help inform me if a newly trained version of a model is "better" than the previous version.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fk1va7g8un57zyup7uqf2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fk1va7g8un57zyup7uqf2.png" alt=" " width="800" height="476"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Foaq557hi0opm43ni1n3i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Foaq557hi0opm43ni1n3i.png" alt=" " width="800" height="483"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmpr71a21h495soiukn4i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmpr71a21h495soiukn4i.png" alt=" " width="800" height="469"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Some examples of the images in the evaluation set&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The models are scored against the evaluation set using these criteria:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Did they find all the fruit?&lt;/li&gt;
&lt;li&gt;How many did they miss?&lt;/li&gt;
&lt;li&gt;How many fake identifications (false positives) did they make?&lt;/li&gt;
&lt;li&gt;Of the fruits found, how often did they get the name right?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Twenty photos might seem small for an evaluation set, but that's intentional. The size of the evaluation set has to be manageable for one person to look at every single mistake. I can then analyze what is happening, instead of solely relying on metrics.&lt;/p&gt;

&lt;p&gt;For people familiar with ML, these are the actual metrics for the detector and classifier models:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Number&lt;/th&gt;
&lt;th&gt;The question it answers&lt;/th&gt;
&lt;th&gt;Score&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Detector mAP&lt;/td&gt;
&lt;td&gt;How closely do its boxes line up with the real fruit, and is it most confident about the right ones?&lt;/td&gt;
&lt;td&gt;0.33&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Detector recall&lt;/td&gt;
&lt;td&gt;Of all the real fruit in the photos, how much did it find?&lt;/td&gt;
&lt;td&gt;65%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Detector precision&lt;/td&gt;
&lt;td&gt;Of all the boxes it drew, how many had fruit in them?&lt;/td&gt;
&lt;td&gt;74%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;False positives per image&lt;/td&gt;
&lt;td&gt;How many boxes per photo landed on something that isn't fruit?&lt;/td&gt;
&lt;td&gt;2.4&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Classification accuracy&lt;/td&gt;
&lt;td&gt;When it named a fruit, how often was the name right?&lt;/td&gt;
&lt;td&gt;81%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Classifier F1&lt;/td&gt;
&lt;td&gt;Fruit by fruit, how well does it catch each one without handing its name to the wrong fruit?&lt;/td&gt;
&lt;td&gt;0.74&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Coverage&lt;/td&gt;
&lt;td&gt;Of the fruit it found, how much was it confident enough to name at all?&lt;/td&gt;
&lt;td&gt;75%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  How the detector works
&lt;/h2&gt;

&lt;p&gt;The detector has one job, to look at a video frame and see if there's a fruit in the scene. It doesn't try to identify the fruit, that's the job of the classifier.&lt;/p&gt;

&lt;p&gt;It's built on top of YOLO (You Only Look Once), a CNN designed for real-time object detection. By default, a YOLO model is trained to detect a wide variety of objects; I fine tuned it against a corpus of fruit images to tailor it specifically on fruits.&lt;/p&gt;

&lt;p&gt;To teach it what fruit looks like, I fed it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Real photos of fruit from a giant public photo collection, with boxes already drawn around each piece.&lt;/li&gt;
&lt;li&gt;Extra photos of fruit piled up in big messy groups (like a crate of apples), so it also learns to spot fruit in a crowd.&lt;/li&gt;
&lt;li&gt;Photos of things that look like fruit but aren't: balls, hands, phones, with no boxes drawn, so it learns what to ignore.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fe1ydvskd2j6kux1eu5ul.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fe1ydvskd2j6kux1eu5ul.png" alt=" " width="799" height="347"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;All three sources point at the same detector. It never sees which dataset a photo came from, only the fruit boxes (or the lack of any) in it.&lt;/p&gt;

&lt;h2&gt;
  
  
  How the classifier works
&lt;/h2&gt;

&lt;p&gt;The detector determines if there is a fruit in the scene. If there is, the classifier then attempts to identify the fruit using the cropped piece of the scene.&lt;/p&gt;

&lt;p&gt;The classifier is built on MobileNet, a small mobile friendly image recognition model. Similar to the detector, it is fine tuned specifically on images of fruit.&lt;/p&gt;

&lt;p&gt;There is one valued learning from fine tuning the classifier. The usual data augmentation techniques that is applied on the corpus had to be applied carefully for this use case. For fruits, the color is often the main clue as to what fruit it is (green vs red apple, ripe vs unripe banana, etc.). Twist the colors too much during fine tuning, and you'll accidentally teach the model the wrong lesson.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fr2n4lt6rfb58pshn65lo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fr2n4lt6rfb58pshn65lo.png" alt=" " width="799" height="305"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Quantization
&lt;/h2&gt;

&lt;p&gt;For performance optimization, the models are quantized to fp16 before deployment to the web server.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F50izunuoc3ev2209bchg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F50izunuoc3ev2209bchg.png" alt=" " width="799" height="248"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ffk4hnso1qt56nqrs7llb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ffk4hnso1qt56nqrs7llb.png" alt=" " width="800" height="177"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;One lesson learnt from the quantization of these models, if I quantize every layer of the model equally, the models perform quite badly. The problem was the first layer (the stem, which reads the raw pixels) and the last layer (the head, which produces the boxes or class scores). Both are very sensitive to rounding. Mess with those and the whole thing falls apart. Quantize everything in between, though, is totally fine. Once I figured out to leave the first and last layers alone, the quantized models performed almost exactly as well as the full-size ones.&lt;/p&gt;

&lt;h2&gt;
  
  
  Loading it all client side
&lt;/h2&gt;

&lt;p&gt;When you visit &lt;a href="https://fruitlens.app/" rel="noopener noreferrer"&gt;https://fruitlens.app&lt;/a&gt;, it loads the detector and classifier models into your browser. The loading process is in a separate background thread so the page remains responsive.&lt;/p&gt;

&lt;p&gt;Then, while your camera is on, roughly 10 times a second, it grabs a snapshot and runs it through four steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Find&lt;/strong&gt; - spot the fruit-shaped boxes in the frame.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Track&lt;/strong&gt; - match each box to the one from a split second ago, so it's not treating the same banana as a brand new banana every single frame.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Name&lt;/strong&gt; - crop out each box and figure out what fruit it is. If there's a bunch of fruit in frame, it bundles all the crops together and asks the model once, instead of asking one at a time (which would be slower).&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Draw&lt;/strong&gt; - paint the boxes on screen and show the nutrition info for whichever fruit is selected.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The drawing code runs at 60 frames per second, separate from the Vue UI. Updating the UI is expensive, so it only hears about detections when they change.&lt;/p&gt;

&lt;p&gt;Labels are also kept from flickering. A tracked fruit only changes its name after two classifications in a row agree on the new one.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try to break it
&lt;/h2&gt;

&lt;p&gt;Open &lt;a href="https://fruitlens.app/" rel="noopener noreferrer"&gt;fruitlens.app&lt;/a&gt; and point it at whatever fruit you have lying around. If it gets something wrong, I'd like to hear about it. A photo it fails on is the most useful thing you can send me.&lt;/p&gt;

&lt;p&gt;I hope you got some useful pointers from this article. If you are interested in more articles about tech, be sure to&amp;nbsp;&lt;a href="https://blog.jasonhee.com/#/portal/signup" rel="noopener noreferrer"&gt;subscribe to get notified whenever I publish a new article&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>machinelearning</category>
      <category>computervision</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Automating the Elgato Key Light</title>
      <dc:creator>Jason Hee</dc:creator>
      <pubDate>Wed, 26 May 2021 10:42:24 +0000</pubDate>
      <link>https://dev.to/jasonheecs/automating-the-elgato-key-light-2242</link>
      <guid>https://dev.to/jasonheecs/automating-the-elgato-key-light-2242</guid>
      <description>&lt;p&gt;As video conference calls are now part of my daily life, I decided to investigate how I can look better in front of my webcam. After some research, I bought an Elgato Key Light Air to help illuminate my face better.&lt;/p&gt;

&lt;p&gt;So far, I'm delighted with the purchase. The key light has definitely improved how I look on video calls. But having to turn it on every time I have a video call and then turn it off when the call ends is a pain.&lt;/p&gt;

&lt;p&gt;I considered leaving the light on throughout the work day, but the light can be quite searing to my eyes when it's shining at me for an extended period of time.&lt;/p&gt;

&lt;p&gt;I then put on my software engineering hat and wondered, "Can I automate this inconvenience away?". As it turns out, I can.&lt;/p&gt;

&lt;h2&gt;
  
  
  Elgato Key Light REST&amp;nbsp;API
&lt;/h2&gt;

&lt;p&gt;The Elgato Key Light and Key Light Air devices actually have a web server (listening on port 9123) built in. The web server exposes a REST API:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GET /elgato/lights
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This endpoint returns the status of the key light.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sample Response&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "numberOfLights": 1,
    "lights": [
        {
            "on": 1,
            "brightness": 9,
            "temperature": 262
        }
    ]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For updating the key light, there's a PUT action endpoint:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PUT /elgato/lights

Content-Type: 'application/json'
--data-raw '{
  "Lights": [
    {
      "Temperature": 344,
      "Brightness": 100,
      "On": 1
    }
  ]
}'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This endpoint allows you to set the attributes of the key light. You can set the brightness and temperature, including turning it on or off.&lt;/p&gt;

&lt;p&gt;This means that I can turn the Elgato Key Light off and on by interfacing with its REST API endpoints.&lt;/p&gt;

&lt;h2&gt;
  
  
  A Node.js&amp;nbsp;script
&lt;/h2&gt;

&lt;p&gt;I created  &lt;a href="https://github.com/jasonheecs/elgato-key-light-automator"&gt;a Node.js script that toggles on and off the Elgato Key Light&lt;/a&gt;. I then bound the execution of the script to a keyboard macro. So now, I can tap a key to turn the Key Light on and off.&amp;nbsp;:D&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;It is relatively easy for one to interface with an Elgato Key Light or Key Light Air using its built-in REST API. You can even integrate it into your smart home via something like  &lt;a href="https://github.com/homebridge/homebridge"&gt;Homebridge&lt;/a&gt; .&lt;/p&gt;

</description>
      <category>node</category>
      <category>automation</category>
      <category>smarthome</category>
      <category>api</category>
    </item>
    <item>
      <title>How to use YAML Aliases</title>
      <dc:creator>Jason Hee</dc:creator>
      <pubDate>Tue, 18 May 2021 13:07:06 +0000</pubDate>
      <link>https://dev.to/jasonheecs/how-to-use-yaml-aliases-3kig</link>
      <guid>https://dev.to/jasonheecs/how-to-use-yaml-aliases-3kig</guid>
      <description>&lt;p&gt;Have you ever had to copy and paste duplicate content in a YAML file and wondered if it is possible to DRY that up? As it turns out, YAML allows you to repeat nodes via aliases.&lt;/p&gt;

&lt;p&gt;YAML Aliases allow you to assign a name to a value or block of data and recall the assigned data by its name in the YAML file. Aliases should work for any file written in YAML.&lt;/p&gt;

&lt;h1&gt;
  
  
  Simple Example
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;hello&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="nl"&gt;&amp;amp;hello&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;hello'&lt;/span&gt;
&lt;span class="na"&gt;greeting&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;audience&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;world'&lt;/span&gt;
  &lt;span class="na"&gt;hello&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="nv"&gt;*hello&lt;/span&gt;  &lt;span class="c1"&gt;#greeting.hello has the string value of 'hello'&lt;/span&gt;
&lt;span class="na"&gt;new_greeting&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;audience&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;room'&lt;/span&gt;
  &lt;span class="na"&gt;hello&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="nv"&gt;*hello&lt;/span&gt;  &lt;span class="c1"&gt;#new_greeting.hello has the string value of 'hello'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Aliasing blocks of&amp;nbsp;data
&lt;/h1&gt;

&lt;p&gt;Besides string or number values, you can alias a block of data as well:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;foo&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;bar&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="nl"&gt;&amp;amp;bar&lt;/span&gt;
    &lt;span class="na"&gt;qux&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;quxqux'&lt;/span&gt;
    &lt;span class="na"&gt;baz&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;bazbaz'&lt;/span&gt;
&lt;span class="na"&gt;greeting&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;audience&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;world'&lt;/span&gt;
  &lt;span class="na"&gt;bar&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="nv"&gt;*bar&lt;/span&gt;  &lt;span class="c1"&gt;#greeting.bar has the same values as foo.bar.&lt;/span&gt;
             &lt;span class="c1"&gt;#So greeting.bar.baz is 'bazbaz'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Modifying a section of an&amp;nbsp;alias
&lt;/h1&gt;

&lt;p&gt;You can copy an alias and modify a section of it by using the merge key (&amp;lt;&amp;lt;:):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;bar&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="nl"&gt;&amp;amp;bar&lt;/span&gt;
  &lt;span class="na"&gt;qux&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;quxqux'&lt;/span&gt;
  &lt;span class="na"&gt;baz&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;bazbaz'&lt;/span&gt;
&lt;span class="na"&gt;greeting&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;audience&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;world'&lt;/span&gt;
  &lt;span class="na"&gt;bar&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="s"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="nv"&gt;*bar&lt;/span&gt;       &lt;span class="c1"&gt;# greeting.bar.qux is 'quxqux'&lt;/span&gt;
    &lt;span class="na"&gt;baz&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;notbaz'&lt;/span&gt;  &lt;span class="c1"&gt;# greeting.bar.baz is 'notbaz'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Defining aliases from modified&amp;nbsp;aliases
&lt;/h1&gt;

&lt;p&gt;You can even modify a section of an alias and define that as a new alias:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;bar&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="nl"&gt;&amp;amp;bar&lt;/span&gt;
  &lt;span class="na"&gt;qux&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;quxqux'&lt;/span&gt;
  &lt;span class="na"&gt;baz&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;bazbaz'&lt;/span&gt;
&lt;span class="na"&gt;greeting&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;audience&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;world'&lt;/span&gt;
  &lt;span class="na"&gt;bar&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="nl"&gt;&amp;amp;newalias&lt;/span&gt;
    &lt;span class="s"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="nv"&gt;*bar&lt;/span&gt;
    &lt;span class="na"&gt;baz&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;notbaz'&lt;/span&gt;
&lt;span class="na"&gt;new_greeting&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;audience&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;room'&lt;/span&gt;
  &lt;span class="na"&gt;bar&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="nv"&gt;*newalias&lt;/span&gt;  &lt;span class="c1"&gt;#new_greeting.bar.baz is 'notbaz'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  YAML specification
&lt;/h1&gt;

&lt;p&gt;Alias nodes are described in the YAML specification &lt;a href="https://yaml.org/spec/1.2/spec.html#id2786196"&gt;here&lt;/a&gt; &lt;/p&gt;

</description>
      <category>yaml</category>
      <category>devops</category>
    </item>
  </channel>
</rss>
