This repository has been archived on 2025-02-21. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
swift-mhoush.com/deploy/articles/2023/introduction-to-programming-for-hvac-1/index.html

321 lines
18 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8"/>
<meta content="#0e1112" media="(prefers-color-scheme: dark)" name="theme-color"/>
<meta content="#566B78" media="(prefers-color-scheme: light)" name="theme-color"/>
<meta content="Michael Housh" name="author"/>
<meta content="Mhoush" name="apple-mobile-web-app-title"/>
<meta content="initial-scale=1.0, width=device-width" name="viewport"/>
<meta content="telephone=no" name="format-detection"/>
<meta content="True" name="HandheldFriendly"/>
<meta content="320" name="MobileOptimized"/>
<meta content="Mhoush" name="og:site_name"/>
<meta content="hvac, developer, swift, home-performance, design" name="keywords"/>
<title>
mhoush: Introduction to Programming for HVAC Part-1
</title>
<link href="/static/favicon.ico" rel="shortcut icon"/>
<link href="/static/output.css" rel="stylesheet"/>
<link href="/static/style.css" rel="stylesheet"/>
<link href="/articles/feed.xml" rel="alternate" title="mhoush" type="application/rss+xml"/>
<link href="/static/prism.css" rel="stylesheet"/>
<meta content="This is part one of a series of articles to help HVAC technicians (or others) get started in developing their skills to program. This can
help to automate everyday tasks or just familiarize themselves with some of the tools used by programmers.
Why
I..." name="description"/>
<meta content="summary_large_image" name="twitter:card"/>
<meta content="http://localhost:3000/articles/images/2023-09-21-introduction-to-programming-for-hvac-1.png" name="twitter:image"/>
<meta content="Introduction to Programming for HVAC Part-1" name="twitter:image:alt"/>
<meta content="http://localhost:3000/articles/images//articles/2023/introduction-to-programming-for-hvac-1/" name="og:url"/>
<meta content="Introduction to Programming for HVAC Part-1" name="og:title"/>
<meta content="This is part one of a series of articles to help HVAC technicians (or others) get started in developing their skills to program. This can
help to automate everyday tasks or just familiarize themselves with some of the tools used by programmers.
Why
I..." name="og:description"/>
<meta content="http://localhost:3000/articles/images/2023-09-21-introduction-to-programming-for-hvac-1.png" name="og:image"/>
<meta content="1014" name="og:image:width"/>
<meta content="530" name="og:image:height"/>
<script crossorigin="anonymous" src="https://kit.fontawesome.com/f209982030.js">
</script>
</head>
<body class="bg-page text-white pb-5 font-avenir articles">
<header class="bg-nav text-gray py-4 text-base/6 lg:fixed w-full lg:h-[62px]">
<nav class="container flex gap-x-5 lg:gap-x-y items-center">
<ul class="flex flex-wrap gap-x-2 lg:gap-x-5">
<li>
<a class href="/">Home</a>
</li>
<li>
<a class="active" href="/articles/">Articles</a>
</li>
<li>
<a class href="/about/">About</a>
</li>
</ul>
</nav>
</header>
<div class="container pt-12 lg:pt-28">
<article class="prose">
<h1>
Introduction to Programming for HVAC Part-1
</h1>
<div class="-mt-6">
<div class="text-gray gray-links text-sm">
<span class="border-r border-gray pr-2 mr-2">September 21, 2023</span>1650 words, posted in <a href="/articles/tag/hvac/">HVAC</a>, <a href="/articles/tag/programming/">programming</a> and <a href="/articles/tag/software/">software</a>
</div>
</div>
<img alt="banner" src="http://localhost:3000/articles/images/2023-09-21-introduction-to-programming-for-hvac-1.png"/>
<p>This is part one of a series of articles to help HVAC technicians (or others) get started in developing their skills to program. This can
help to automate everyday tasks or just familiarize themselves with some of the tools used by programmers.</p>
<h2>Why</h2>
<p>I think if nothing else, this series can help gain knowledge, tips, and tricks to make you more comfortable with your computer. I hope that
you will at least learn how to use your <code>terminal</code> application and more specifically <code>vim</code> motions and keybindings (more on that in another
article).</p>
<p>The goal of this article is to just get a machine setup with tools and to start exploring. I am a shill for <code>macOS</code>, so all of these will be
specifically geared towards that and my workflows, most everything that is showcased should also work on <code>linux</code> machines (not sure about
<code>windows</code>), although you may have to search for specific instructions on installing software for other platforms.</p>
<p>What I have learned on my journey in programming is that the more you can lean on small software packages that focus on a single task, but
do them well, the better. The less you use your mouse, the more productive you can be. The more you can work with <code>text</code> files and formats
the more portable and transformable your workflows can be.</p>
<h2>Getting Started</h2>
<p>The first thing that we will focus on is becoming familiar with the terminal application. On macOS the terminal application is located at
<code>/Applications/Utilities/Terminal.app</code>. However, rather than click around to find it, you can use the <code>&lt;space&gt;</code> to pull up your spotlight
search, then type <code>Terminal</code> to select the terminal application.</p>
<p><img src="/articles/images/2023-09-21-spotlight.png" alt="spotlight" /></p>
<h3>Terminal Overview</h3>
<p>Your terminal is a program that allows you to run programs by typing commands into its window. There are a lot of built-in commands and a
bunch that you can install. The terminal is very customizable (and once familiar, you will constantly be tweaking / adjusting to suit your
needs). Right now customization is not what we will focus on, however in future articles I will provide tips and tricks on customizing it.
Right now, we only need to know how to open it up and type in commands.</p>
<p><img src="/articles/images/2023-09-21-terminal.png" alt="terminal" /></p>
<p>Below is an image / explanation of what the default status line includes.</p>
<p><img src="/articles/images/2023-09-21-terminal-line.png" alt="terminal-line" /></p>
<h3>Learn Basic Commands (Built-in)</h3>
<p>Here are a few basic commands that you should familiarize yourself with, as you will use them often when working inside of a terminal.</p>
<h3>Change Directory</h3>
<p><code>cd</code> (change directory) is the command that allows you to move around your file system when inside the terminal.</p>
<blockquote>
<p><strong>Note:</strong> <code>~</code> is a representation of your <code>Home</code> directory.</p>
</blockquote>
<pre><code class="language-bash">cd ~/Documents
</code></pre>
<p>The above command will move you into your Documents directory.</p>
<blockquote>
<p><strong>Note:</strong> If there are spaces in the name of the directory you try to move to then the easiest way is to wrap the name in quotes.</p>
</blockquote>
<pre><code class="language-bash">cd &quot;~/Documents/Product Concepts&quot;
</code></pre>
<p>Some other things to understand when moving around / supplying arguments to the <code>cd</code> command.</p>
<p>You can use <code>..</code> to go backwards / move up to the parent directory. For example, say we are in the <code>~/Documents</code> directory, to go back up to
the home directory we could use the following:</p>
<pre><code class="language-bash">cd ..
</code></pre>
<p>These can be chained together as well. For example say we are located in the <code>~/Documents/Product Concepts</code> directory, we could use the
following to go up two directory levels back to the home directory.</p>
<pre><code class="language-bash">cd ../..
</code></pre>
<blockquote>
<p><strong>Pro-Tip:</strong> You can use the <code>&lt;tab&gt;</code> key when navigating to auto-complete, generally typing a few characters followed with the <code>&lt;tab&gt;</code> key
will auto-complete for you.</p>
</blockquote>
<h3>List files</h3>
<p>Use <code>ls</code> to output a list of files and directories where you are located.</p>
<pre><code class="language-bash">ls
</code></pre>
<p><em>Example Output when in my ~/Documents directory</em></p>
<pre><code class="language-bash">Estimates.app
InkscapeDrawings
KwikModel
MyAparment
NCISummit
Personal
Product Concepts
Receipts.receipts
RingCentral
SketchUP
Tech-Tips
desktop.ini
espanso-migrate-backup
espanso-migrate-backup-2
</code></pre>
<p>Using options with <code>ls</code> to show more statistics and hidden files. There are often hidden files on your computer that are used for
application support or other purposes, these files are not shown using the default command. Hidden files start with a <code>.</code>, below is an
example of showing hidden files in your home directory.</p>
<pre><code class="language-bash">ls -la ~/
</code></pre>
<blockquote>
<p><strong>Note:</strong> Above I added the <code>~/</code> which will allow you to list the files in your home directory even if you currently are not there in your
terminal, if you were already there (for example by using <code>cd ~/</code> then you would not need to use that at the end of the command.</p>
</blockquote>
<p><em>Example Output</em></p>
<pre><code>total 168
drwxr-xr-x+ 46 michael staff 1472 Sep 22 10:45 .
drwxr-xr-x 6 root admin 192 Sep 22 09:08 ..
-r-------- 1 michael staff 7 Apr 8 2021 .CFUserTextEncoding
-rw-r--r--@ 1 michael staff 14340 Sep 18 10:15 .DS_Store
drwx------+ 5 michael staff 160 Sep 20 17:03 .Trash
-rw-r--r-- 1 michael staff 186 Sep 12 15:20 .actrc
drwxr-xr-x 4 michael staff 128 Dec 13 2021 .bin
drwxr-xr-x 3 michael staff 96 Mar 6 2023 .bundle
drwxr-xr-x 7 michael staff 224 Sep 12 11:40 .cabal
drwxr-xr-x 7 michael staff 224 Sep 12 15:20 .cache
drwxr-xr-x 13 michael staff 416 Aug 10 08:47 .config
drwx------ 3 michael staff 96 Jun 21 2021 .cups
drwxr-xr-x 12 michael staff 384 Sep 15 15:22 .docker
drwxr-xr-x 20 michael staff 640 Sep 19 08:11 .dotfiles
drwxr-xr-x 4 michael staff 128 Jul 26 2021 .gem
drwxr-xr-x 3 michael staff 96 Oct 11 2021 .jssc
-rw------- 1 michael staff 20 Sep 22 10:45 .lesshst
drwxr-x--- 3 michael staff 96 Mar 29 08:47 .lldb
drwxr-xr-x 8 michael staff 256 Mar 1 2023 .local
drwxr-xr-x 4 root staff 128 Apr 12 2021 .newtek
drwxr-xr-x 5 michael staff 160 Dec 13 2021 .npm
-rw------- 1 michael staff 27436 Apr 10 10:21 .psql_history
drwxr-xr-x 7 michael staff 224 Apr 18 2022 .ssh
drwxr-xr-x 6 michael staff 192 Sep 21 09:06 .swiftpm
lrwxr-xr-x 1 michael staff 25 Dec 27 2021 .tmux.conf -&gt; .dotfiles/tmux/.tmux.conf
drwxr-xr-x 8 michael staff 256 Mar 27 16:14 .twilio-cli
drwxr-xr-x 6 michael staff 192 Sep 18 11:08 .vim
-rw------- 1 michael staff 23086 Sep 21 09:45 .viminfo
-rw-r--r-- 1 michael staff 254 Sep 21 09:32 .wget-hsts
lrwxr-xr-x 1 michael staff 43 Jan 3 2022 .zshenv -&gt; /Users/michael/.dotfiles/zsh/config/.zshenv
drwxr-xr-x 8 michael staff 256 Dec 14 2021 AmazonWorkDocsCompanion
drwx------@ 4 michael staff 128 Dec 13 2021 Applications
lrwxr-xr-x 1 michael staff 40 Jun 6 12:00 Applications (Parallels) -&gt; /Volumes/Bucket/Applications (Parallels)
drwx------@ 30 michael staff 960 Sep 21 08:54 Desktop
drwx------@ 19 michael staff 608 Sep 14 10:15 Documents
drwx------@ 21 michael staff 672 Sep 21 09:43 Downloads
drwx------+ 115 michael staff 3680 Sep 14 10:04 Library
drwxr-xr-x 3 michael staff 96 Sep 8 13:06 LocalProjects
lrwxr-xr-x 1 michael staff 29 Dec 30 2021 Movies -&gt; /Volumes/Bucket/Videos/Movies
lrwxr-xr-x 1 michael staff 21 Dec 30 2021 Music -&gt; /Volumes/Bucket/Music
drwx------@ 2 michael staff 64 Mar 6 2023 Parallels
drwx------@ 7 michael staff 224 Sep 14 09:52 Pictures
drwxr-x---+ 4 michael staff 128 Apr 8 2021 Public
drwxr-xr-x+ 3 michael staff 96 Sep 14 09:52 Sites
drwxr-xr-x 3 michael staff 96 Jun 7 2021 WorkDocs Drive
drwxr-xr-x 3 michael staff 96 Sep 18 11:36 go
</code></pre>
<p>As you can see, I have a lot of hidden files and folders, your output will probably look much different than mine.</p>
<h3>Clearing the Terminal</h3>
<p>Often times you may want to clear the terminal screen. You can use the <code>clear</code> command to clear the screen of the terminal.</p>
<pre><code class="language-bash">clear
</code></pre>
<p>Or use a keyboard shortcut <code>⌃l</code> (<code>&lt;control&gt;l</code>)</p>
<h3>Creating Directories</h3>
<p>Use <code>mkdir</code> (make directory) to create a directory.</p>
<p>First, lets move into the <code>tmp</code> directory, the <code>tmp</code> directory is a directory on your file system that is typically used for applications
to write temporary logs / files to, it gets erased everytime your computer is restarted. We can use the <code>cd</code> command that we learned
earlier.</p>
<pre><code class="language-bash">cd /tmp
</code></pre>
<p>Next, lets create a new directory called “MyDirectory”.</p>
<pre><code class="language-bash">mkdir MyDirectory
</code></pre>
<h4>Gotchas with mkdir</h4>
<p>By default you cant create directories that are multiple levels deep, unless the directories already existed or we provide the <code>-p</code> option.
For example, if we want to create a directory at <code>/tmp/MyOtherDirectory/Nested/Deeply</code> then we could use the following command when inside
the <code>tmp</code> directory.</p>
<pre><code class="language-bash">mkdir -p MyOtherDirectory/Nested/Deeply
</code></pre>
<p>Now, try out using the <code>&lt;tab&gt;</code> key with the <code>cd</code> command to navigate to the <code>Deeply</code> folder.</p>
<pre><code class="language-bash">cd MyOther &lt;tab&gt; &lt;tab&gt; &lt;tab&gt;
</code></pre>
<h3>Open Command</h3>
<p>You can use the open command to open files or folders in the default application for the file type.</p>
<p>For example, if we want to open a <code>Finder</code> window while in the <code>/tmp</code> directory, we can use the following command:</p>
<pre><code class="language-bash">open .
</code></pre>
<h3>Manual Pages</h3>
<p>Lastly, to learn more about commands you can use the <code>man &lt;command&gt;</code>. To bring up the manual pages for the command in the terminal. You can
use the arrow keys to navigate around the manual pages and type the letter <code>q</code> to quit / close the manual pages.</p>
<pre><code class="language-bash">man ls
</code></pre>
<p>That is it for the first installment in this series. I hope you learned something and have better understanding of using your terminal.</p>
</article>
<div class="border-t border-light mt-8 pt-8">
<h2 class="text-4xl font-extrabold mb-8">
Written by
</h2>
<div class="flex flex-col lg:flex-row gap-8">
<div class="flex-[0_0_120px]">
<img class="w-[120px] h-[120px] rounded-full" src="/static/images/avatar.png"/>
</div>
<div class="prose">
<h3 class="!m-0">
Michael Housh
</h3>
<p class="text-gray">
HVAC business owner with over 27 years of experience. Writes articles about HVAC,
Programming, Home-Performance, and Building Science
</p>
</div>
</div>
</div>
<div class="mt-16">
<h2 class="text-4xl font-extrabold mb-8">
More articles
</h2>
<div class="grid lg:grid-cols-2 gap-10">
<section>
<h2 class="text-2xl font-bold mb-2">
<a class="[&:hover]:border-b border-orange" href="/articles/2025/vapor-htmx-todo-app/">Vapor + HTMX</a>
</h2>
<div class="text-gray gray-links text-sm mb-4">
<span class="border-r border-gray pr-2 mr-2">January 05, 2025</span><a href="/articles/tag/general/">general</a>, <a href="/articles/tag/programming/">programming</a> and <a href="/articles/tag/software/">software</a>
</div>
<p>
<a href="/articles/2025/vapor-htmx-todo-app/"><div>
Build an example application using Vapor and HTMX.
</div></a>
</p>
</section>
<section>
<h2 class="text-2xl font-bold mb-2">
<a class="[&:hover]:border-b border-orange" href="/articles/2024/free-as-in-freedom/">Free As In Freedom</a>
</h2>
<div class="text-gray gray-links text-sm mb-4">
<span class="border-r border-gray pr-2 mr-2">April 09, 2024</span><a href="/articles/tag/general/">general</a>, <a href="/articles/tag/open-source/">open-source</a> and <a href="/articles/tag/software/">software</a>
</div>
<p>
<a href="/articles/2024/free-as-in-freedom/"><div>
Salute to open-source software engineers
</div></a>
</p>
</section>
</div>
<p class="prose mt-8">
<a href="/articles/"> See all articles</a>
</p>
</div>
</div>
<div class="site-footer container text-gray gray-links border-t border-light text-center pt-6 mt-8 text-sm">
<p>
Copyright © Michael Housh 2023-2025.
</p>
<p>
Built in Swift using
<a href="https://github.com/loopwerk/Saga" rel="nofollow" target="_blank">Saga</a>
(<a href="https://github.com/m-housh/mhoush.com" rel="nofollow" target="_blank">source</a>).
</p>
<p>
<a href="http://localhost:3000/articles/feed.xml" rel="nofollow" target="_blank">RSS</a>
|
<a href="https://github.com/m-housh" rel="nofollow" target="_blank">Github</a>
|
<a href="https://www.youtube.com/channel/UCb58SeURd5bObfTiL0KoliA" rel="nofollow" target="_blank">Youtube</a>
|
<a href="https://www.facebook.com/michael.housh" rel="nofollow" target="_blank">Facebook</a>
|
<a href="mailto:michael@mhoush.com" rel="nofollow">Email</a>
</p>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-core.min.js">
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/keep-markup/prism-keep-markup.min.js">
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/autoloader/prism-autoloader.min.js">
</script>
</div>
</body>
</html>