<?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"><channel><title><![CDATA[TAW DEV]]></title><description><![CDATA[Articles on the latest tools and technology for programmers and developers.]]></description><link>https://blog.techsavvytravvy.com</link><image><url>https://cdn.hashnode.com/res/hashnode/image/upload/v1687320295448/3aWn4hBgU.png</url><title>TAW DEV</title><link>https://blog.techsavvytravvy.com</link></image><generator>RSS for Node</generator><lastBuildDate>Wed, 16 Sep 2026 04:00:04 GMT</lastBuildDate><atom:link href="https://blog.techsavvytravvy.com/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Streamlining Chrome Extension Development with Bun]]></title><description><![CDATA[I've always been intrigued by browser extensions and their ability to do crazy things and make the web cooler + get rid of ads. That said, going from concept to a working Chrome extension can be super annoying with repetitive setup tasks, configurati...]]></description><link>https://blog.techsavvytravvy.com/streamlining-chrome-extension-development-with-bun</link><guid isPermaLink="true">https://blog.techsavvytravvy.com/streamlining-chrome-extension-development-with-bun</guid><category><![CDATA[Bun]]></category><category><![CDATA[chrome extension]]></category><category><![CDATA[tools]]></category><category><![CDATA[TypeScript]]></category><category><![CDATA[cli]]></category><dc:creator><![CDATA[trav]]></dc:creator><pubDate>Thu, 18 Jan 2024 17:31:43 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1705598944591/7e77dd21-e4fe-49d1-9f10-f0c1efb0af67.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I've always been intrigued by browser extensions and their ability to do crazy things and make the web cooler + get rid of ads. That said, going from concept to a working Chrome extension can be super annoying with repetitive setup tasks, configuration, and a slow iteration cycle. To remedy this, I created <a target="_blank" href="https://github.com/trvswgnr/cextup">CExtUp</a>: a scaffolding tool designed to make Chrome extension development less painful and more enjoyable. It started with me trying out <a target="_blank" href="https://bun.sh">Bun</a> for the build step and it was so fast and easy that I thought others might appreciate it as well.</p>
<h2 id="heading-why-cextup">Why CExtUp?</h2>
<p>CExtUp was born out of my desire to simplify the initial setup process and provide a modern development environment for Chrome extensions. By using <a target="_blank" href="https://bun.sh/">Bun</a>—a modern JavaScript runtime, bundler, and package manager—instead of Node.js, CExtUp offers an insanely fast and efficient development experience that is actually pleasant to use.</p>
<h2 id="heading-key-features">Key Features</h2>
<ul>
<li><p><strong>Quick Scaffolding</strong>: CExtUp automates the creation of a new Chrome extension project, setting up a basic structure and all necessary files with just one command.</p>
</li>
<li><p><strong>Bun-Powered</strong>: The integration with Bun ensures that builds are quick and the development server is responsive, allowing for rapid prototyping and testing.</p>
</li>
<li><p><strong>TypeScript Ready</strong>: With out-of-the-box support for TypeScript, developers can write safer and more maintainable code from the get-go.</p>
</li>
<li><p><strong>Serverless Edge Functions</strong>: For those who need backend logic, CExtUp is pre-configured to use Vercel Serverless Edge Functions, though it's flexible enough to work with other serverless platforms, or even with a self-hosted solution.</p>
</li>
</ul>
<h2 id="heading-getting-started">Getting Started</h2>
<p>To get started with CExtUp, simply run the following command:</p>
<pre><code class="lang-sh">bunx cextup
<span class="hljs-comment"># or</span>
npx cextup
</code></pre>
<p>This interactive CLI will guide you through naming your new extension and create a directory with that name, populated with a well-organized set of files and folders for your project.</p>
<h2 id="heading-a-thoughtful-project-structure">A Thoughtful Project Structure</h2>
<p>CExtUp generates a project with a clear and logical structure:</p>
<ul>
<li><p><code>src/</code>: Contains the source files for your Chrome extension, including background scripts, content scripts, and the manifest file.</p>
</li>
<li><p><code>types/</code>: Houses TypeScript type definitions to ensure type safety.</p>
</li>
<li><p><code>api/</code>: If you opt for serverless functions, this is where they'll live.</p>
</li>
<li><p><code>scripts/</code>: Includes build and serve scripts to facilitate development.</p>
</li>
</ul>
<h2 id="heading-development-workflow">Development Workflow</h2>
<p>Once you've scaffolded your project with CExtUp, the development workflow is straightforward:</p>
<ol>
<li>Install Bun if you haven't already:</li>
</ol>
<pre><code class="lang-bash">curl -fsSL https://bun.sh/install | bash
</code></pre>
<ol>
<li>Install dependencies:</li>
</ol>
<pre><code class="lang-sh"><span class="hljs-built_in">cd</span> your-extension-name
bun i
</code></pre>
<ol>
<li>Start the development server and watch for changes:</li>
</ol>
<pre><code class="lang-sh">bun start
</code></pre>
<p>Alternatively, to build the extension without starting the server:</p>
<pre><code class="lang-sh">bun ./scripts/build.ts
</code></pre>
<h2 id="heading-loading-your-extension">Loading Your Extension</h2>
<p>To test your extension in Chrome, navigate to <code>chrome://extensions</code>, enable Developer Mode, and click <code>Load unpacked</code>. Select the <code>extension</code> directory from your project. Remember to reload the extension after making changes to see them reflected in the browser.</p>
<p>Let me know if you try out CExtUp and if you find it useful. Contributions, feedback, and discussions are welcome—feel free to reach out through <a target="_blank" href="https://github.com/trvswgnr/cextup/issues">GitHub issues</a> or <a target="_blank" href="https://github.com/trvswgnr/cextup/pulls">pull requests</a>.</p>
<p>Go <a target="_blank" href="https://twitter.com/techsavvytravvy">follow me</a> if you want to see what else I'm making!</p>
]]></content:encoded></item><item><title><![CDATA[Making a Spotify “Now Playing” Widget for tmux]]></title><description><![CDATA[This is going to be a "quick" little guide to customizing the tmux status bar to include a scrolling Spotify “Now Playing” widget. I’m going to be doing this on macOS, but you should be able to adapt it to Linux and I'll try to assist where I can. If...]]></description><link>https://blog.techsavvytravvy.com/making-a-spotify-now-playing-widget-for-tmux</link><guid isPermaLink="true">https://blog.techsavvytravvy.com/making-a-spotify-now-playing-widget-for-tmux</guid><category><![CDATA[tmux]]></category><category><![CDATA[Bash]]></category><category><![CDATA[Spotify]]></category><category><![CDATA[coding]]></category><category><![CDATA[fun]]></category><dc:creator><![CDATA[trav]]></dc:creator><pubDate>Tue, 20 Jun 2023 09:17:54 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1687252190441/f0c72b78-612f-4033-a885-7bcd78425db2.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>This is going to be a "quick" little guide to customizing the tmux status bar to include a scrolling Spotify “Now Playing” widget. I’m going to be doing this on macOS, but you should be able to adapt it to Linux and I'll try to assist where I can. If you’re on Windows… I have no idea. Here are the tools we’re going to use:</p>
<ul>
<li><p><a target="_blank" href="https://github.com/tmux/tmux/wiki">tmux</a> - Kind of obvious. I’m assuming you already have this.</p>
</li>
<li><p><a target="_blank" href="https://github.com/Rigellute/spotify-tui">spotify-tui</a> - We’ll mostly just be using this for the <code>spt playback</code> CLI command to get the playback info.</p>
</li>
<li><p><a target="_blank" href="https://github.com/Spotifyd/spotifyd">spotifyd</a>- We need this for the “song changed” hook and so we don’t need the Spotify app open.</p>
</li>
<li><p>bash - You already know.</p>
</li>
<li><p><a target="_blank" href="https://brew.sh/">homebrew</a> - Skip this if you’re not on macOS. I’ll be using it to download all of these tools and also to launch the <code>spotifyd</code> daemon. Again, I’m going to assume you already have this.</p>
</li>
<li><p><a target="_blank" href="https://spotify.com">Spotify</a> - You'll probably need this, eh? I'm pretty sure you need Spotify Premium for this to work, but I'm not positive.</p>
</li>
</ul>
<h2 id="heading-prerequisites">Prerequisites</h2>
<p>Before we get started, go <a target="_blank" href="https://developer.spotify.com/">make a Spotify developer account</a> if you don’t already have one. Then <a target="_blank" href="https://developer.spotify.com/dashboard/create">create a new app</a> in the developer dashboard. The name and description don’t matter, but make sure you add <code>http://localhost:8888/callback</code> to the "Redirect URIs" section - spotify-tui requires this and we’ll revisit it later.</p>
<h2 id="heading-installing-the-tools">Installing the Tools</h2>
<p>Now let’s get our tools. If you're on macOS, use the following command:</p>
<pre><code class="lang-bash">brew install spotify-tui
brew install spotifyd
</code></pre>
<p>For Linux users, you can install the tools using your package manager or by following the instructions on their respective GitHub repositories (<a target="_blank" href="https://github.com/Rigellute/spotify-tui#installation">spotify-tui</a> and <a target="_blank" href="https://github.com/Spotifyd/spotifyd#installation">spotifyd</a>).</p>
<h2 id="heading-creating-the-script">Creating the Script</h2>
<p>Now we can get a little crazy with some bash scripting. We’re going to gloss over this, but essentially it uses the <code>spt playback</code> subcommand from spotify-tui to get the current song in a specified format, then uses the current date in seconds to calculate the scroll position if the playback info is longer than a certain number of characters. It does some tempfile file things to store the state and saves us from calling the Spotify API too many times.</p>
<p>Save this script anywhere you want but let’s name it <code>spt_status.sh</code>.</p>
<pre><code class="lang-bash"><span class="hljs-meta">#!/usr/bin/env bash</span>

tmpdir=<span class="hljs-string">"<span class="hljs-variable">$TMPDIR</span>/spt_status"</span>
data_file=<span class="hljs-string">"<span class="hljs-variable">$tmpdir</span>/current.txt"</span>

<span class="hljs-keyword">if</span> [ ! -d <span class="hljs-string">"<span class="hljs-variable">$tmpdir</span>"</span> ]; <span class="hljs-keyword">then</span>
    <span class="hljs-built_in">printf</span> <span class="hljs-string">"\rInitializing..."</span>

    <span class="hljs-comment"># create the directory</span>
    mkdir <span class="hljs-string">"<span class="hljs-variable">$tmpdir</span>"</span>

    <span class="hljs-comment"># initialize the data file</span>
    <span class="hljs-built_in">echo</span> <span class="hljs-string">"null"</span> &gt;<span class="hljs-string">"<span class="hljs-variable">$data_file</span>"</span>
    <span class="hljs-built_in">echo</span> <span class="hljs-string">"false"</span> &gt;&gt;<span class="hljs-string">"<span class="hljs-variable">$data_file</span>"</span>

    <span class="hljs-built_in">printf</span> <span class="hljs-string">"\rInitialized successfully!"</span>

    <span class="hljs-built_in">exit</span> 0
<span class="hljs-keyword">fi</span>

<span class="hljs-comment"># the first line of the data file is the output of the last run</span>
output=$(head -n 1 <span class="hljs-string">"<span class="hljs-variable">$data_file</span>"</span> 2&gt;/dev/null)

<span class="hljs-comment"># the second line is whether or not we've already updated</span>
updated=$(tail -n 1 <span class="hljs-string">"<span class="hljs-variable">$data_file</span>"</span> 2&gt;/dev/null)

<span class="hljs-keyword">if</span> [ <span class="hljs-string">"<span class="hljs-variable">$1</span>"</span> = <span class="hljs-string">"--update"</span> ]; <span class="hljs-keyword">then</span>
    <span class="hljs-built_in">printf</span> <span class="hljs-string">"\rUpdating..."</span>

    <span class="hljs-comment"># only get the playback information if we haven't already updated</span>
    <span class="hljs-keyword">if</span> [ <span class="hljs-string">"<span class="hljs-variable">$updated</span>"</span> != <span class="hljs-string">"true"</span> ]; <span class="hljs-keyword">then</span>
        <span class="hljs-comment"># write the playback information to the data file</span>
        <span class="hljs-built_in">echo</span> <span class="hljs-string">"null"</span> &gt;<span class="hljs-string">"<span class="hljs-variable">$data_file</span>"</span>

        <span class="hljs-comment"># write that we've updated to the data file</span>
        <span class="hljs-built_in">echo</span> <span class="hljs-string">"true"</span> &gt;&gt;<span class="hljs-string">"<span class="hljs-variable">$data_file</span>"</span>
    <span class="hljs-keyword">fi</span>

    <span class="hljs-built_in">exit</span> 0
<span class="hljs-keyword">fi</span>

<span class="hljs-comment"># get the output from the data file</span>
output=$(head -n 1 <span class="hljs-string">"<span class="hljs-variable">$data_file</span>"</span> 2&gt;/dev/null)

<span class="hljs-comment"># if the output is null, get the playback information</span>
<span class="hljs-keyword">if</span> [ <span class="hljs-string">"<span class="hljs-variable">$output</span>"</span> = <span class="hljs-string">"null"</span> ]; <span class="hljs-keyword">then</span>
    <span class="hljs-comment"># format options:</span>
    <span class="hljs-comment"># %a: artist, %b: album, %p: playlist, %t: track, %h: show,</span>
    <span class="hljs-comment"># %f: flags (shuffle, repeat, like), %s: playback status, %v: volume, %d: current device</span>

    <span class="hljs-comment"># get the playback information</span>
    pb=$(/usr/<span class="hljs-built_in">local</span>/bin/spt playback --format <span class="hljs-string">"%s %a: %t"</span> 2&gt;/dev/null || <span class="hljs-built_in">echo</span> <span class="hljs-string">"null"</span>)

    <span class="hljs-comment"># write the playback information to the data file</span>
    <span class="hljs-built_in">echo</span> <span class="hljs-string">"<span class="hljs-variable">$pb</span>"</span> &gt;<span class="hljs-string">"<span class="hljs-variable">$data_file</span>"</span>

    <span class="hljs-comment"># write that we haven't updated to the data file</span>
    <span class="hljs-built_in">echo</span> <span class="hljs-string">"false"</span> &gt;&gt;<span class="hljs-string">"<span class="hljs-variable">$data_file</span>"</span>

    <span class="hljs-comment"># get the output from the data file</span>
    output=$(head -n 1 <span class="hljs-string">"<span class="hljs-variable">$data_file</span>"</span> 2&gt;/dev/null)
<span class="hljs-keyword">fi</span>

<span class="hljs-comment"># remove all newlines from the output</span>
output=$(<span class="hljs-built_in">echo</span> <span class="hljs-string">"<span class="hljs-variable">$output</span>"</span> | tr -d <span class="hljs-string">'\n'</span>)

<span class="hljs-comment"># max length of the output</span>
max_length=35

<span class="hljs-comment"># the speed at which the text should scroll (characters per second)</span>
scroll_speed=10

<span class="hljs-keyword">if</span> [ <span class="hljs-string">"<span class="hljs-variable">$output</span>"</span> = <span class="hljs-string">"null"</span> ]; <span class="hljs-keyword">then</span>
    <span class="hljs-comment"># if the output is null, print an error message and exit</span>
    <span class="hljs-built_in">printf</span> <span class="hljs-string">"\rSomething went wrong..."</span>

    <span class="hljs-built_in">exit</span> 1
<span class="hljs-keyword">fi</span>

<span class="hljs-keyword">if</span> [ <span class="hljs-variable">${#output}</span> -gt <span class="hljs-variable">$max_length</span> ]; <span class="hljs-keyword">then</span>
    <span class="hljs-comment"># get the current time in seconds</span>
    current_time=$(date +%s)

    <span class="hljs-comment"># first character is the play/pause symbol</span>
    play_pause_symbol=<span class="hljs-string">"<span class="hljs-variable">${output:0:2}</span>"</span>

    <span class="hljs-comment"># the rest of the output is the track information</span>
    output=<span class="hljs-variable">${output:2}</span>

    <span class="hljs-comment"># calculate the scroll position based on the current time and scroll speed</span>
    scroll_position=$((current_time * scroll_speed % (<span class="hljs-variable">${#output}</span> + max_length)))

    <span class="hljs-comment"># create a padded version of the output with spaces</span>
    padded_output=<span class="hljs-string">"<span class="hljs-variable">${output}</span><span class="hljs-subst">$(printf '%*s' $((max_length)</span>) '')<span class="hljs-variable">${output}</span>"</span>

    <span class="hljs-comment"># extract the substring to display based on the scroll position</span>
    displayed_output=<span class="hljs-string">"<span class="hljs-variable">${padded_output:$scroll_position:(($max_length - 2))}</span>"</span>

    <span class="hljs-built_in">printf</span> <span class="hljs-string">"\r%s%s "</span> <span class="hljs-string">"<span class="hljs-variable">$play_pause_symbol</span>"</span> <span class="hljs-string">"<span class="hljs-variable">$displayed_output</span>"</span>

    <span class="hljs-built_in">exit</span> 0
<span class="hljs-keyword">fi</span>

padded_output=<span class="hljs-string">"<span class="hljs-variable">${output}</span><span class="hljs-subst">$(printf '%*s' $((max_length + 1 - ${#output})</span>) '')"</span>
<span class="hljs-built_in">printf</span> <span class="hljs-string">"\r%s"</span> <span class="hljs-string">"<span class="hljs-variable">$padded_output</span>"</span>
</code></pre>
<p>Make sure you run <code>chmod +x spt_status.sh</code> to make it executable.</p>
<h2 id="heading-configuring-the-daemon">Configuring the Daemon</h2>
<p>Now, we’re almost ready to see it in action, but there are a couple of things we need to do first.</p>
<p>For macOS users, we’ll make a small modification to the .plist file that <code>brew</code> uses to launch the daemon. Open up <code>/usr/local/Cellar/spotifyd/0.3.4/homebrew.mxcl.spotifyd.plist</code> (modify to match your version) and look for this section around line 17:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">key</span>&gt;</span>ProgramArguments<span class="hljs-tag">&lt;/<span class="hljs-name">key</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">array</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">string</span>&gt;</span>/usr/local/opt/spotifyd/bin/spotifyd<span class="hljs-tag">&lt;/<span class="hljs-name">string</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">string</span>&gt;</span>--no-daemon<span class="hljs-tag">&lt;/<span class="hljs-name">string</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">string</span>&gt;</span>--backend<span class="hljs-tag">&lt;/<span class="hljs-name">string</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">string</span>&gt;</span>portaudio<span class="hljs-tag">&lt;/<span class="hljs-name">string</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">array</span>&gt;</span>
</code></pre>
<p>Add the following to the array after <code>&lt;string&gt;portaudio&lt;/string&gt;</code>:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">string</span>&gt;</span>--on-song-change-hook<span class="hljs-tag">&lt;/<span class="hljs-name">string</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">string</span>&gt;</span>/path/to/spt_status.sh --update<span class="hljs-tag">&lt;/<span class="hljs-name">string</span>&gt;</span>
</code></pre>
<p>Note that this needs to be the full path to our script.</p>
<p>For Linux users, you can create a systemd service file to launch the daemon. Create a file named <code>spotifyd.service</code> in <code>~/.config/systemd/user/</code> with the following content:</p>
<pre><code class="lang-ini"><span class="hljs-section">[Unit]</span>
<span class="hljs-attr">Description</span>=Spotifyd Daemon

<span class="hljs-section">[Service]</span>
<span class="hljs-attr">ExecStart</span>=/usr/bin/spotifyd --<span class="hljs-literal">no</span>-daemon --backend alsa --<span class="hljs-literal">on</span>-song-change-hook <span class="hljs-string">"/path/to/spt_status.sh --update"</span>
<span class="hljs-attr">Restart</span>=always
<span class="hljs-attr">RestartSec</span>=<span class="hljs-number">12</span>

<span class="hljs-section">[Install]</span>
<span class="hljs-attr">WantedBy</span>=default.target
</code></pre>
<p>Replace <code>/path/to/spt_status.sh</code> with the full path to the script you created earlier.</p>
<h2 id="heading-launching-the-daemon">Launching the Daemon</h2>
<p>From here, we can launch our daemon:</p>
<p>For macOS users:</p>
<pre><code class="lang-bash">brew services start spotifyd
</code></pre>
<p>For Linux users:</p>
<pre><code class="lang-bash">systemctl --user <span class="hljs-built_in">enable</span> --now spotifyd.service
</code></pre>
<h2 id="heading-configuring-spotify-tui-and-tmux">Configuring spotify-tui and tmux</h2>
<p>We need to run <code>spt</code> one time to configure it, so do that now and follow the messages, entering your Spotify app’s client and secret tokens when prompted. Then press <code>d</code> and select <code>spotifyd</code> from the devices list. If it’s not showing up in the list of available devices, you might need to open the official app and select “spotifyd” as your playback device. You can then close the Spotify app.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1687251734845/9ef08a0b-ffb0-42a5-98db-223c8090b731.png" alt="select the spotifyd device in the official spotify app" class="image--center mx-auto" /></p>
<p>We’re almost there, I promise. All that’s left is to open up your tmux config (probably at ~/.tmux.conf) and make a couple of small tweaks:</p>
<pre><code class="lang-bash"><span class="hljs-comment"># .tmux.conf</span>

<span class="hljs-comment"># ...rest of file</span>

<span class="hljs-comment"># update the status bar every second</span>
<span class="hljs-built_in">set</span> -g status-interval 1

<span class="hljs-comment"># show our widget</span>
<span class="hljs-built_in">set</span> -g status-right <span class="hljs-string">' #(spt_status.sh)'</span>

<span class="hljs-comment"># ...rest of file</span>
</code></pre>
<h2 id="heading-wrapping-up">Wrapping Up</h2>
<p>Whew! We did it. If you have any open tmux sessions, exit them with <code>tmux kill-server</code> and start up a new one. Play a song with either the official app or with spotify-tui, and you should see our new widget on the right.</p>
<p>If you liked this, let me know in the comments and give me a follow! Also, don’t hesitate to let me know if something isn’t working or if I overlooked anything.</p>
<p>I'm also on Twitter <a target="_blank" href="https://twitter.com/techsavvytravvy">@techsavvytravvy</a> and sometimes I <a target="_blank" href="https://twitch.tv/techsavvytravvy">stream on Twitch</a> - come hang out!</p>
<p>Bye!</p>
]]></content:encoded></item><item><title><![CDATA[Transitioning to a Full-Time Job as a Developer]]></title><description><![CDATA[I've been freelancing as a developer for the last 5 years, but recently I landed a job at a company I've always wanted to work at. As a lifelong musician, it's always been my goal to work in that industry, and I simply couldn't turn down the offer. M...]]></description><link>https://blog.techsavvytravvy.com/transitioning-to-a-full-time-job-as-a-developer</link><guid isPermaLink="true">https://blog.techsavvytravvy.com/transitioning-to-a-full-time-job-as-a-developer</guid><category><![CDATA[General Programming]]></category><category><![CDATA[jobs]]></category><category><![CDATA[job search]]></category><category><![CDATA[Career]]></category><dc:creator><![CDATA[trav]]></dc:creator><pubDate>Tue, 11 Oct 2022 11:28:14 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1665486854875/_bRti0MCp.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I've been freelancing as a developer for the last 5 years, but recently I landed a job at a company I've always wanted to work at. As a lifelong musician, it's always been my goal to work in that industry, and I simply couldn't turn down the offer. Making the decision to take the plunge and go full-time was a scary but ultimately very rewarding one. If you're thinking of making the transition from freelancing to a full-time job, here are a few things to keep in mind.</p>
<h2 id="heading-why-a-full-time-job">Why a Full-Time Job?</h2>
<p>There are a lot of reasons why you might want to make the switch from freelancing to a full-time job. Maybe you're tired of the unstable income, or the constant hustle to find new clients. Maybe you're ready for benefits and a regular paycheck. Or maybe you're just ready for a change of pace.</p>
<p>There are a few things to consider before making the switch. First, let's look at the pros and cons of a full-time job.</p>
<h3 id="heading-pros-and-cons">Pros and Cons</h3>
<p>There are some obvious advantages to a full-time job:</p>
<ul>
<li><p>Regular income: You'll know how much you're going to be paid, and when you're going to be paid, which can be a huge relief after the uncertainty of freelancing.</p>
</li>
<li><p>Benefits: Health insurance, vacation days, 401k matching, and other benefits can be extremely valuable, especially if you have a family.</p>
</li>
<li><p>Stability: A full-time job offers a lot more stability than freelancing, both in terms of income and workload.</p>
</li>
<li><p>Opportunities for growth: A full-time job will give you the opportunity to work with a team, learn new skills, and advance in your career.</p>
</li>
</ul>
<p>Of course, there are also some disadvantages to consider:</p>
<ul>
<li><p>Less flexibility: You'll have to work set hours, and may have less control over your workload and projects.</p>
</li>
<li><p>Less freedom: You may have to dress a certain way, or adhere to other rules and regulations that you didn't have to worry about as a freelancer.</p>
</li>
<li><p>Less independence: You'll be working for someone else, and will have to answer to a boss.</p>
</li>
</ul>
<p>Overall, there are a lot of factors to consider before making the switch from freelancing to a full-time job. It's important to weigh the pros and cons and decide what's right for you.</p>
<h2 id="heading-the-job-market-for-programmers">The Job Market for Programmers</h2>
<p>If you've decided that a full-time job is the right move for you, the next step is to start looking for positions. The job market for programmers is very competitive, so it's important to take the time to find the right position.</p>
<h3 id="heading-choosing-the-right-position">Choosing the Right Position</h3>
<p>When you're looking for a programming position, it's important to consider your skills and experience. Do you want to work in a specific language or framework? Do you want to work in a specific industry? Do you want to work on a particular type of project?</p>
<p>It's also important to consider the company you want to work for. Do you want to work for a big company or a small startup? Do you want to work in a corporate environment, or a more relaxed atmosphere? Do you want to work remotely, or in an office?</p>
<p>There are a lot of factors to consider when choosing the right position. It's important to take the time to find a position that's a good fit for you.</p>
<h3 id="heading-interviewing-and-code-tests">Interviewing and Code Tests</h3>
<p>Once you've found a few positions that you're interested in, it's time to start applying. The interview process for programming positions can be very competitive. Many companies require a code test as part of the interview process.</p>
<p>If you're not familiar with code tests, they are basically a way for companies to assess your skills. They usually involve solving a problem or writing code to complete a task. Code tests can be very difficult, so it's important to practice before you take one.</p>
<p>There are a few resources that can help you prepare for a code test:</p>
<ul>
<li><p>LeetCode: The gold standard for interview code questions. There is a wide range of programming challenges, as well as articles and tutorials on various programming topics.</p>
</li>
<li><p>CodeWars: Similar to LeetCode, they offer a somewhat more fun platform with many code challenges.</p>
</li>
<li><p>HackerRank: Another site with challenges to help you prepare for a code test.</p>
</li>
</ul>
<p>Practicing for a code test is a great way to prepare for the interview process. It's also a good way to assess your skills and see if you're ready for a full-time job. Just be aware that you don't necessarily need to be a master of algorithms to get the job you want, and the actual test might end up being a more practical application of your skills.</p>
<h2 id="heading-how-to-make-the-transition">How to Make the Transition</h2>
<p>Making the transition from freelancing to a full-time job can be a big change. Here are a few tips to help you make the transition:</p>
<ul>
<li><p>Start looking for positions early: The sooner you start looking, the better. It can take a while to find the right position, so it's important to start early.</p>
</li>
<li><p>Keep your options open: Don't limit yourself to one type of position or company. The more options you have, the better.</p>
</li>
<li><p>Be prepared for the interview process: Practice for code tests and interviews. The more prepared you are, the better.</p>
</li>
<li><p>Be patient: The process can take some time, so it's important to keep your eyes on the prize.</p>
</li>
</ul>
<p>Making the transition from freelancing to a full-time job can be a big change, but it's definitely doable. If you're thinking of making the switch, I hope this article helped you.</p>
<h2 id="heading-the-bottom-line">The Bottom Line</h2>
<p>Making the switch from freelancing to a full-time job is a big decision. There are a lot of factors to consider, and the process can be competitive. But if you're ready for a change, a full-time job can be a great opportunity.</p>
<p>Which do you prefer: a full-time job or freelancing? Let me know in the comments!</p>
<p>Be sure to follow me for more like this.</p>
]]></content:encoded></item><item><title><![CDATA[The Pros and Cons of Python]]></title><description><![CDATA[Python has been around for a while now, and it's not going anywhere anytime soon. It's a popular language for a reason: it's easy to learn, it's "batteries included," and it's free and open-source. But Python also has its drawbacks. It's slower than ...]]></description><link>https://blog.techsavvytravvy.com/the-pros-and-cons-of-python</link><guid isPermaLink="true">https://blog.techsavvytravvy.com/the-pros-and-cons-of-python</guid><category><![CDATA[Python]]></category><category><![CDATA[Beginner Developers]]></category><category><![CDATA[languages]]></category><dc:creator><![CDATA[trav]]></dc:creator><pubDate>Mon, 22 Aug 2022 09:01:03 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1661158810590/n0OonjcBW.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Python has been around for a while now, and it's not going anywhere anytime soon. It's a popular language for a reason: it's easy to learn, it's "batteries included," and it's free and open-source. But Python also has its drawbacks. It's slower than compiled languages, and not statically typed. It's also not good for mobile development. Testing can also be a pain. But enough about the downsides, let's dive into the Pros!</p>
<h2 id="heading-pros">Pros</h2>
<h3 id="heading-popular">Popular</h3>
<p>Python is one of the most popular programming languages in the world. It's used by major companies like Google, Facebook, Instagram, Netflix, and Dropbox. If you're looking for a language with a large community and good job prospects, Python is a good choice.</p>
<p>Being popular also means that there is a large community of developers who can help you if you get stuck, and it also means that there are many libraries and frameworks available to help you with your development.</p>
<h3 id="heading-batteries-included">Batteries Included</h3>
<p>Python comes with a lot of standard library modules that provide functionality that would otherwise need to be provided by third-party libraries. This means that you don't have to worry about installing extra libraries when you're starting a new project, and it also means that you have more options available to you out of the box.</p>
<p>Need to parse JSON? There's a module for that. Want to do some complex math? There's a module for that, too. Python's "batteries included" approach saves you time and effort.</p>
<h3 id="heading-easy-to-learn">Easy to Learn</h3>
<p>Python is considered a beginner-friendly language. Its syntax is clean and straightforward. And there's a lot of documentation and resources available to help you learn. If you're just starting out, Python is a good language to learn.</p>
<h3 id="heading-free-and-open-source">Free and Open-Source</h3>
<p>Python is free to use. You can download it from the Python website and use it without paying a licensing fee. And Python is open-source, which means its source code is available for anyone to view and contribute to.</p>
<h3 id="heading-portable">Portable</h3>
<p>Python is a portable language. This means you can run Python programs on any platform that supports Python, including Windows, Mac, Linux, and Raspberry Pi. This makes Python a good choice for cross-platform development.</p>
<h3 id="heading-interpreted">Interpreted</h3>
<p>Python is an interpreted language. This means that Python programs are executed by an interpreter, not by a compiler. Interpreted languages are usually easier to debug because you can see what's happening as the program is running.</p>
<h2 id="heading-cons">Cons</h2>
<h3 id="heading-slow">Slow</h3>
<p>Compared to compiled languages, Python is considered slow. It's not suitable for tasks that need to be completed quickly, such as real-time video processing or games. If speed is important, you should look for a language that's faster, such as C++ or Rust.</p>
<h3 id="heading-interpreted">Interpreted</h3>
<p>Because Python is interpreted, it's not suitable for tasks that require a lot of processing power. If you need to do something that's computationally intensive, like machine learning or data analysis, you'll be better off with a language like C++.</p>
<h3 id="heading-not-statically-typed">Not statically typed</h3>
<p>Python is not a statically typed language. This means that you don't have to declare the types of variables before using them. This can make Python code less reliable, because it's easy to make mistakes that go undetected.</p>
<h3 id="heading-not-good-for-mobile">Not good for mobile</h3>
<p>Python is not a good choice for mobile development. If you want to develop apps for Android or iOS, you should use a language like Java or Swift.</p>
<h3 id="heading-hard-to-test">Hard to test</h3>
<p>Python code can be hard to test. This is because Python is interpreted, and because it's not statically typed. It can be difficult to catch all the potential errors in Python code.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Python is a popular, versatile language that's easy to learn. But it has its drawbacks. It's slower, interpreted, and not great for mobile app development. Testing can also be a challenge. If you're looking for a language that's easy to use and has a large community, Python is a good choice. But if you need a language that's optimized for speed, you might look elsewhere.</p>
]]></content:encoded></item><item><title><![CDATA[Take Care of That Beautiful Brain!]]></title><description><![CDATA[Whether you go by “developer”, “programmer”, or “engineer”, a career in tech is a mentally demanding pursuit. You are constantly problem solving, learning new things, and working on complex projects. It is important to take care of your mental health...]]></description><link>https://blog.techsavvytravvy.com/take-care-of-that-beautiful-brain</link><guid isPermaLink="true">https://blog.techsavvytravvy.com/take-care-of-that-beautiful-brain</guid><category><![CDATA[General Programming]]></category><category><![CDATA[Programming Tips]]></category><category><![CDATA[Mental Health]]></category><category><![CDATA[technology]]></category><category><![CDATA[community]]></category><dc:creator><![CDATA[trav]]></dc:creator><pubDate>Sun, 14 Aug 2022 05:55:47 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1660456116112/FSuIkB3T3.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Whether you go by “developer”, “programmer”, or “engineer”, a career in tech is a mentally demanding pursuit. You are constantly problem solving, learning new things, and working on complex projects. It is important to take care of your mental health in this industry, or you will quickly become overwhelmed and burned out.</p>
<h2 id="heading-the-importance-of-mental-health">The Importance of Mental Health</h2>
<p>Developers are often seen as independent and strong-willed people who don't need help. While this is sometimes true, we have to remember that we are, in fact, human. Everyone struggles, and everyone needs help sometimes.</p>
<p>Mental health is just as important for developers as it is for anyone else. In fact, it is arguably more important because of the demands of the job. </p>
<p>Programming requires you to be able to focus for long periods of time, handle stress, and deal with difficult challenges. If your mental health is not in good shape, you will quickly become overwhelmed and will not be able to perform at your best.</p>
<h2 id="heading-the-stigma-around-mental-health-in-tech">The Stigma Around Mental Health in Tech</h2>
<p><em>“Mental health problems? No way, not me! I just grind 80 hours a week and get paid.”</em></p>
<p>Mental health is still seen as a taboo topic, and developers are especially reluctant to talk about it. We're supposed to be the smart ones, the successful ones. We're not supposed to have problems with our brains.</p>
<p>Mental health problems are often seen as a weakness, and people who suffer from these issues worry they'll be viewed as less capable. This is especially true in the tech community, where people are expected to be able to work long hours and handle difficult challenges.</p>
<p>This stigma is one of the reasons why so many developers don't seek help when they are struggling. Many people fear that they will be seen as weak or less capable if they admit that they are having difficulties. This is a dangerous way of thinking, and it is far removed from the truth.</p>
<h2 id="heading-the-reality-of-mental-health-in-the-community">The Reality of Mental Health in the Community</h2>
<p>The reality of mental health in the tech community is that it is a very real and very serious issue that most people experience. Developers are just as susceptible to mental health issues as anyone else. In fact, due to the nature of the job, programmers are actually at a higher risk for developing mental health issues. One study showed that around <a target="_blank" href="https://pubmed.ncbi.nlm.nih.gov/1974658/">62% of developers had problems with their mental health</a> at some point in their career!</p>
<p>The most common mental health issues among programmers are anxiety, depression, and general stress. These are all very serious problems that can have a major impact on your ability to do your job. If you are struggling with any of these issues, it is important to seek help from a professional before the situation gets worse.</p>
<h2 id="heading-the-consequences-of-neglecting-mental-health">The Consequences of Neglecting Mental Health</h2>
<p>As a developer, you're probably used to neglecting your mental health. After all, there's always another line of code to write, another bug to fix, or another feature to add. Who has time to worry about their mental health when there's work to be done?</p>
<p>Unfortunately, neglecting your mental health can have some serious consequences. For example, you might find yourself struggling to concentrate, feeling irritable or anxious, or experiencing depression.</p>
<p>You might be ignoring your well-being because of work, but it’s eventually going to make you less productive. If you are struggling with mental health issues, you will not be able to focus or be the <a target="_blank" href="https://www.simplethread.com/the-10x-programmer-myth/">10x developer</a> you set out to be. Burnout can lead to errors in your code, missed deadlines, and a general decline in the quality of your work.</p>
<p>It can also lead to isolation. When you are struggling with mental health issues, it is easy to withdraw from social activities and become isolated. This isolation can make your mental health problems worse, and it make it more difficult to get help when you need it.</p>
<h2 id="heading-how-to-take-care-of-your-mental-health">How to Take Care of Your Mental Health</h2>
<p>I would like to preface this section by saying that I am a developer, not a psychologist, and there are plenty of people much more qualified than me to speak on this topic.</p>
<p>That said, there are some obvious things that you can do to take care of your mental health as a developer, and sometimes we all need a reminder of the basics:</p>
<ul>
<li><p><strong>Get enough sleep</strong></p>
<p>  This may seem like an obvious one, but it's important to get enough sleep when you're a developer. Developers are known for being night-owls, but when you're sleep-deprived you're more likely to make mistakes and your productivity will suffer.</p>
</li>
<li><p><strong>Eat healthy</strong></p>
<p>  Just like your physical health, what you eat affects your mental health. Eating unhealthy food will make you feel sluggish and can lead to mental health issues such as anxiety and depression. So make sure to eat plenty of fruits, vegetables, and whole grains. The <em>All-Coffee Diet</em> just isn't going to cut it.</p>
</li>
<li><p><strong>Exercise</strong></p>
<p>  Working at a desk all day isn't great for anyone, even if it's a cool convertible standing desk. Exercise is not only good for your physical health, but it's also good for your mental health. It releases endorphins, which have mood-boosting effects. So make sure to get some exercise every day, even if it's just a brisk walk around the block.</p>
</li>
<li><p><strong>Take breaks</strong></p>
<p>  When you're feeling overwhelmed or stressed, take a break. Step away from your computer and take a few deep breaths. Or go for that walk we just talked about. Taking breaks will help you clear your head and come back to your work refreshed.</p>
</li>
<li><p><strong>Connect with other developers</strong></p>
<p>  It's important to connect with other developers, because they understand the challenges you're facing. Join an online community or attend meetups to meet other developers in your area. Talking to other developers can help you feel less alone and can give you helpful insights.</p>
</li>
<li><p><strong>Don’t be afraid to seek professional help</strong></p>
<p>  There is no shame in finding help from a therapist or counselor. In fact, getting professional help is one of the best things that you can do for your mental health and unfortunately, <a target="_blank" href="https://pubmed.ncbi.nlm.nih.gov/1974658/#:~:text=only%20one%20subject%20sought%20professional%20help%20from%20a%20psychiatrist%20for%20relief%20of%20mental%20complaints">only a small percentage of developers actually do it</a>.</p>
</li>
</ul>
<h2 id="heading-conclusion">Conclusion</h2>
<p>The importance of maintaining your mental health cannot be overstated. Whether you're a developer, programmer, or software engineer, it is important to be honest with yourself about how you are feeling and to seek help if you are struggling.</p>
<p>Don't forget, we're all in this together and nobody is better off ignoring their mental well-being. Take care of that big, beautiful brain and live to code another day!</p>
]]></content:encoded></item><item><title><![CDATA[Enough to Be Dangerous: The Command Line Interface]]></title><description><![CDATA[The command line is a text-based interface that lets you enter commands to perform various tasks. Think of it like a mini-programming language that you can use to control your computer. This guide will show you just enough about the command line inte...]]></description><link>https://blog.techsavvytravvy.com/the-command-line-interface</link><guid isPermaLink="true">https://blog.techsavvytravvy.com/the-command-line-interface</guid><category><![CDATA[cli]]></category><category><![CDATA[terminal]]></category><category><![CDATA[General Programming]]></category><category><![CDATA[Linux]]></category><category><![CDATA[basics]]></category><dc:creator><![CDATA[trav]]></dc:creator><pubDate>Sun, 07 Aug 2022 07:53:09 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1659858471974/SjwWLxmeP.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>The command line is a text-based interface that lets you enter commands to perform various tasks. Think of it like a mini-programming language that you can use to control your computer. This guide will show you just enough about the command line interface (CLI) to be dangerous.</p>
<p><em>* The command line interface may differ slightly for various operating systems, but for the most part everything covered in this article should work on all of them.</em></p>
<h2 id="heading-why-do-i-need-the-command-line">Why do I need the command line?</h2>
<p>There are many reasons you might want to learn and use the command line interface, but it's especially important if one of these describes you:</p>
<ol>
<li><p>You're a programmer who needs to work with code or other text-based files on a regular basis</p>
</li>
<li><p>You want to do something that can't be done with a GUI, or would be very time consuming</p>
</li>
<li><p>You're a sysadmin who needs to automate tasks or manage hundreds of servers from the command line</p>
</li>
<li><p>You're a power user who wants to be able to customize your system to do exactly what you want it to do</p>
</li>
<li><p>You need to learn how to use the command line in order to pass a class or get a job.</p>
</li>
<li><p>You want to be an ethical hacker and you love the challenge of getting a computer to do what you want it to do by typing in arcane commands</p>
</li>
<li><p>You're a masochist who enjoys typing in commands instead of using a mouse</p>
</li>
</ol>
<p>Of course, this isn't an exhaustive list and if nothing else the CLI can actually be pretty fun to use and customize. Plus, everyone knows that using the CLI automatically makes you <code>L33T</code>.</p>
<h2 id="heading-common-use-cases">Common Use Cases</h2>
<p>The list of what you can do with the CLI is limited only by your imagination (and hardware), but these are some common uses:</p>
<ul>
<li>Create and delete files</li>
<li>Move, copy, and rename files</li>
<li>Search for text in files</li>
<li>Install and remove software</li>
<li>Connect to remote servers</li>
<li>Perform system administration tasks</li>
</ul>
<h2 id="heading-some-history">Some History</h2>
<p>The command line interface (CLI) is a text-based interface that allows users to interact with a computer using text commands. The CLI was first developed in the early 1970s, when computer users began to need a way to interact with the growing number of computer systems. The CLI was initially developed for use with the Unix operating system, but it has since been adapted for use with other operating systems, such as Microsoft Windows and Apple macOS.</p>
<p>The CLI is typically used by advanced users who are comfortable working with text-based commands. The CLI has a learning curve and is not always the easiest way to interact with a computer, so many users prefer to use a graphical user interface (GUI) instead. However, the CLI can be faster and more powerful than a GUI, so it is still used by many users who need to get work done quickly.</p>
<h2 id="heading-opening-a-terminal">Opening a Terminal</h2>
<p>To use the command line, you need to open a terminal. On Linux and Mac, this can be done by opening the "Terminal" application. On Windows, you can use the "Command Prompt" application.</p>
<p>On Linux, the Terminal applicationcan be opened by pressing the CTRL + ALT + T keys simultaneously.</p>
<p>On Mac, the command line interface can be opened by pressing the CMD + SPACE keys simultaneously and then typing "terminal" into the Spotlight search bar. The Terminal app can also be found in the Utilities folder inside Applications. </p>
<p>On Windows, the command line interface can be opened by pressing the Windows key + R keys simultaneously and then typing "cmd" into the Run dialog box.</p>
<h2 id="heading-navigating-the-filesystem">Navigating the Filesystem</h2>
<p>You can't do much if you don't know how to navigate the filesystem on your computer. To do this, you use the <code>cd</code> command to enter a folder. You can type an absolute path, a relative path, or prefix with <code>~/</code> to enter a folder relative to the home directory of the user:</p>
<pre><code class="lang-bash"><span class="hljs-comment"># absolute paths start with forward slash</span>
<span class="hljs-built_in">cd</span> /etc/

<span class="hljs-comment"># relative paths start with the folder name, or a period referring to the current directory</span>
<span class="hljs-built_in">cd</span> etc/
<span class="hljs-built_in">cd</span> ./etc/

<span class="hljs-comment"># paths relative from home start with a tilde</span>
<span class="hljs-built_in">cd</span> ~/Documents/
</code></pre>
<p><em>* Anything on a line after a <code>#</code> is ignored. These are used to add comments</em></p>
<p>You can also traverse into parent folders by using <code>..</code> to go up one directory:</p>
<pre><code class="lang-bash"><span class="hljs-comment"># go up one directory</span>
<span class="hljs-built_in">cd</span> ..

<span class="hljs-comment"># go up two directories, then into the folder named 'project'</span>
<span class="hljs-built_in">cd</span> ../../project
</code></pre>
<p>If you forget where you are, you can use the <code>pwd</code> to display the current directory.</p>
<p>To list files in the current directory, use the <code>ls</code> command:</p>
<pre><code>ls
</code></pre><p>Options are often added to commands to alter their behavior. These are usually passed with two hyphens and an option name, or a single hyphen and a letter for shorthand. In most cases they can be combined to further tailor the command.</p>
<p>Let's use options to recursively list files and folders or sort them by size:</p>
<pre><code class="lang-bash"><span class="hljs-comment"># list all files in the directory and its subfolders</span>
ls -R

<span class="hljs-comment"># list files sorted by size</span>
ls -S
</code></pre>
<p>If you want to list files in a specific directory, use the <code>ls</code> command followed by the absolute path (starting with <code>/</code> to the directory:</p>
<pre><code class="lang-bash">ls /etc/
</code></pre>
<p>If you're in an empty folder, there's probably not a lot to look at, so let's change that.</p>
<h2 id="heading-create-and-remove">Create and Remove</h2>
<p>To create a file, enter the folder where you want the file to live (you know how to do that, right?) and use the <code>touch</code> command, followed by the name of the file—be sure to include the extension!</p>
<pre><code class="lang-bash">touch test.txt
</code></pre>
<p>If you want it gone, remove it with <code>rm</code>:</p>
<pre><code class="lang-bash">rm test.txt
</code></pre>
<p>But what about folders? Just use the <code>mkdir</code> command to create a directory:</p>
<pre><code class="lang-bash">mkdir test-folder
</code></pre>
<p>To remove a folder, we'll use the <code>rm</code> command again, but with an important option passed to it:</p>
<pre><code class="lang-bash">rm -r test-folder
</code></pre>
<p>The <code>-r</code> options tell the command that we want to <code>r</code>ecursively remove a folder and all of its contents.</p>
<p>** Note: The <code>rm</code> command deletes files permanently and does not move them to Trash. Be careful!</p>
<p>Now that we have some files and folders, let's look at a how we can move them around.</p>
<h2 id="heading-moving-files-and-folders">Moving Files and Folders</h2>
<p>Let's move some things around using the <code>mv</code> command. We do this by targeting a source file or folder, and then adding a destination:</p>
<pre><code class="lang-bash"><span class="hljs-comment"># move a file inside a folder</span>
mv sourcefile.txt destination-folder/
</code></pre>
<p>There are few very important caveats when using <code>mv</code> to move a file or folder.</p>
<ol>
<li><p>When moving a <strong>file</strong> inside of a folder, the destination directory must already exist. If it doesn't then the file will be renamed instead. This can be mitigated by adding a trailing slash (<code>/</code>) to the destination folder name, in which case it will throw an error if it does not exist. It's generally a good practice to end directory names with a trailing forward slash to avoid confusion.</p>
</li>
<li><p>By default, if a file already exists with the same name inside the destination folder, it will be overwritten without prompting you. I recommend overriding this by using the "interactive" option  <code>-i</code>, which will ask when a file would be overwritten.</p>
</li>
</ol>
<p>Knowing how <code>mv</code> behaves is important, since we'll be using the same command to rename files:</p>
<pre><code class="lang-bash"><span class="hljs-comment"># rename the "original.txt" file to "updated.txt"</span>
mv original.txt updated.txt
</code></pre>
<p>You can also change the filename and move it inside a folder, all in one command!</p>
<pre><code class="lang-bash">mv original.txt destination-folder/updated.txt
</code></pre>
<p>Now we can move and rename our files, but what if we want to duplicate them?</p>
<h2 id="heading-copy">Copy</h2>
<p>The <code>cp</code> command is short and sweet, just add the file or files that you want to copy, and the directory that you want it to be copied into. If you want to copy a file into the same directory, include the new name of the duplicated file.</p>
<p>For example:</p>
<pre><code class="lang-bash"><span class="hljs-comment"># copy a file into a directory</span>
cp test.txt myfolder/

<span class="hljs-comment"># copy multiple files into a directory</span>
cp test1.txt test2.txt myfolder/

<span class="hljs-comment"># copy a file into the same directory</span>
cp original.txt duplicate.txt
</code></pre>
<h2 id="heading-clear">Clear</h2>
<p>Let's wrap up with a nice and easy one. The <code>clear</code> command does exactly what it says: it clears the console and gives you a clean slate if things get a bit  too cluttered.</p>
<pre><code class="lang-bash">clear
</code></pre>
<p>Done and done.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Of course, this just scratches the surface of what can be done in the terminal. There are plenty of resources around if you want to learn more, like <a target="_blank" href="https://www.hostinger.com/tutorials/linux-commands">this article by Artūras B on Hostinger</a> or the <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Learn/Tools_and_testing/Understanding_client-side_tools/Command_line">Command Line Crash Course on MDN</a>.</p>
<p>The command line interface is a powerful and versatile tool that can be used to perform a wide variety of tasks on a computer. With a little practice, you can use the CLI to do everything from managing files and folders to installing software and performing system administration. It can be daunting at first, but once you get the hang of it, you'll wonder how you ever lived without it.</p>
<p>Next time, we'll look at some more exciting features of the command line interface like piping, the superuser, permissions, personalization, and more!</p>
<p>Let me know in the comments if this was helpful or if you have any questions.</p>
<p>Be sure to follow me for more like this!</p>
]]></content:encoded></item><item><title><![CDATA[Make a Synthesizer With Tone.js]]></title><description><![CDATA[This is the first part of the series "Make Music With Tone.js."
Maybe you want to make music, but you don't want to spend money on a DAW or expensive equipment. Or maybe you're just too lazy to learn an instrument. Either way, I have the perfect solu...]]></description><link>https://blog.techsavvytravvy.com/make-a-synthesizer-with-tonejs</link><guid isPermaLink="true">https://blog.techsavvytravvy.com/make-a-synthesizer-with-tonejs</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[HTML5]]></category><category><![CDATA[CSS]]></category><category><![CDATA[music]]></category><category><![CDATA[General Programming]]></category><dc:creator><![CDATA[trav]]></dc:creator><pubDate>Mon, 01 Aug 2022 14:22:22 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1659363196371/Lsoou6BPg.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>This is the first part of the series "<a target="_blank" href="https://tawdev.hashnode.dev/series/tone-js">Make Music With Tone.js</a>."</p>
<p>Maybe you want to make music, but you don't want to spend money on a DAW or expensive equipment. Or maybe you're just too lazy to learn an instrument. Either way, I have the perfect solution for you: create a playable synthesizer using Tone.js! For this short guide, all you'll need is basic knowledge of HTML, CSS, and JavaScript.</p>
<h2 id="heading-what-is-tonejs">What Is Tone.js?</h2>
<p>Tone.js is a JavaScript library for creating interactive music in the browser. With Tone.js, you can create sound files and play them back, create synthesizers and samplers, and much more. You can even use Tone.js to create entire songs! For our purposes, we'll just be using it to create a simple synthesizer that we can play with our mouse or keyboard.</p>
<h2 id="heading-create-a-project">Create a Project</h2>
<p>First, we need to create a new project. We'll do this by creating a new folder on our computer and giving it a name. I'm going to call mine "tone-synth". Inside this folder, we'll create three new files: index.html, style.css, and script.js. These are the files that we'll be working with in this tutorial.</p>
<h2 id="heading-make-the-synth">Make the Synth</h2>
<p>Let's get to work making each part of a simple monophonic synth. We'll want to make a nice piano UI in HTML, style it with CSS, then make it play notes when we click each piano key as well as map each note to the keyboard.</p>
<h3 id="heading-html">HTML</h3>
<p>First, we'll create our HTML and add links to the stylesheet as well as the . We'll start with a simple structure that looks like this:</p>
<pre><code class="lang-html"><span class="hljs-meta">&lt;!DOCTYPE <span class="hljs-meta-keyword">html</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">html</span> <span class="hljs-attr">lang</span>=<span class="hljs-string">"en"</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">charset</span>=<span class="hljs-string">"UTF-8"</span> /&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"viewport"</span> <span class="hljs-attr">content</span>=<span class="hljs-string">"width=device-width, initial-scale=1.0"</span> /&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>Vite App<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">link</span> <span class="hljs-attr">rel</span>=<span class="hljs-string">"stylesheet"</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"style.css"</span> /&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span>
  <span class="hljs-comment">&lt;!-- our piano will go here --&gt;</span>

  <span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://cdn.jsdelivr.net/npm/tone@14.7.77/build/Tone.min.js"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"main.js"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span>

<span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span>
</code></pre>
<p>Now, let's add the HTML for our piano keys. We'll use a simple structure of <code>&lt;div&gt;</code>s with each representing a key, and give it a class to target in CSS. We'll also give each key a <code>data-note</code> value to tell Tone.js what note to play, as well as a <code>data-key</code> to map it to the QWERTY keyboard.</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"piano"</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"key white"</span> <span class="hljs-attr">data-note</span>=<span class="hljs-string">"C3"</span> <span class="hljs-attr">data-key</span>=<span class="hljs-string">"a"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"key black"</span> <span class="hljs-attr">data-note</span>=<span class="hljs-string">"C#3"</span> <span class="hljs-attr">data-key</span>=<span class="hljs-string">"w"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"key white"</span> <span class="hljs-attr">data-note</span>=<span class="hljs-string">"D3"</span> <span class="hljs-attr">data-key</span>=<span class="hljs-string">"s"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"key black"</span> <span class="hljs-attr">data-note</span>=<span class="hljs-string">"D#3"</span> <span class="hljs-attr">data-key</span>=<span class="hljs-string">"e"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"key white"</span> <span class="hljs-attr">data-note</span>=<span class="hljs-string">"E3"</span> <span class="hljs-attr">data-key</span>=<span class="hljs-string">"d"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"key white"</span> <span class="hljs-attr">data-note</span>=<span class="hljs-string">"F3"</span> <span class="hljs-attr">data-key</span>=<span class="hljs-string">"f"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"key black"</span> <span class="hljs-attr">data-note</span>=<span class="hljs-string">"F#3"</span> <span class="hljs-attr">data-key</span>=<span class="hljs-string">"t"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"key white"</span> <span class="hljs-attr">data-note</span>=<span class="hljs-string">"G3"</span> <span class="hljs-attr">data-key</span>=<span class="hljs-string">"g"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"key black"</span> <span class="hljs-attr">data-note</span>=<span class="hljs-string">"G#3"</span> <span class="hljs-attr">data-key</span>=<span class="hljs-string">"y"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"key white"</span> <span class="hljs-attr">data-note</span>=<span class="hljs-string">"A3"</span> <span class="hljs-attr">data-key</span>=<span class="hljs-string">"h"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"key black"</span> <span class="hljs-attr">data-note</span>=<span class="hljs-string">"A#3"</span> <span class="hljs-attr">data-key</span>=<span class="hljs-string">"u"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"key white"</span> <span class="hljs-attr">data-note</span>=<span class="hljs-string">"B3"</span> <span class="hljs-attr">data-key</span>=<span class="hljs-string">"j"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"key white"</span> <span class="hljs-attr">data-note</span>=<span class="hljs-string">"C4"</span> <span class="hljs-attr">data-key</span>=<span class="hljs-string">"k"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"key black"</span> <span class="hljs-attr">data-note</span>=<span class="hljs-string">"C#4"</span> <span class="hljs-attr">data-key</span>=<span class="hljs-string">"o"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"key white"</span> <span class="hljs-attr">data-note</span>=<span class="hljs-string">"D4"</span> <span class="hljs-attr">data-key</span>=<span class="hljs-string">"l"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"key black"</span> <span class="hljs-attr">data-note</span>=<span class="hljs-string">"D#4"</span> <span class="hljs-attr">data-key</span>=<span class="hljs-string">"p"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"key white"</span> <span class="hljs-attr">data-note</span>=<span class="hljs-string">"E4"</span> <span class="hljs-attr">data-key</span>=<span class="hljs-string">";"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"key white"</span> <span class="hljs-attr">data-note</span>=<span class="hljs-string">"F4"</span> <span class="hljs-attr">data-key</span>=<span class="hljs-string">"'"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<p>That's it for our HTML! Now let's move on to CSS.</p>
<h3 id="heading-css">CSS</h3>
<p>Our CSS is fairly simple but results in a nice looking piano. We'll start by setting some globals and styling the  piano:</p>
<pre><code class="lang-css">*,
*<span class="hljs-selector-pseudo">::before</span>,
*<span class="hljs-selector-pseudo">::after</span> {
  <span class="hljs-attribute">box-sizing</span>: inherit;
}

<span class="hljs-selector-tag">html</span>,
<span class="hljs-selector-tag">body</span> {
  <span class="hljs-attribute">box-sizing</span>: border-box;
}

<span class="hljs-selector-tag">body</span> {
  <span class="hljs-attribute">margin</span>: <span class="hljs-number">0</span>;
  <span class="hljs-attribute">display</span>: flex;
  <span class="hljs-attribute">justify-content</span>: center;
  <span class="hljs-attribute">align-items</span>: center;
  <span class="hljs-attribute">width</span>: <span class="hljs-number">100%</span>;
  <span class="hljs-attribute">min-height</span>: <span class="hljs-number">100vh</span>;
  <span class="hljs-attribute">background-color</span>: <span class="hljs-number">#282938</span>;
}

<span class="hljs-selector-class">.piano</span> {
  <span class="hljs-attribute">display</span>: flex;
  <span class="hljs-attribute">position</span>: relative;
  <span class="hljs-attribute">padding</span>: <span class="hljs-number">40px</span>;
  <span class="hljs-attribute">padding-bottom</span>: <span class="hljs-number">0</span>;
  <span class="hljs-attribute">background-color</span>: <span class="hljs-number">#341304</span>;
  <span class="hljs-attribute">border</span>: <span class="hljs-number">1px</span> solid <span class="hljs-number">#160801</span>;
  <span class="hljs-attribute">border-radius</span>: <span class="hljs-number">16px</span>;
  <span class="hljs-attribute">user-select</span>: none;
}
</code></pre>
<p>We want our piano keys to look like, well, piano keys! To do this, we'll give the keys a width and height, then offset the black keys' margin. Then, set their background color and change it when a key is active.</p>
<p>Our CSS for that will look like this:</p>
<pre><code class="lang-css"><span class="hljs-selector-class">.key</span> {
  <span class="hljs-attribute">width</span>: <span class="hljs-number">75px</span>;
  <span class="hljs-attribute">height</span>: <span class="hljs-number">350px</span>;
  <span class="hljs-attribute">border</span>: <span class="hljs-number">2px</span> outset <span class="hljs-number">#dddddd</span>;
  <span class="hljs-attribute">border-radius</span>: <span class="hljs-number">0</span> <span class="hljs-number">0</span> <span class="hljs-number">6px</span> <span class="hljs-number">6px</span>;
  <span class="hljs-attribute">background</span>: white;
  <span class="hljs-attribute">margin-bottom</span>: -<span class="hljs-number">8px</span>;
}

<span class="hljs-selector-class">.key</span><span class="hljs-selector-class">.black</span> {
  <span class="hljs-attribute">z-index</span>: <span class="hljs-number">1</span>;
  <span class="hljs-attribute">height</span>: <span class="hljs-number">225px</span>;
  <span class="hljs-attribute">margin-left</span>: -<span class="hljs-number">24px</span>;
  <span class="hljs-attribute">margin-right</span>: -<span class="hljs-number">24px</span>;
  <span class="hljs-attribute">width</span>: <span class="hljs-number">50px</span>;
  <span class="hljs-attribute">border-color</span>: <span class="hljs-number">#5f5f5f</span>;
  <span class="hljs-attribute">background-color</span>: <span class="hljs-number">#222</span>;
}

<span class="hljs-selector-class">.key</span><span class="hljs-selector-class">.white</span><span class="hljs-selector-class">.active</span> {
  <span class="hljs-attribute">background-color</span>: <span class="hljs-number">#ddd</span>
}

<span class="hljs-selector-class">.key</span><span class="hljs-selector-class">.black</span><span class="hljs-selector-class">.active</span> {
  <span class="hljs-attribute">background-color</span>: <span class="hljs-number">#000</span>
}

<span class="hljs-selector-class">.key</span><span class="hljs-selector-class">.white</span> + <span class="hljs-selector-class">.key</span><span class="hljs-selector-class">.white</span> {
  <span class="hljs-attribute">margin-left</span>: <span class="hljs-number">2px</span>;
}
</code></pre>
<p>Here's what it should look like:
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1659331416531/O6W_3_yS0.png" alt="html and css piano" /></p>
<p>Lookin' good. Let's move on to the JavaScript portion of our project.</p>
<h2 id="heading-javascript">JavaScript</h2>
<p>The <code>main.js</code> file is where we'll put all of our code that makes our synth actually work. Let's start by initializing a Tone.js <code>Synth</code> and creating an array from our piano key elements that we can access later:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> synth = <span class="hljs-keyword">new</span> Tone.Synth().toDestination();
<span class="hljs-keyword">const</span> keys = <span class="hljs-built_in">Array</span>.from(<span class="hljs-built_in">document</span>.querySelectorAll(<span class="hljs-string">'.key'</span>));
</code></pre>
<p>Now let's add an event listener so our keys make a sound when we click them. We can do this by creating a <code>'mousedown'</code> event on <code>document</code>, checking if the event target element contains the class <code>'key'</code>, then triggering an attack with Tone.js. We'll also want to add the <code>'active'</code> class to the element so that we have a visual indicator:</p>
<pre><code class="lang-javascript"><span class="hljs-built_in">document</span>.addEventListener(<span class="hljs-string">'mousedown'</span>, <span class="hljs-function">(<span class="hljs-params">e</span>) =&gt;</span> {
  <span class="hljs-keyword">if</span> (!e.target.classList.contains(<span class="hljs-string">'key'</span>)) {
    <span class="hljs-keyword">return</span>;
  }
  synth.triggerAttack(e.target.dataset.note);
  e.target.classList.add(<span class="hljs-string">'active'</span>);
});
</code></pre>
<p>We don't want our note to play forever, so let's create a <code>'mouseup'</code> event listener, where we remove the <code>'active'</code> class from all keys and trigger a release:</p>
<pre><code class="lang-javascript"><span class="hljs-built_in">document</span>.addEventListener(<span class="hljs-string">'mouseup'</span>, <span class="hljs-function">() =&gt;</span> {
  keys.forEach(<span class="hljs-function"><span class="hljs-params">key</span> =&gt;</span> key.classList.remove(<span class="hljs-string">'active'</span>));
  synth.triggerRelease();
});
</code></pre>
<p>That's it for our simple synth! You can test it out by opening <code>index.html</code> in your browser and clicking on each key. You should hear a different note being played back for each key you click on. But what if we want to be able to play our synth with our keyboard instead of just our mouse? Let's do that!</p>
<p>Since each key has a data attribute with its associated QWERTY key, we can create event listeners for <code>'keydown'</code> then find the element containing that data attribute in the <code>keys</code> array. For <code>'keyup'</code>, we'll do the same thing we did for <code>'mouseup'</code>.</p>
<pre><code class="lang-javascript"><span class="hljs-built_in">document</span>.addEventListener(<span class="hljs-string">'keydown'</span>, <span class="hljs-function">(<span class="hljs-params">e</span>) =&gt;</span> {
  <span class="hljs-keyword">const</span> key = keys.find(<span class="hljs-function"><span class="hljs-params">key</span> =&gt;</span> key.dataset.key === e.key);
  <span class="hljs-keyword">if</span> (!key) {
    <span class="hljs-keyword">return</span>;
  }
  key.classList.add(<span class="hljs-string">'active'</span>);
  synth.triggerAttack(key.dataset.note);
});

<span class="hljs-built_in">document</span>.addEventListener(<span class="hljs-string">'keyup'</span>, <span class="hljs-function">() =&gt;</span> {
  keys.forEach(<span class="hljs-function"><span class="hljs-params">key</span> =&gt;</span> key.classList.remove(<span class="hljs-string">'active'</span>));
  synth.triggerRelease();
});
</code></pre>
<p>Now you can play the notes with your keyboard!</p>
<h2 id="heading-test-it-out">Test It Out</h2>
<p>To test out your new synth, open <code>index.html</code> in your browser and try clicking on each key or pressing the corresponding letter on your keyboard. You should hear a different note being played back for each key you click or press.</p>
<p>Here's a working demo on CodePen:</p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://codepen.io/trvswgnr/pen/LYderra">https://codepen.io/trvswgnr/pen/LYderra</a></div>
<p>The GitHub repo can be found <a target="_blank" href="https://github.com/trvswgnr/tonejs-synth/tree/simple">here</a>.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>If everything sounds good, congratulations! You've just created your very first playable synthesizer with Tone.js!</p>
<p>Of course, this is just scratching the surface. In the next article, we'll dive deeper into Tone.js and expand our synth to be polyphonic, as well as add controls to change the sound, adjust levels, switch octaves, and add effects!</p>
<p>Let me know if this was helpful in the comments or if you have any questions.</p>
<p>Be sure to follow me for more like this!</p>
]]></content:encoded></item><item><title><![CDATA[Enough Already... Is HTML a Programming Language?]]></title><description><![CDATA[For reasons I can't quite comprehend, this question has spurred a 🔥heated🔥 debate on the internet for years: is HTML a programming language?
The discord on the topic seems to come back around every few years, so hopefully the following will help br...]]></description><link>https://blog.techsavvytravvy.com/enough-already-is-html-a-programming-language</link><guid isPermaLink="true">https://blog.techsavvytravvy.com/enough-already-is-html-a-programming-language</guid><category><![CDATA[HTML5]]></category><category><![CDATA[HTML]]></category><category><![CDATA[development]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[webdev]]></category><dc:creator><![CDATA[trav]]></dc:creator><pubDate>Fri, 29 Jul 2022 14:03:12 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1659103140785/SUoL9Ba0L.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>For reasons I can't quite comprehend, this question has spurred a 🔥<strong>heated</strong>🔥 debate on the internet for years: <em>is HTML a programming language?</em></p>
<p>The discord on the topic seems to come back around every few years, so hopefully the following will help bring some clarity to the shouting match.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1659101140914/E6l6nQOwL.gif" alt="beating a dead horse" /></p>
<h2 id="heading-understanding-html">Understanding HTML</h2>
<p>First, let's take a look at what HTML is and what it does.</p>
<p><a target="_blank" href="https://en.m.wikipedia.org/wiki/HTML">HyperText Markup Language</a>, abbreviated as HTML, is a markup language used for structuring web pages. HTML is made up of a series of elements, which are represented by tags.</p>
<p>For example, a paragraph element is denoted by the <code>&lt;p&gt;</code> tag, and a heading element is denoted by the <code>&lt;h1&gt;</code> tag.</p>
<p>You can also use HTML to add images, videos, and other multimedia content to your web page.</p>
<h2 id="heading-what-makes-a-programming-language">What Makes a Programming Language?</h2>
<p>To determine whether or not HTML is a programming language, we first need to understand what qualifies as a programming language.</p>
<p>Generally, a <a target="_blank" href="https://en.m.wikipedia.org/wiki/Programming_language">programming language</a> is a formal language that consists of a set of instructions that can be used to produce a desired output. These languages are used to create programs, which convert the instructions into machine code that can be understood by computers.</p>
<p>Based on this definition, we can say that a programming language must be able to create programs that produce a desired result.</p>
<h2 id="heading-so-does-it-qualify">So... Does It Qualify?</h2>
<p>The answer is... wait for it... <strong>no</strong>. HTML is simply not a programming language. You can not write programs in HTML. You can not actually compute anything with HTML. It just doesn't work that way.</p>
<p>HTML is a <strong>markup language</strong>. That means it's used for formatting and structure, not for logic or computational power. You can use HTML to format and create a layout for a website, but you can't use it to add any functionality.</p>
<p>HTML is not a set of instructions, it is simply a set of tags and data that comprise a document meant to present information.</p>
<p>As I mentioned before, HTML is a markup language. This means that it is used for structuring web pages. Without the ability to compute, HTML does not qualify as a programming language.</p>
<h2 id="heading-but">"But..."</h2>
<p>Some people might argue that HTML is just a different kind of programming language. While I understand that some consider it a <a target="_blank" href="https://en.m.wikipedia.org/wiki/Declarative_programming">declarative language</a>, these arguments just don't hold enough weight.</p>
<p>If you compare HTML to SQL, Wolfram, or <a target="_blank" href="https://en.m.wikipedia.org/wiki/List_of_programming_languages_by_type#Declarative_languages">any other declarative language</a>, it's pretty obvious which one is not like the others.</p>
<p>There isn't any logic in HTML and it is, for the most part, completely static—it's essentially a text document that can be parsed and processed by programming languages. </p>
<p>Just because something has a lot of features and tags doesn't make it a programming language.</p>
<h2 id="heading-examples">Examples</h2>
<p>Just to be clear, here are some examples of programming languages:</p>
<ul>
<li>C++</li>
<li>Rust</li>
<li>Java</li>
</ul>
<p>There are also scripting languages, which are slightly different because they are interpreted. That said, these could also be considered programming languages:</p>
<ul>
<li>JavaScript</li>
<li>Python</li>
<li>PHP</li>
</ul>
<p>And here are some example of a markup language:</p>
<ul>
<li>HTML</li>
<li>XML</li>
</ul>
<p>The primary difference here is structuring data vs computing it.</p>
<p>If you need more, check out this <a target="_blank" href="https://en.m.wikipedia.org/wiki/List_of_programming_languages_by_type">exhaustive list of programming languages</a>.</p>
<h2 id="heading-tldr">TL;DR</h2>
<p>HTML does not have a specific syntax for writing programs; it does not have a set of semantics for interpreting or compiling programs. Therefore, it is not a programming language.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Now, does that mean HTML is useless? Of course not! HTML is a great markup language. It's hard for me to take this stance on the subject because in no way do I support gatekeeping, and its status as a language doesn't make it less important. HTML is essential for creating websites. The fact that it's easy to learn and widely supported also makes it a great entry point for new developers.</p>
<p>The key takeaway is to know the purpose of the tools available to you and understand their capabilities.</p>
<p>Let me know in the comments where you stand on the matter.</p>
<p>Be sure to follow me for more like this!</p>
<h3 id="heading-further-reading">Further Reading</h3>
<ol>
<li><a target="_blank" href="https://ischool.syr.edu/why-html-is-not-a-programming-language/">Why HTML is Not a Programming Language</a></li>
<li><a target="_blank" href="https://www.geeksforgeeks.org/difference-between-programming-scripting-and-markup-languages/amp/">Difference Between Programming, Scripting, and Markup Languages</a></li>
<li><a target="_blank" href="https://mortoray.com/2019/02/11/of-course-html-is-a-programming-language/">Of course HTML is a programming language</a></li>
</ol>
]]></content:encoded></item><item><title><![CDATA[Please Start Writing Better Git Commits]]></title><description><![CDATA[I recently read a helpful article on Hashnode by Simon Egersand titled "Write Git Commit Messages Your Colleagues Will Love," and it inspired me to dive a little deeper into understanding what makes a Git commit good or bad.
You're probably thinking ...]]></description><link>https://blog.techsavvytravvy.com/please-start-writing-better-git-commits</link><guid isPermaLink="true">https://blog.techsavvytravvy.com/please-start-writing-better-git-commits</guid><category><![CDATA[Git]]></category><category><![CDATA[GitHub]]></category><category><![CDATA[Collaboration]]></category><category><![CDATA[documentation]]></category><category><![CDATA[General Programming]]></category><dc:creator><![CDATA[trav]]></dc:creator><pubDate>Fri, 29 Jul 2022 12:00:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1658903878041/gJRznhsCW.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I recently read a helpful article on Hashnode by <a target="_blank" href="https://hashnode.com/@prplcode">Simon Egersand</a> titled "<a target="_blank" href="https://prplcode.hashnode.dev/write-git-commit-messages-that-your-colleagues-will-love">Write Git Commit Messages Your Colleagues Will Love</a>," and it inspired me to dive a little deeper into understanding what makes a Git commit good or bad.</p>
<p>You're probably thinking to yourself, "my commits are just fine, thank you." But are they really? Let's take a closer look.</p>
<h2 id="heading-why-are-good-commits-important">Why Are Good Commits Important?</h2>
<p>Git commits are like little snapshots of your code. They let you and others see what changes were made, and when. They also let you roll back those changes when something inevitably goes wrong.</p>
<p>That's why it's important to make sure your git commits are as clear and concise as possible. Otherwise, you run the risk of confusing yourself and others down the road.</p>
<h2 id="heading-the-problem-with-your-current-commits">The Problem With Your Current Commits</h2>
<p>There are three main problems I find with many commits:</p>
<ol>
<li>They're not informative enough.</li>
<li>They're not helpful to others.</li>
<li>You're putting too many changes in one commit.</li>
</ol>
<h3 id="heading-not-enough-information">Not Enough Information</h3>
<p>These commits are essentially worthless. You know the ones I'm talking about - they just say "updated" or "fixed bug" or something similarly unhelpful.</p>
<p>It doesn't have to be that way. Let's look at why these kinds of commits are a problem, and what you can do about it.</p>
<ol>
<li><p>They don't tell us anything about what was actually changed. Was a bug fixed? Was a feature added? We have no idea.</p>
</li>
<li><p>It makes it harder to analyze when we're trying to find out when a particular change was introduced. If a commit just says "updated", we have no way of knowing whether it introduced the change we're looking for or not.</p>
</li>
<li><p>It's lazy. If you can't be bothered to write a decent commit message, then why are you making it in the first place?</p>
</li>
</ol>
<p>So, what can you do about it? Simple: make sure your git commits are informative. Tell us what was changed, why it was changed, and how it was changed. Use subject line wisely, and include extra information in the body. Otherwise, developers (including your future self) might just end up ignoring your commits altogether.</p>
<h3 id="heading-not-helpful-to-others">Not Helpful to Others</h3>
<p>Your git commits should be helpful to others who may be working on the same codebase. That means including information that will help them understand the changes you made, and why.</p>
<p>Here's the problem: when you make a git commit, you're only required to provide a brief message describing the change. But that's not enough information for other developers to understand what you did and why.</p>
<p>As a result, many git commits are cryptic and unhelpful. The classic "updated libraries" doesn't actually tell us anything about the change that was made.</p>
<p>This is a problem because it makes it difficult for other developers to understand the history of a project. It also makes it hard to figure out who to blame when something goes wrong.</p>
<p>And we <em>need</em> to know who's to blame.</p>
<h3 id="heading-too-much-in-one-commit">Too Much In One Commit</h3>
<p>Your git commits should be concise and to the point. You want them to be informative, sure, but one wants to read a novel every time they look at the commit history. I personally have a problem writing commits that are way too long, and often have more files than I should in one commit.</p>
<p>I know, I know, I should be making small, atomic commits that are easy to revert if something goes wrong. But sometimes, I just can't help myself. I make a change, and it's so big and complex that I just have to commit it all at once. And then I have to go through the process of squashing all those changes into a single commit.</p>
<p>It's a pain, and it often leads to messy, hard-to-read commit histories. But worst of all, it can make it really difficult to revert a change if something goes wrong.</p>
<p>So, please, for the sake of your sanity and the sanity of those who have to work with your code, try to avoid making these long commits with multiple files. Stick to the small, atomic changes that are easy to revert.</p>
<p>Your future self will thank you.</p>
<h2 id="heading-how-to-write-better-commits">How To Write Better Commits</h2>
<p>Now that we know what makes a bad Git commit, let's look at how to make your commits better.</p>
<h3 id="heading-make-them-more-informative">Make them more informative.</h3>
<p>Your git commits should be clear and concise. That means including a proper description of what changed, and—more importantly—<em>why</em> it changed.</p>
<h3 id="heading-make-them-more-helpful">Make them more helpful.</h3>
<p>Try to put yourself in another developer's shoes and ask yourself if what you wrote would be helpful to others who may be working on the same codebase. That means including information that will help them understand the changes you made and again, <em>why</em>.</p>
<p>There's a trend here.</p>
<h3 id="heading-write-more-smaller-commits">Write more, smaller commits.</h3>
<p>As I mentioned before, your git commits should be direct and to the point. Be sure to remove any unnecessary information from your commit messages, and split them up where it makes sense. Longer doesn't always mean better; keep the subject line short and move other details to the body. Smaller, atomic commits are much easier to understand and can be rolled back without affecting other working code.</p>
<h2 id="heading-examples">Examples</h2>
<p>Here are some examples of good commit messages:</p>
<h4 id="heading-example-1">Example 1</h4>
<pre><code class="lang-git">Remove unused CSS

Get rid of unused selectors from primary stylesheet to drastically reduce load time.
</code></pre>
<h4 id="heading-example-2">Example 2</h4>
<pre><code class="lang-git">Update README

Add a new section on how to run tests to provide more information to developers.
</code></pre>
<h4 id="heading-example-3">Example 3</h4>
<pre><code class="lang-git">Fix bug in login flow

Add a new redirect which takes users to the home page if they're already logged in, preventing users from getting stuck.
</code></pre>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Writing quality Git commits is a crucial part of building a successfully project and collaborating with other developers. Your messages should be clear, concise, and helpful to others. By following these tips, hopefully you can make sure your commits are all of those things.</p>
<p>If you want to take it a step further, you could follow the <a target="_blank" href="https://www.conventionalcommits.org/en/v1.0.0/">Conventional Commits</a> specification.</p>
<p>Let me know in the comments if this was helpful or if you have any questions.</p>
<p>Be sure to follow me for more like this!</p>
]]></content:encoded></item><item><title><![CDATA[Introducing Bun, the Node.js Killer?]]></title><description><![CDATA[Most developers know Node.js as the standard runtime for using JavaScript outside of the browser. But recently, a new runtime—Bun—has been announced that claims to be 3x faster than Node.js, and even its successor Deno, in common use cases.
Jared Sum...]]></description><link>https://blog.techsavvytravvy.com/introducing-bun</link><guid isPermaLink="true">https://blog.techsavvytravvy.com/introducing-bun</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[Node.js]]></category><category><![CDATA[runtime]]></category><category><![CDATA[Deno]]></category><category><![CDATA[serverless]]></category><dc:creator><![CDATA[trav]]></dc:creator><pubDate>Thu, 28 Jul 2022 07:04:46 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1658993058847/vnuMLafik.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Most developers know <a target="_blank" href="https://nodejs.org/">Node.js</a> as the standard runtime for using JavaScript outside of the browser. But recently, a new runtime—Bun—has been announced that claims to be 3x faster than Node.js, and even its successor <a target="_blank" href="https://deno.land/">Deno</a>, in common use cases.</p>
<p>Jared Sumner, a former developer at Stripe, released <a target="_blank" href="https://bun.sh">Bun</a> in July of 2022. Bun is a runtime developed using the relatively obscure <a target="_blank" href="https://ziglang.org/">Zig</a> programming language that embraces web standards but aims for compatibility with Node.js, so developers can easily migrate existing code.</p>
<p>All of that is great and interesting, but what separates Bun from other runtimes, and does it really stand a chance against the big players?</p>
<h2 id="heading-what-makes-it-different">What Makes It Different</h2>
<p>One of the most distinguishing features of Bun is that it uses <a target="_blank" href="https://github.com/WebKit/WebKit/tree/main/Source/JavaScriptCore">JavaScriptCore</a> as its engine, unlike Node.js and Deno, which use V8. The result is a blazing fast runtime that offers several quality-of-life features for JS developers.</p>
<p>Bun also has first-class integration of TypeScript and JSX, while also providing many of the features of transpilers like Babel, and bundlers like Webpack, Rollup, and Vite.</p>
<h2 id="heading-diving-in">Diving In</h2>
<p>Let's get started with Bun by installing it. According to the <a target="_blank" href="https://github.com/oven-sh/bun#Reference">official documentation</a>, this requires only the following command:</p>
<pre><code class="lang-shell">curl https://bun.sh/install | bash
</code></pre>
<p>After it's finished just follow the confirmation prompt with directions for adding Bun to your PATH.</p>
<p>Writing and running our first Bun script is pretty simple. We can run Bun.serve by using the command <code>bun run script.js</code> and then going to <code>localhost:3000</code> to see the response to our request.</p>
<p>It's very common to need to read and write to files when building applications, and Bun makes this dead simple. In this example we'll create a file containing the URL each time we submit a request:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> count = <span class="hljs-number">1</span>;
Bun.serve({
    fetch(request) {
        Bun.write(<span class="hljs-string">`test-<span class="hljs-subst">${count}</span>.txt`</span>, request.url);
        count++;
        <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> Response(<span class="hljs-string">'Created Test File'</span>);
    },
});
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Listening on Port 3000'</span>);
</code></pre>
<h2 id="heading-features-baked-in">Features Baked-In</h2>
<p>Support for <a target="_blank" href="https://www.sqlite.org/index.html">SQLite</a> by default is another nice touch. Querying your database is a breeze and you don't have to install external packages.</p>
<p>Using <code>.env</code> files with Bun is also quite easy. You can simply access them with <code>process.env</code> like in Node, but without needing to install <a target="_blank" href="https://www.dotenv.org/">dotenv</a>.</p>
<h2 id="heading-the-nodejs-killer">The Node.js Killer?</h2>
<p>As of right now Bun is still in its infancy, with many APIs and features not yet implemented. I don't see it replacing Node.js anytime soon, but with that said, its speed and features are enough to grab my attention. I'll certainly be keeping an eye on it to see how it progresses.</p>
<p>Are you excited about Bun, or are you content with Node.js? Let me know in the comments.</p>
<p>Be sure to follow me for more like this!</p>
]]></content:encoded></item><item><title><![CDATA[What Is Web3 and Why Should I Care?]]></title><description><![CDATA[You've probably heard the term "Web3" thrown around—it's been a buzzword for a while now. But what is it really, and has it lived up to the hype?
Web3 was touted as the next phase of the internet, focused on decentralization. The idea was that there ...]]></description><link>https://blog.techsavvytravvy.com/what-is-web3-and-why-should-i-care</link><guid isPermaLink="true">https://blog.techsavvytravvy.com/what-is-web3-and-why-should-i-care</guid><category><![CDATA[Web3]]></category><category><![CDATA[Blockchain]]></category><category><![CDATA[Smart Contracts]]></category><category><![CDATA[Cryptocurrency]]></category><category><![CDATA[NFT]]></category><dc:creator><![CDATA[trav]]></dc:creator><pubDate>Tue, 26 Jul 2022 18:48:01 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1658843421368/nHvBQ7Y4K.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>You've probably heard the term "Web3" thrown around—it's been a buzzword for a while now. But what is it really, and has it lived up to the hype?</p>
<p>Web3 was touted as the next phase of the internet, focused on decentralization. The idea was that there would be no central authority controlling it, instead relying on a network of computers worldwide. Sounds great in theory, right?</p>
<p>The promise was that you could use the web without worrying about being tracked or censored by a central authority. Instead of relying on tech giants like Google and Facebook to store your data, Web3 would allow you to do it yourself. It was supposed to open up incredible opportunities for increased transparency, security, and creativity.</p>
<p>But let's be real: it hasn't quite panned out that way.</p>
<p>The Web3 hype train attracted a swarm of scammers, con artists, and opportunists looking to make a quick buck. Because there's no central authority, it's been a challenge to stop bad actors from doing nefarious deeds. Remember all those stories about NFT rug pulls and crypto scams? Yeah, that's the dark side of decentralization.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1658858270055/IQGpnke1Y.png" alt="rug pulls have become common in the cryptocurrency space" /></p>
<p>Another glaring issue is that Web3 is still complicated and difficult to use for the average person. Even if you're tech-savvy, figuring out how to set up a Web3 wallet or use a decentralized exchange can be a headache. This complexity, combined with a general lack of understanding among average internet users, has seriously slowed adoption.</p>
<p>Let's dive into some of the ways Web3 was supposed to change how we use the internet, and see how reality measures up.</p>
<h2 id="heading-read-write-own-sort-of">Read, Write, Own... Sort of</h2>
<p>Web 1.0 was mostly read-only. Web 2.0 allowed users to interact through comments, reactions, and shares. Web3 promised that we could not only read and write but also own our data.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1658860667034/4FWN3U8o4.jpeg" alt="collage of web 1.0 websites" /></p>
<p>In practice, though, most people are still using centralized platforms. Sure, you can technically "own" your data on a blockchain, but good luck explaining that to your grandma. The reality is that most users are still happily handing over their data to Facebook, Google, and Amazon.</p>
<h2 id="heading-the-promise-of-better-transactions">The Promise of Better Transactions</h2>
<p>Web3 promised the ability to transact money directly on the web without intermediaries. While cryptocurrencies have made some headway, they're far from replacing traditional financial systems.</p>
<p>Here's the reality of using Web3 for financial transactions:</p>
<ol>
<li><p>It's fast... when it works. Network congestion can slow things to a crawl.</p>
</li>
<li><p>It's convenient... if you don't mind the learning curve and potential for costly mistakes.</p>
</li>
<li><p>It's secure... until someone hacks an exchange or you lose your private keys.</p>
</li>
<li><p>It's private... except when it's not. Blockchain transactions are often more traceable than cash.</p>
</li>
</ol>
<h2 id="heading-a-new-take-on-identity">A New Take On Identity</h2>
<p>Web3 promised secure, decentralized identities. In reality, most people are still logging in with their Google or Facebook accounts because it's just easier.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1658859144746/A1S-ju3ID.jpeg" alt="flowchart showing &quot;password hell&quot;" /></p>
<p>While there have been some interesting developments in decentralized identity, adoption has been slow. Most users still prefer the convenience of centralized identity providers, even if it means sacrificing some privacy.</p>
<h2 id="heading-there-was-an-attempt">There Was An Attempt</h2>
<p>Web3 was supposed to be the internet's rebellion against data mishandling by social networks. While concerns about data privacy are still very real, Web3 hasn't exactly led to a mass exodus from traditional platforms.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1658858874650/v-RJ8StAa.png" alt="Bar Graph Showing Concern Over Social Media Companies Selling Personal Data" /></p>
<p>The reality is that most people are still using Facebook, Twitter, and Instagram. The promised land of secure, decentralized, and censorship-resistant social networks remains largely theoretical.</p>
<h2 id="heading-a-new-era-for-artists-or-just-more-hype">A New Era for Artists, Or Just More Hype?</h2>
<p>Web3 was supposed to revolutionize the creative industry, allowing artists to own their work and connect directly with fans. While some artists have found success with NFTs, the reality for most has been less rosy.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1658859962099/k6cstM7hY.png" alt="Bored Ape Yacht Club NFTs" /></p>
<p>The NFT craze led to a lot of hype and some eye-watering prices, but it also brought a flood of low-quality cash grabs and outright scams. Many artists found themselves spending more time marketing their NFTs than creating art. And let's not forget the environmental concerns around the energy consumption of blockchain networks.</p>
<h2 id="heading-better-communities">Better Communities</h2>
<p>Decentralized Autonomous Organizations (DAOs) were touted as a revolutionary way to organize communities. While there have been some interesting experiments, DAOs have also faced challenges with governance, legal recognition, and scalability.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1658869525683/q2Im1eZO3.png" alt="components of a decentralized autonomous organization" /></p>
<p>The reality is that most people are still more comfortable with traditional organizational structures. DAOs remain a niche concept, largely confined to the crypto community.</p>
<h2 id="heading-were-not-quite-there-yet-and-maybe-we-never-will-be">We're Not Quite There, Yet... And Maybe We Never Will Be</h2>
<p>The dream of a fully decentralized web remains just that—a dream. Ethereum, often held up as the backbone of Web3, is still largely controlled by a small group of whales and mining pools. Key infrastructure remains centralized, and most users still rely on centralized exchanges and wallets.</p>
<p>The push towards Web3 has also raised important questions about scalability, energy consumption, and regulatory compliance. As governments around the world start to take a closer look at cryptocurrencies and blockchain technologies, the future of Web3 remains uncertain.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Web3 has potential, but it's important to separate the hype from reality. While it has introduced some interesting concepts and technologies, it hasn't revolutionized the internet as many predicted. It's still a niche interest, plagued by complexity, scams, and regulatory uncertainty.</p>
<p>That said, some of the ideas behind Web3—like increased data ownership and privacy—are worth pursuing. The challenge lies in making these concepts accessible and useful to the average internet user. Until then, Web3 remains more of a playground for tech enthusiasts and speculators than a true next generation of the web.</p>
]]></content:encoded></item><item><title><![CDATA[How to Get Clients as a Freelance Programmer]]></title><description><![CDATA[So you want to be a freelance programmer? Congratulations! You've joined the ranks of the unemployed, the hopeless, and the destitute. But don't worry, with a few simple tips, you too can become a member of the ever-growing ranks of the precariously ...]]></description><link>https://blog.techsavvytravvy.com/how-to-get-clients-as-a-freelance-programmer</link><guid isPermaLink="true">https://blog.techsavvytravvy.com/how-to-get-clients-as-a-freelance-programmer</guid><category><![CDATA[Freelancing]]></category><category><![CDATA[marketing]]></category><category><![CDATA[programming]]></category><category><![CDATA[social media]]></category><category><![CDATA[Open Source]]></category><dc:creator><![CDATA[trav]]></dc:creator><pubDate>Sun, 24 Jul 2022 19:04:52 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1658689190134/yVLFtuY03.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>So you want to be a freelance programmer? Congratulations! You've joined the ranks of the unemployed, the hopeless, and the destitute. But don't worry, with a few simple tips, you too can become a member of the ever-growing ranks of the precariously employed!</p>
<p>There are a few things you can do to increase your chances of finding clients. In this article, we will discuss some of the best ways to find clients as a freelance programmer.</p>
<h2 id="heading-contribute-to-open-source">Contribute to Open Source</h2>
<p>One of the best ways to build your portfolio is to contribute to open-source projects. Not only will this give you some great experience, but you'll also get your name out there and make some important connections.</p>
<p>There are a few ways to find open source projects to contribute to. One is to search for them on GitHub, and another is to look for them on popular programming forums.</p>
<p>Once you've found a project you'd like to contribute to, the next step is to make sure you have the skills required. If you don't, that's okay! There are plenty of projects that need documentation or other non-coding tasks completed.</p>
<p>Once you've found a project and made sure you have the required skills, the next step is to reach out to the project maintainers and let them know you're interested in contributing. They'll be able to give you more specific instructions on what they need and how you can help.</p>
<p>When you contribute to open source, make sure to include a link to your website or blog so that people can see your work. You can also list your contributions on your resume or website to show potential clients what you're capable of.</p>
<h2 id="heading-find-your-niche">Find Your Niche</h2>
<p>There are a lot of programmers out there, and it can be difficult to stand out from the crowd. But if you focus on a specific area or technology, you'll be more likely to find clients who are looking for someone with your skills.</p>
<p>There are a few ways to find your niche. One is to think about the technologies you're most interested in. Another is to look at the projects you've worked on in the past and see if there's a common thread.</p>
<p>Once you've identified your niche, the next step is to start marketing yourself as an expert in that area. Write blog posts, give talks at meetups, and get involved in online communities. The more you can position yourself as an expert, the more likely you are to find clients who need your help.</p>
<p>When you focus on a specific niche, you will be able to build a strong portfolio and become an expert in that area. This will make you more attractive to potential clients who are looking for someone with your specific skills.</p>
<h2 id="heading-build-a-strong-online-presence">Build a Strong Online Presence</h2>
<p>In breaking news to nobody, it's important to have a strong online presence. This means having a website or blog where you can showcase your work, and being active on social media.</p>
<p>As a programmer, you're probably used to spending most of your time in front of a computer screen, alone in your own thoughts. But if you want to be successful in today's world, you need to be more than just a coder—you need to be a social media superstar.</p>
<p>That's right, in order to build a successful career as a programmer, you need to have a strong social media presence. But don't worry, it's not as difficult as it sounds. Here are a few tips to help you get started:</p>
<ol>
<li><p>Be active </p>
<p> This may seem like a no-brainer, but it's important to be active on social media if you want to build a strong presence. Post regularly, interact with other users, and make sure you're constantly putting yourself out there.</p>
</li>
<li><p>Share your work</p>
<p> If you're proud of the work you're doing, make sure you share it on social media! Post your code snippets, share your blog posts, and let the world know what you're up to.</p>
</li>
<li><p>Connect with other programmers</p>
<p> One of the best ways to build a strong social media presence is to connect with other programmers. Follow them on Twitter, retweet their blog posts, and engage in discussion.</p>
</li>
<li><p>Be yourself</p>
<p> People connect with people, not robots. So make sure you're being authentic on social media. Share your interests, your thoughts, and your personality.</p>
</li>
<li><p>Have fun!</p>
<p> Building a social media presence can be a lot of work, but it should also be fun. So make sure you're enjoying the process and having a good time.</p>
</li>
</ol>
<p>If you want my personal opinion (why else are you reading this?) I would highly recommend TikTok if you're trying to decide what platform to use.</p>
<h2 id="heading-how-to-find-clients">How to Find Clients</h2>
<p>Now that you've built a strong online presence, it's time to start looking for clients. There are a few different ways to find clients, and the best method will vary depending on your niche.</p>
<p>One of the most popular ways to find clients is to use online platforms like Upwork, Toptal, or Freelancer.com. These platforms allow you to create a profile and bid on projects that clients have posted.</p>
<p>Another way to find clients is to reach out to them directly. This can be done by sending them an email or connecting with them on social media. If you have a personal connection with a potential client, this can be a great way to get your foot in the door.</p>
<p>You can also get referrals from other freelancers or businesses. If you know someone who has worked with a client that you think would be a good fit for you, reach out and ask for a referral.</p>
<h3 id="heading-upwork">Upwork</h3>
<p><a target="_blank" href="https://upwork.com">Upwork</a> is a great place to find clients. It's a freelancing marketplace where you can create a profile and bid on projects.</p>
<p>To be successful on Upwork, you need to have a strong profile and portfolio. You also need to be able to market yourself well and sell your skills to potential clients.</p>
<h3 id="heading-toptal">Toptal</h3>
<p><a target="_blank" href="https://toptal.com">Toptal</a> is a freelancing marketplace that is specifically for top talent. To be accepted onto the platform, you need to pass a rigorous screening process.</p>
<p>Once you're accepted, you will be able to access a wide range of high-paying clients. To be successful on Toptal, you need to have a strong portfolio and be able to market yourself well.</p>
<h3 id="heading-fiverr">Fiverr</h3>
<p><a target="_blank" href="https://fiverr.com">Fiverr</a> is a freelancing marketplace where you can offer services starting at $5. While this may not seem like a lot of money, you can offer multiple services and upsells to make more money.</p>
<p>To be successful on Fiverr, you need to have a strong portfolio and be able to market yourself well. You also need to be able to deliver your services quickly and efficiently.</p>
<h3 id="heading-freelancercom">Freelancer.com</h3>
<p>Freelancer.com is a freelancing marketplace where you can find a wide range of clients. To be successful on Freelancer.com, you need to have a strong portfolio, be able to market yourself well, and be able to deliver your services quickly and efficiently.</p>
<h2 id="heading-keeping-your-clients">Keeping Your Clients</h2>
<p>Once you've found a few clients, you need keep them happy. This can be done by delivering high-quality work on time and keeping communication channels open.</p>
<p>It's crucial that you keep your clients updated on your availability. If you know you're going to be unavailable for a period of time, let them know in advance so they can make alternative arrangements.</p>
<p>Always be professional. This means being polite, respectful, and responsive. The importance of good communication can't be stressed enough. If you're able to build strong relationships with your clients, they will be more likely to keep working with you.</p>
<h2 id="heading-get-referrals">Get Referrals</h2>
<p>One of the best ways to find new clients is to get referrals from your existing clients. If you're doing a good job and they're happy with your work, they will be more likely to refer you to their friends or colleagues.</p>
<p>Another way to get referrals is to offer a discount to clients who refer you to someone else. This can be done by giving them a percentage off their next project or a gift card to a popular retailer.</p>
<p>You can also ask for testimonials from your clients which you can use to market yourself. This is a great way to show off your work and give potential clients an idea of what it's like to work with you.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>As a freelance programmer, it's important to find ways to stand out from the crowd. By following the tips in this article, you will be able to find more clients and build strong relationships with them.</p>
<p>Let me know in the comments if you found this helpful or if you have any questions.</p>
<p>Be sure to follow me for more like this!</p>
]]></content:encoded></item><item><title><![CDATA[How to Create a Doubly Linked List in C++]]></title><description><![CDATA[A common misconception is that doubly linked lists are difficult to understand and work with. This is not the case! In fact, they can be quite easy to use once you get the hang of it. In this article, we will be discussing the basics of doubly linked...]]></description><link>https://blog.techsavvytravvy.com/how-to-create-and-print-a-doubly-linked-list-in-cpp</link><guid isPermaLink="true">https://blog.techsavvytravvy.com/how-to-create-and-print-a-doubly-linked-list-in-cpp</guid><category><![CDATA[C++]]></category><category><![CDATA[data structures]]></category><category><![CDATA[howto]]></category><category><![CDATA[100DaysOfCode]]></category><dc:creator><![CDATA[trav]]></dc:creator><pubDate>Sun, 24 Jul 2022 09:35:04 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1658655176098/0K_15h71L.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>A common misconception is that doubly linked lists are difficult to understand and work with. This is not the case! In fact, they can be quite easy to use once you get the hang of it. In this article, we will be discussing the basics of doubly linked lists in C++.</p>
<h2 id="heading-what-is-a-doubly-linked-list">What is a Doubly Linked List?</h2>
<p>A doubly linked list is a data structure that consists of a set of nodes that are linked together in a linear fashion. Each node contains two pointers: one that points to the next node in the list, and one that points to the previous node in the list. The first and last node have their previous and next pointing to <code>null</code>, respectively. This allows for bidirectional traversal of the list.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1658656055655/aH1zFDvdS.png" alt="doubly linked list" /></p>
<h2 id="heading-creating-a-doubly-linked-list-in-c">Creating a Doubly Linked List in C++</h2>
<p>Creating a doubly linked list in C++ is fairly simple. First, we need to define a node class:</p>
<pre><code class="lang-cpp"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Node</span> {</span>
<span class="hljs-keyword">public</span>:
    <span class="hljs-keyword">int</span> data;
    Node* next;
    Node* prev;
};
</code></pre>
<p>Next, we need to create a function that will add a new node to the list:</p>
<pre><code class="lang-cpp"><span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">addNode</span><span class="hljs-params">(Node* &amp;head, <span class="hljs-keyword">int</span> data)</span> </span>{
    Node* newNode = <span class="hljs-keyword">new</span> Node();
    newNode-&gt;data = data;
    newNode-&gt;next = head;
    newNode-&gt;prev = <span class="hljs-literal">nullptr</span>;
    <span class="hljs-keyword">if</span> (head != <span class="hljs-literal">nullptr</span>)
        head-&gt;prev = newNode;
    head = newNode;
}
</code></pre>
<p>Now that we have a function to add nodes, we can create a doubly linked list by calling this function multiple times:</p>
<pre><code class="lang-cpp">Node* head = <span class="hljs-literal">nullptr</span>;
addNode(head, <span class="hljs-number">1</span>);
addNode(head, <span class="hljs-number">2</span>);
addNode(head, <span class="hljs-number">3</span>);
addNode(head, <span class="hljs-number">4</span>);
addNode(head, <span class="hljs-number">5</span>);
</code></pre>
<p>We can print the list by traversing it and printing each node's data:</p>
<pre><code class="lang-cpp"><span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">printList</span><span class="hljs-params">(Node* head)</span> </span>{
    <span class="hljs-keyword">while</span> (head != <span class="hljs-literal">nullptr</span>) {
        <span class="hljs-built_in">cout</span> &lt;&lt; head-&gt;data &lt;&lt; <span class="hljs-string">" "</span>;
        head = head-&gt;next;
    }
    <span class="hljs-built_in">cout</span> &lt;&lt; <span class="hljs-built_in">endl</span>;
}
</code></pre>
<p>Putting everything together, we have the following program:</p>
<pre><code class="lang-cpp"><span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;iostream&gt;</span></span>

<span class="hljs-keyword">using</span> <span class="hljs-keyword">namespace</span> <span class="hljs-built_in">std</span>;

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Node</span> {</span>
<span class="hljs-keyword">public</span>:
    <span class="hljs-keyword">int</span> data;
    Node* next;
    Node* prev;
};

<span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">addNode</span><span class="hljs-params">(Node* &amp;head, <span class="hljs-keyword">int</span> data)</span> </span>{
    Node* newNode = <span class="hljs-keyword">new</span> Node();
    newNode-&gt;data = data;
    newNode-&gt;next = head;
    newNode-&gt;prev = <span class="hljs-literal">nullptr</span>;
    <span class="hljs-keyword">if</span> (head != <span class="hljs-literal">nullptr</span>)
        head-&gt;prev = newNode;
    head = newNode;
}

<span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">printList</span><span class="hljs-params">(Node* head)</span> </span>{
    <span class="hljs-keyword">while</span> (head != <span class="hljs-literal">nullptr</span>) {
        <span class="hljs-built_in">cout</span> &lt;&lt; head-&gt;data &lt;&lt; <span class="hljs-string">" "</span>;
        head = head-&gt;next;
    }
    <span class="hljs-built_in">cout</span> &lt;&lt; <span class="hljs-built_in">endl</span>;
}

<span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">main</span><span class="hljs-params">()</span> </span>{
    Node* head = <span class="hljs-literal">nullptr</span>;
    addNode(head, <span class="hljs-number">1</span>);
    addNode(head, <span class="hljs-number">2</span>);
    addNode(head, <span class="hljs-number">3</span>);
    addNode(head, <span class="hljs-number">4</span>);
    addNode(head, <span class="hljs-number">5</span>);
    printList(head);
    <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;
}
</code></pre>
<p>Running this program produces the following output:</p>
<pre><code><span class="hljs-number">5</span> <span class="hljs-number">4</span> <span class="hljs-number">3</span> <span class="hljs-number">2</span> <span class="hljs-number">1</span>
</code></pre><p>You can also print the list in reverse by traversing it from the end and printing each node's data:</p>
<pre><code class="lang-cpp"><span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">printListReverse</span><span class="hljs-params">(Node* head)</span> </span>{
    <span class="hljs-keyword">while</span> (head-&gt;next != <span class="hljs-literal">nullptr</span>)
        head = head-&gt;next;
    <span class="hljs-keyword">while</span> (head != <span class="hljs-literal">nullptr</span>) {
        <span class="hljs-built_in">cout</span> &lt;&lt; head-&gt;data &lt;&lt; <span class="hljs-string">" "</span>;
        head = head-&gt;prev;
    }
    <span class="hljs-built_in">cout</span> &lt;&lt; <span class="hljs-built_in">endl</span>;
}
</code></pre>
<p>If we add this function to our program and call it, we get the following output:</p>
<pre><code><span class="hljs-number">1</span> <span class="hljs-number">2</span> <span class="hljs-number">3</span> <span class="hljs-number">4</span> <span class="hljs-number">5</span>
</code></pre><h2 id="heading-conclusion">Conclusion</h2>
<p>Doubly linked lists are a powerful data structure that can be used to store data in a linear fashion while still allowing for quick traversal in both directions. In C++, they can be easily created and manipulated using the built-in node class.</p>
]]></content:encoded></item><item><title><![CDATA[How I Created My First Successful NPM Package]]></title><description><![CDATA[I've created a few NPM packages in the past, but they never really took off (not that they were intended to in the first place). Last year, however, I created a tool called Lightbox for Bootstrap 5 (bs5-lightbox on NPM) and it's currently getting aro...]]></description><link>https://blog.techsavvytravvy.com/how-i-created-my-first-successful-npm-package</link><guid isPermaLink="true">https://blog.techsavvytravvy.com/how-i-created-my-first-successful-npm-package</guid><category><![CDATA[npm]]></category><category><![CDATA[Open Source]]></category><category><![CDATA[GitHub]]></category><category><![CDATA[howto]]></category><dc:creator><![CDATA[trav]]></dc:creator><pubDate>Sun, 24 Jul 2022 08:45:40 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1658651995432/tRbz2I3MN.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I've created a few NPM packages in the past, but they never really took off (not that they were intended to in the first place). Last year, however, I created a tool called <a target="_blank" href="https://github.com/trvswgnr/bs5-lightbox">Lightbox for Bootstrap 5</a> (bs5-lightbox on <a target="_blank" href="https://www.npmjs.com/package/bs5-lightbox">NPM</a>) and it's currently getting around 3 million CDN hits per month and has over 12,000 downloads on NPM. Since I never expected or meant for this to be so popular—I mean, it's just a simple lightbox gallery plugin—I thought I would analyze what made this project different in case that might be of use to anyone.</p>
<p>Based on my findings, here are a few things you can try if you want a more successful project.</p>
<h2 id="heading-piggyback-off-of-an-existing-popular-project">Piggyback off of an existing popular project</h2>
<p>A major reason why bs5-lightbox gets the amount of attention it does is because it was created for Bootstrap, an incredibly  popular front-end framework. By creating a plugin that piggybacks off of an existing project, you're immediately introducing your package to a large audience that is already interested in what you're offering.</p>
<h2 id="heading-replace-an-out-of-date-tool">Replace an out-of-date tool</h2>
<p>I think another large contributing factor to the success of bs5-lightbox is that it replaces an already successful, but out of date tool called Ekko Lightbox. Many people, including myself would reach for it but then realize it was only compatible with Bootstrap 4. So, by creating a tool to fill that void, I was able to attract users who were looking for a similar solution.</p>
<h2 id="heading-have-a-good-name">Have a good name</h2>
<p>This might seem like a no-brainer, but it's important to have a name for your project that is both accurate and memorable. In the case of bs5-lightbox, the name is accurate (it's a lightbox gallery plugin for Bootstrap 5) and it's also easy to remember.</p>
<h2 id="heading-make-it-as-simple-as-possible">Make it as simple as possible</h2>
<p>This is probably the most important tip I can give. The bs5-lightbox package is extremely simple. It's just one JavaScript file. That's it. It just works. And I think that's why people like it so much. It's easy to install and it does one thing well.</p>
<p>Lightbox for Bootstrap 5 is also very easy to setup. It can be installed with a simple <code>npm install bs5-lightbox</code> or by adding a script tag with a link to the CDN. No need to fiddle with any build tools or configuration files.</p>
<h2 id="heading-offer-a-live-demo">Offer a live demo</h2>
<p>People are always more likely to use something if they can see it in action first. That's why I created a live demo of bs5-lightbox that people can try out before they download it. This not only lets people see what the lightbox looks like, but it also shows them how easy it is to use.</p>
<h2 id="heading-have-good-documentation">Have good documentation</h2>
<p>Once people have decided to use your package, it's important to have good documentation so they know how to do so. This can be in the form of a README file, a wiki, or even a blog post like this one. As long as it is clear and concise, people will be able to get up and running with your package in no time.</p>
<h2 id="heading-keep-it-updated">Keep it updated</h2>
<p>Finally, it's important to keep your package updated with the latest versions of the dependencies it uses. In the case of bs5-lightbox, that means always using the latest version of Bootstrap. Not only does this ensure that your package works with the latest versions of the dependencies, but it also shows that you are keeping up with the latest changes.</p>
<h2 id="heading-offer-support">Offer support</h2>
<p>I try to offer support for bs5-lightbox as much as I can through its <a target="_blank" href="https://github.com/trvswgnr/bs5-lightbox">GitHub page</a>. I think this is important because it shows that I'm actively involved in the project and care about its users. I respond to issues as soon as I can and I encourage developers who have solved problems with the package to create Pull Requests.</p>
<h2 id="heading-be-open-to-feedback">Be open to feedback</h2>
<p>Finally, I was open to feedback and was always looking for ways to improve the project. I never wanted to rest on my laurels and I think that helped me keep people interested in the project.</p>
<p>I don't think there's a magic formula for making a successful project, but I do think the popularity <a target="_blank" href="https://github.com/trvswgnr/bs5-lightbox">Lightbox for Bootstrap 5</a> was a combination of these factors. I was lucky enough to create a tool that filled a void for a large and active community. But, I also put in the work to make sure people knew about it and understood how to use it. If you're thinking about creating an NPM package, I hope this was helpful. Good luck!</p>
]]></content:encoded></item><item><title><![CDATA[Beginner's Guide to Data Structures in JavaScript]]></title><description><![CDATA[As you may or may not know, data structures are the key to efficient algorithms and data management. In this article, we'll take a look at the most popular data structures, how to implement them in JavaScript, and how they can be used to your advanta...]]></description><link>https://blog.techsavvytravvy.com/beginners-guide-to-data-structures-in-javascript</link><guid isPermaLink="true">https://blog.techsavvytravvy.com/beginners-guide-to-data-structures-in-javascript</guid><category><![CDATA[Data Science]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[algorithms]]></category><category><![CDATA[data structures]]></category><category><![CDATA[General Programming]]></category><dc:creator><![CDATA[trav]]></dc:creator><pubDate>Sat, 23 Jul 2022 14:00:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1658355349896/2N2tlQGf9.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>As you may or may not know, data structures are the key to efficient algorithms and data management. In this article, we'll take a look at the most popular data structures, how to implement them in JavaScript, and how they can be used to your advantage.</p>
<h2 id="heading-what-are-data-structures">What are data structures?</h2>
<p>In computer science, a data structure is a data organization, management, and storage format that enables efficient access and modification. More precisely, a data structure is a collection of data values, the relationships among them, and the functions or operations that can be applied to the data.</p>
<p>When I first started programming, I found data structures and algorithms to be incredibly confusing. Hopefully this article will help developers who are new  to these concepts understand how to use some of the more common data structures.</p>
<p>Data structures are used to store data in a computer in an organized way so that it can be used efficiently. Different types of data structures are suited to different kinds of applications, and some are highly specialized to specific tasks. For example, trees are particularly well-suited for implementing databases, while compiler implementations usually use hash tables to look up identifiers.</p>
<h2 id="heading-common-data-structures">Common Data Structures</h2>
<p>There are many ways to store data, but the data structures I'll be talking about today are Arrays, Linked Lists, Hash Tables, and Trees.</p>
<h3 id="heading-arrays">Arrays</h3>
<p>Arrays are the simplest data structure. They are just a list of items, where each item can be accessed by its index. For example, an array of numbers might look like this:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> arr = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>];
</code></pre>
<p>To access an item in the array, we just use its zero-index. For example, to get the third item, we would do this:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> x = arr[<span class="hljs-number">2</span>]
</code></pre>
<p>Arrays have some drawbacks, though. They are not very flexible, and they can be slow to access items if the array is large.</p>
<h3 id="heading-linked-lists">Linked Lists</h3>
<p>Linked lists are a more flexible data structure than arrays. They are made up of nodes, which are connected together like a chain. Each node contains data, and a pointer to the next node in the list. A linked list of numbers could be visualized like this:</p>
<pre><code><span class="hljs-number">1</span> <span class="hljs-operator">-</span><span class="hljs-operator">&gt;</span> <span class="hljs-number">2</span> <span class="hljs-operator">-</span><span class="hljs-operator">&gt;</span> <span class="hljs-number">3</span> <span class="hljs-operator">-</span><span class="hljs-operator">&gt;</span> <span class="hljs-number">4</span> <span class="hljs-operator">-</span><span class="hljs-operator">&gt;</span> <span class="hljs-number">5</span>
</code></pre><p>To access an item in the linked list, we just follow the pointers until we reach the desired node.</p>
<p>To create a linked list in JavaScript, we can create a class that maintains a head pointer in the list:</p>
<pre><code class="lang-javascript"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">LinkedList</span> </span>{
  <span class="hljs-keyword">constructor</span>() {
    <span class="hljs-built_in">this</span>.head = <span class="hljs-literal">null</span>;
  }
}
</code></pre>
<p>We can then create nodes for our list. Each node will have a value and a pointer to the next node in the list:</p>
<pre><code class="lang-javascript"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Node</span> </span>{
  <span class="hljs-keyword">constructor</span>(value) {
    <span class="hljs-built_in">this</span>.value = value;
    <span class="hljs-built_in">this</span>.next = <span class="hljs-literal">null</span>;
  }
}
</code></pre>
<p>We can now create methods on our LinkedList class to add nodes to the list:</p>
<pre><code class="lang-javascript"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">LinkedList</span> </span>{
  <span class="hljs-keyword">constructor</span>() {
    <span class="hljs-built_in">this</span>.head = <span class="hljs-literal">null</span>;
  }

  <span class="hljs-comment">// adds a node to the end of the list</span>
  add(value) {
    <span class="hljs-keyword">const</span> node = <span class="hljs-keyword">new</span> Node(value);

    <span class="hljs-comment">// if the list is empty, set the node as the head</span>
    <span class="hljs-keyword">if</span> (<span class="hljs-built_in">this</span>.head === <span class="hljs-literal">null</span>) {
      <span class="hljs-built_in">this</span>.head = node;
      <span class="hljs-keyword">return</span>;
    }

    <span class="hljs-comment">// otherwise, traverse the list until we find the last node</span>
    <span class="hljs-keyword">let</span> current = <span class="hljs-built_in">this</span>.head;
    <span class="hljs-keyword">while</span> (current.next !== <span class="hljs-literal">null</span>) {
      current = current.next;
    }

    <span class="hljs-comment">// set the last node's next pointer to the new node</span>
    current.next = node;
  }

  <span class="hljs-comment">// removes a node from the list with the given value</span>
  remove(value) {
    <span class="hljs-comment">// if the list is empty, do nothing</span>
    <span class="hljs-keyword">if</span> (<span class="hljs-built_in">this</span>.head === <span class="hljs-literal">null</span>) <span class="hljs-keyword">return</span>;

    <span class="hljs-comment">// otherwise, check if the head node needs to be removed</span>
    <span class="hljs-keyword">if</span> (<span class="hljs-built_in">this</span>.head.value === value) {
      <span class="hljs-built_in">this</span>.head = <span class="hljs-built_in">this</span>.head.next;
      <span class="hljs-keyword">return</span>;
    }

    <span class="hljs-comment">// otherwise, traverse the list until we find the node to remove</span>
    <span class="hljs-keyword">let</span> current = <span class="hljs-built_in">this</span>.head;
    <span class="hljs-keyword">while</span> (current.next !== <span class="hljs-literal">null</span>) {
      <span class="hljs-keyword">if</span> (current.next.value === value) {
        <span class="hljs-comment">// set the next pointer of the current node to the node after the one we're removing</span>
        current.next = current.next.next;
        <span class="hljs-keyword">return</span>;
      }

      current = current.next;
    }
  }

  <span class="hljs-comment">// returns true if the list contains a node with the given value, false otherwise</span>
  contains(value) {
    <span class="hljs-comment">// if the list is empty, return false</span>
    <span class="hljs-keyword">if</span> (<span class="hljs-built_in">this</span>.head === <span class="hljs-literal">null</span>) <span class="hljs-keyword">return</span> <span class="hljs-literal">false</span>;

    <span class="hljs-comment">// otherwise, traverse the list until we find the value or reach the end</span>
    <span class="hljs-keyword">let</span> current = <span class="hljs-built_in">this</span>.head;
    <span class="hljs-keyword">while</span> (current !== <span class="hljs-literal">null</span>) {
      <span class="hljs-keyword">if</span> (current.value === value) <span class="hljs-keyword">return</span> <span class="hljs-literal">true</span>;

      current = current.next;
    }

    <span class="hljs-keyword">return</span> <span class="hljs-literal">false</span>;
  }
}
</code></pre>
<p>We can now create a list and add nodes to it:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> list = <span class="hljs-keyword">new</span> LinkedList();
list.add(<span class="hljs-number">1</span>);
list.add(<span class="hljs-number">2</span>);
list.add(<span class="hljs-number">3</span>);
</code></pre>
<p>And we can remove nodes:</p>
<pre><code class="lang-javascript">list.remove(<span class="hljs-number">2</span>);
</code></pre>
<p>Finally, we can check if the list contains a certain value:</p>
<pre><code class="lang-javascript">list.contains(<span class="hljs-number">3</span>); <span class="hljs-comment">// true</span>
list.contains(<span class="hljs-number">4</span>); <span class="hljs-comment">// false</span>
</code></pre>
<p>Linked lists are more flexible than arrays because we can easily insert and remove items without changing the rest of the list. They can also be slower to access items, though, because we have to follow the pointers.</p>
<h3 id="heading-hash-tables">Hash Tables</h3>
<p>Hash tables are used to store key-value pairs. The key is used to look up the value, like a dictionary. A hash table of numbers can be visualized like this:</p>
<pre><code><span class="hljs-number">1</span> <span class="hljs-string">-&gt;</span> <span class="hljs-number">2</span>
<span class="hljs-number">3</span> <span class="hljs-string">-&gt;</span> <span class="hljs-number">4</span>
<span class="hljs-number">5</span> <span class="hljs-string">-&gt;</span> <span class="hljs-number">6</span>
</code></pre><p>To implement a hash table in JavaScript, we can use an object to store the key-value pairs. The keys can be used as the object's properties, and the values can be stored as the property values.</p>
<p>For example, we could store a user's name and age in a hash table like this:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> user = {
  <span class="hljs-attr">name</span>: <span class="hljs-string">"John"</span>,
  <span class="hljs-attr">age</span>: <span class="hljs-number">30</span>
};
</code></pre>
<p>To lookup a value in the hash table, we can use the key as the index:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> name = user.name; <span class="hljs-comment">// "John"</span>
<span class="hljs-keyword">const</span> age = user.age; <span class="hljs-comment">// 30</span>
</code></pre>
<p>To add a new key-value pair to the hash table, we can simply create a new property on the object and assign it a value:</p>
<pre><code class="lang-javascript">user.city = <span class="hljs-string">"New York"</span>;
</code></pre>
<p>To remove a key-value pair from the hash table, we can use the delete operator:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">delete</span> user.city;
<span class="hljs-string">``</span>

You can also use <span class="hljs-string">`Map`</span> to implement hash tables. Using JavaScript<span class="hljs-string">'s `Map` class for hash tables has some advantages over using a standard object. For instance, `Map` keeps track of the order in which keys are added, which is important for some algorithms. It also provides some handy methods like `forEach()` and `values()` that make iteration more straightforward.

Here'</span>s how you might create a hash table <span class="hljs-keyword">with</span> <span class="hljs-string">`Map`</span>:

<span class="hljs-string">``</span><span class="hljs-string">`javascript
const hashTable = new Map();

hashTable.set('foo', 'bar');
hashTable.set('baz', 'qux');

console.log(hashTable.get('foo')); // 'bar'
console.log(hashTable.get('baz')); // 'qux'</span>
</code></pre>
<p>Just be careful not to accidentally use the same key twice. If you do, the second value will overwrite the first:</p>
<pre><code class="lang-javascript">hashTable.set(<span class="hljs-string">'baz'</span>, <span class="hljs-string">'bar'</span>);

<span class="hljs-built_in">console</span>.log(hashTable.get(<span class="hljs-string">'baz'</span>)); <span class="hljs-comment">// 'bar'</span>
</code></pre>
<p>Hash tables are very fast to access items, because the key is used to directly look up the value. They are not very flexible, though, because the keys have to be unique.</p>
<h3 id="heading-trees">Trees</h3>
<p>Trees are a type of data structure that is used to store data in a hierarchical way. That is, each item has a parent and zero or more children. For example, a tree of numbers might look like this:</p>
<pre><code>  <span class="hljs-number">1</span>
 <span class="hljs-string">/</span> <span class="hljs-string">\</span>
<span class="hljs-number">2</span>   <span class="hljs-number">3</span>
   <span class="hljs-string">/</span> <span class="hljs-string">\</span>
  <span class="hljs-number">4</span>   <span class="hljs-number">5</span>
</code></pre><p>Each node has a value, and a link to another node (or null, if there is no child node).</p>
<p>To access an item in the tree, we just follow the path from the root to the desired node.</p>
<p>Here is an example of how this might be implemented in JavaScript:</p>
<pre><code class="lang-javascript"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Node</span> </span>{
  <span class="hljs-keyword">constructor</span>(value) {
    <span class="hljs-built_in">this</span>.value = value;
    <span class="hljs-built_in">this</span>.child = <span class="hljs-literal">null</span>;
  }
}

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Tree</span> </span>{
  <span class="hljs-keyword">constructor</span>() {
    <span class="hljs-built_in">this</span>.root = <span class="hljs-literal">null</span>;
  }

  <span class="hljs-comment">// add a node to the tree</span>
  addNode(value) {
    <span class="hljs-keyword">const</span> node = <span class="hljs-keyword">new</span> Node(value);

    <span class="hljs-comment">// if the tree is empty, the node is the root node</span>
    <span class="hljs-keyword">if</span> (<span class="hljs-built_in">this</span>.root === <span class="hljs-literal">null</span>) {
      <span class="hljs-built_in">this</span>.root = node;
    } <span class="hljs-keyword">else</span> {
      <span class="hljs-comment">// find the correct place to add the node</span>

      <span class="hljs-comment">// start at the root node</span>
      <span class="hljs-keyword">let</span> current = <span class="hljs-built_in">this</span>.root;

      <span class="hljs-comment">// loop until we find an empty spot</span>
      <span class="hljs-keyword">while</span> (current.child) {
        current = current.child;
      }

      <span class="hljs-comment">// add the node</span>
      current.child = node;
    }
  }

  <span class="hljs-comment">// remove a node from the tree</span>
  removeNode(value) {
    <span class="hljs-keyword">if</span> (<span class="hljs-built_in">this</span>.root === <span class="hljs-literal">null</span>) {
      <span class="hljs-comment">// tree is empty</span>
      <span class="hljs-keyword">return</span>;
    }

    <span class="hljs-comment">// start at the root node</span>
    <span class="hljs-keyword">let</span> current = <span class="hljs-built_in">this</span>.root;

    <span class="hljs-comment">// keep track of the parent node</span>
    <span class="hljs-keyword">let</span> parent = <span class="hljs-literal">null</span>;

    <span class="hljs-comment">// loop until we find the node to remove</span>
    <span class="hljs-keyword">while</span> (current.value !== value) {
      <span class="hljs-comment">// update the parent node</span>
      parent = current;

      <span class="hljs-comment">// move to the child node</span>
      current = current.child;

      <span class="hljs-comment">// if there is no current node, the value is not in the tree</span>
      <span class="hljs-keyword">if</span> (current === <span class="hljs-literal">null</span>) {
        <span class="hljs-keyword">return</span>;
      }
    }

    <span class="hljs-comment">// if we get here, we've found the node to remove</span>

    <span class="hljs-comment">// if the node to remove is the root node, just set the root to null</span>
    <span class="hljs-keyword">if</span> (<span class="hljs-built_in">this</span>.root === current) {
      <span class="hljs-built_in">this</span>.root = <span class="hljs-literal">null</span>;
      <span class="hljs-keyword">return</span>;
    }

    <span class="hljs-comment">// if the node to remove is not the root node,</span>
    <span class="hljs-comment">// we need to find the parent node</span>

    <span class="hljs-comment">// if the node to remove is the parent's only child,</span>
    <span class="hljs-comment">// just set the parent's child to null</span>
    <span class="hljs-keyword">if</span> (parent.child === current) {
      parent.child = <span class="hljs-literal">null</span>;
      <span class="hljs-keyword">return</span>;
    }

    <span class="hljs-comment">// if the node to remove is the parent's first child,</span>
    <span class="hljs-comment">// we need to find the node's next sibling</span>

    <span class="hljs-comment">// start at the parent's first child</span>
    <span class="hljs-keyword">let</span> sibling = parent.child;

    <span class="hljs-comment">// loop until we find the node's next sibling</span>
    <span class="hljs-keyword">while</span> (sibling.child !== current) {
      sibling = sibling.child;
    }

    <span class="hljs-comment">// if we get here, we've found the node's next sibling</span>

    <span class="hljs-comment">// set the node's next sibling to the node's current child</span>
    sibling.child = current.child;
  }

  <span class="hljs-comment">// search for a node in the tree</span>
  search(value) {
    <span class="hljs-keyword">if</span> (<span class="hljs-built_in">this</span>.root === <span class="hljs-literal">null</span>) {
      <span class="hljs-comment">// tree is empty</span>
      <span class="hljs-keyword">return</span> <span class="hljs-literal">null</span>;
    }

    <span class="hljs-comment">// start at the root node</span>
    <span class="hljs-keyword">let</span> current = <span class="hljs-built_in">this</span>.root;

    <span class="hljs-comment">// loop until we find the node or reach the end of the tree</span>
    <span class="hljs-keyword">while</span> (current.value !== value &amp;&amp; current.child) {
      current = current.child;
    }

    <span class="hljs-comment">// if we get here and current.value is not equal to value,</span>
    <span class="hljs-comment">// the node was not found</span>

    <span class="hljs-keyword">return</span> current;
  }
}
</code></pre>
<p>Here's how we would use the Tree class:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> tree = <span class="hljs-keyword">new</span> Tree();

tree.addNode(<span class="hljs-number">1</span>);
tree.addNode(<span class="hljs-number">2</span>);
tree.addNode(<span class="hljs-number">3</span>);
tree.addNode(<span class="hljs-number">4</span>);

tree.search(<span class="hljs-number">3</span>); <span class="hljs-comment">// returns the node with value 3</span>
tree.search(<span class="hljs-number">5</span>); <span class="hljs-comment">// returns null</span>

tree.removeNode(<span class="hljs-number">3</span>); <span class="hljs-comment">// removes the node with value 3</span>
</code></pre>
<p>Trees are very flexible, because we can easily add and remove items. They can be slower to access items, though, because we have to follow the path from the root.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Data structures are important in programming because they provide a way to store and retrieve data efficiently. Without data structures, it would be very difficult to write programs that could manipulate data in a useful way.</p>
<p>I hope you found this article helpful and that you now have a better understanding of how to use data structures in your own code.</p>
<p>Let me know in the comments if you found this article helpful or if you have any questions.</p>
<p>Be sure to follow me for more like this!</p>
]]></content:encoded></item><item><title><![CDATA[Understanding Proxies in JavaScript]]></title><description><![CDATA[If you're looking to dive in to some more advanced JavaScript concepts, the Proxy API is a great place to start! Proxies give you the ability to control how properties are accessed on objects, including getting, setting, and deleting values. In addit...]]></description><link>https://blog.techsavvytravvy.com/understanding-proxies-in-javascript</link><guid isPermaLink="true">https://blog.techsavvytravvy.com/understanding-proxies-in-javascript</guid><category><![CDATA[advanced]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[ES6]]></category><category><![CDATA[guide]]></category><category><![CDATA[General Programming]]></category><dc:creator><![CDATA[trav]]></dc:creator><pubDate>Fri, 22 Jul 2022 13:49:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1658558875356/MJ4HrRmXC.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>If you're looking to dive in to some more advanced JavaScript concepts, the Proxy API is a great place to start! Proxies give you the ability to control how properties are accessed on objects, including getting, setting, and deleting values. In addition, you can use proxies to implement custom behavior for common operations like iteration and assignment.</p>
<p>Proxies are a relatively new feature in JavaScript, and provides a way to create "virtual" objects that can intercept property accesses and perform custom operations.</p>
<h2 id="heading-what-are-proxies">What are Proxies?</h2>
<p>A Proxy is like a middle-man who can sit between you and the thing you're trying to access. You can tell the Proxy what you want to do, and it can either do it for you, stop you from doing it, or do something else entirely.</p>
<p>In JavaScript, objects can have properties that are themselves objects. For example, you might have an object with a property named "foo" that contains another object:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">var</span> obj = {
    <span class="hljs-attr">foo</span>: {
        <span class="hljs-comment">// ...</span>
    }
};
</code></pre>
<p>Proxies provide a way to intercept these property accesses and perform custom operations. In the above example, we could use a proxy to intercept calls to <code>obj.foo</code> and do something else instead:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> proxy = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Proxy</span>(obj, {
    <span class="hljs-attr">get</span>: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">target, property, receiver</span>) </span>{
        <span class="hljs-keyword">if</span> (property == <span class="hljs-string">"foo"</span>) {
            <span class="hljs-comment">// ... do something else</span>
        } <span class="hljs-keyword">else</span> {
            <span class="hljs-comment">// return the default behavior</span>
            <span class="hljs-keyword">return</span> <span class="hljs-built_in">Reflect</span>.get(target, property, receiver);
        }
    }
});
</code></pre>
<p>In this case, we intercept calls to <code>get</code> (which is used to retrieve a property value) and check if the property name is "foo". If it is, we do something else; otherwise, we return the default behavior.</p>
<h2 id="heading-creating-proxies">Creating Proxies</h2>
<p>Proxies are created using the <code>new Proxy()</code> constructor:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> proxy = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Proxy</span>(target, handler);
</code></pre>
<p>The <code>target</code> argument is the object that the proxy will "proxy" for; that is, operations on the proxy will be forwarded to the <code>target</code> object. The <code>handler</code> argument is an object that defines which operations the proxy will intercept.</p>
<h2 id="heading-proxy-handler-methods">Proxy Handler Methods</h2>
<p>The <code>handler</code> object can define any of the following methods:</p>
<ul>
<li><code>get(target, property, receiver)</code>: Called when a property is accessed.</li>
<li><code>set(target, property, value, receiver)</code>: Called when a property is set.</li>
<li><code>has(target, property)</code>: Called when using the <code>in</code> operator.</li>
<li><code>deleteProperty(target, property)</code>: Called when using the <code>delete</code> operator.</li>
<li><code>apply(target, thisArg, argumentsList)</code>: Called when a function is invoked.</li>
<li><code>construct(target, argumentsList, newTarget)</code>: Called when a constructor is invoked.</li>
</ul>
<p>These methods all have the same signature as the corresponding <code>Reflect</code> methods. The <code>Reflect</code> methods are used to perform the default behavior for an operation; if you want to customize the behavior, you can override the corresponding handler method.</p>
<h2 id="heading-example-validating-property-values">Example: Validating Property Values</h2>
<p>In these examples, the JavaScript Proxy API acts like a security guard at a nightclub. It can intercept requests and make sure they are valid before allowing them to pass through.</p>
<p>Let's say we have an object that represents a user's profile, and we want to make sure that the <code>age</code> property is always a positive number. We can do this by creating a proxy for the object, and intercepting calls to <code>set</code>:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> profile = {
    <span class="hljs-attr">name</span>: <span class="hljs-string">"John Doe"</span>,
    <span class="hljs-attr">age</span>: <span class="hljs-number">42</span>
};

<span class="hljs-keyword">const</span> proxy = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Proxy</span>(profile, {
    <span class="hljs-attr">set</span>: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">target, property, value, receiver</span>) </span>{
        <span class="hljs-keyword">if</span> (property == <span class="hljs-string">"age"</span>) {
            <span class="hljs-keyword">if</span> (<span class="hljs-keyword">typeof</span> value != <span class="hljs-string">"number"</span> || value &lt; <span class="hljs-number">0</span>) {
                <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span>(<span class="hljs-string">"Invalid age"</span>);
            }
        }
        <span class="hljs-comment">// return the default behavior</span>
        <span class="hljs-keyword">return</span> <span class="hljs-built_in">Reflect</span>.set(target, property, value, receiver);
    }
});
</code></pre>
<p>Now, if we try to set the <code>age</code> property to an invalid value, we'll get an error:</p>
<pre><code class="lang-javascript">proxy.age = <span class="hljs-string">"42"</span>; <span class="hljs-comment">// Error: Invalid age</span>
</code></pre>
<h2 id="heading-example-logging-property-accesses">Example: Logging Property Accesses</h2>
<p>In this example, we'll create a proxy that logs all property accesses:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> obj = {
    <span class="hljs-attr">foo</span>: <span class="hljs-string">"bar"</span>
};

<span class="hljs-keyword">const</span> proxy = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Proxy</span>(obj, {
    <span class="hljs-attr">get</span>: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">target, property, receiver</span>) </span>{
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">"getting property "</span> + property);
        <span class="hljs-comment">// return the default behavior</span>
        <span class="hljs-keyword">return</span> <span class="hljs-built_in">Reflect</span>.get(target, property, receiver);
    },
    <span class="hljs-attr">set</span>: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">target, property, value, receiver</span>) </span>{
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">"setting property "</span> + property + <span class="hljs-string">" to "</span> + value);
        <span class="hljs-comment">// return the default behavior</span>
        <span class="hljs-keyword">return</span> <span class="hljs-built_in">Reflect</span>.set(target, property, value, receiver);
    }
});
</code></pre>
<p>Now, whenever we access or set a property on <code>proxy</code>, we'll see a message in the console:</p>
<pre><code class="lang-javascript">proxy.foo; <span class="hljs-comment">// getting property foo</span>
proxy.foo = <span class="hljs-string">"baz"</span>; <span class="hljs-comment">// setting property foo to baz</span>
</code></pre>
<h2 id="heading-proxy-revocability">Proxy Revocability</h2>
<p>Proxies are revocable, which means that they can be disabled after they've been created. To do this, we use the <code>Proxy.revocable()</code> method:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> obj = {
    <span class="hljs-attr">foo</span>: <span class="hljs-string">"bar"</span>
};

<span class="hljs-keyword">const</span> revocable = <span class="hljs-built_in">Proxy</span>.revocable(obj, {
    <span class="hljs-attr">get</span>: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">target, property, receiver</span>) </span>{
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">"getting property "</span> + property);
        <span class="hljs-comment">// return the default behavior</span>
        <span class="hljs-keyword">return</span> <span class="hljs-built_in">Reflect</span>.get(target, property, receiver);
    },
});

<span class="hljs-keyword">const</span> proxy = revocable.proxy;
</code></pre>
<p>Now, <code>proxy</code> behaves just like our previous example. We can access and set properties, and we'll see messages in the console:</p>
<pre><code class="lang-javascript">proxy.foo; <span class="hljs-comment">// getting property foo</span>
proxy.foo = <span class="hljs-string">"baz"</span>; <span class="hljs-comment">// setting property foo to baz</span>
</code></pre>
<p>When we're finished with the proxy, we can disable it by calling the <code>revoke()</code> method:</p>
<pre><code class="lang-javascript">revocable.revoke();
</code></pre>
<p>Now, if we try to access or set properties on <code>proxy</code>, we'll get an error:</p>
<pre><code class="lang-javascript">proxy.foo; <span class="hljs-comment">// TypeError: Cannot perform 'get' on a proxy that has been revoked</span>
proxy.foo = <span class="hljs-string">"baz"</span>; <span class="hljs-comment">// TypeError: Cannot perform 'set' on a proxy that has been revoked</span>
</code></pre>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Proxies provide a powerful way to intercept and customize property accesses in JavaScript. I hope this has helped you understand how to create proxies, and how to use them to perform operations such as validating property values and logging property accesses.</p>
<p>Related to Proxies is the incredibly useful Reflect API, so stay follow or signup for an article on that soon.</p>
<p>Let me know in the comments if you liked this or have any questions—be sure to follow me for more like this!</p>
]]></content:encoded></item><item><title><![CDATA[Identifying and Fixing Memory Leaks in JavaScript]]></title><description><![CDATA[We've all been there before—you're testing your site or application in your browser and suddenly it becomes unresponsive, slow, or starts crashing. You may not realize it, but this could be due to a memory leak in your JavaScript code.
So what are me...]]></description><link>https://blog.techsavvytravvy.com/identifying-and-fixing-memory-leaks-in-javascript-1</link><guid isPermaLink="true">https://blog.techsavvytravvy.com/identifying-and-fixing-memory-leaks-in-javascript-1</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[ES6]]></category><category><![CDATA[memory]]></category><category><![CDATA[performance]]></category><category><![CDATA[Memory Leak]]></category><dc:creator><![CDATA[trav]]></dc:creator><pubDate>Thu, 21 Jul 2022 12:36:52 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1658517016286/CJWGDOlz-.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>We've all been there before—you're testing your site or application in your browser and suddenly it becomes unresponsive, slow, or starts crashing. You may not realize it, but this could be due to a memory leak in your JavaScript code.</p>
<p>So what are memory leaks? How do memory leaks happen in JavaScript, and how can you prevent them?</p>
<h2 id="heading-what-are-memory-leaks">What are memory leaks?</h2>
<p>Memory leaks are a type of resource leak that occurs when a computer program fails to release memory after it is no longer needed. Memory leaks may not be serious or even noticeable in some programs, but can cause web browsers to slowly become unresponsive over time.</p>
<h2 id="heading-how-do-memory-leaks-happen-in-javascript">How do memory leaks happen in JavaScript?</h2>
<p>JavaScript memory leaks happen when variables or objects are not properly released after they are no longer needed. This can happen when you forget to call the <code>delete</code> operator on an object, or when you hold onto a reference to an object that is no longer needed.</p>
<h2 id="heading-how-can-i-tell-if-my-javascript-code-has-a-memory-leak">How can I tell if my JavaScript code has a memory leak?</h2>
<p>One of the most frustrating things that can happen when you're working on a JavaScript project is finding a memory leak. Memory leaks can be tough to track down, and they can cause your project to run slowly and eventually crash. But don't despair! There are some tools and techniques you can use to find and fix memory leaks in your code.</p>
<p>The first thing you need to do is identify where the leak is happening. If you're using a web browser, you can use the built-in developer tools to take a heap snapshot. This will give you a list of all the objects that are currently in memory, and how much memory they're using. Take a look at the list of objects and see if there's anything that looks out of place.</p>
<p>Once you've found the general area where the leak is happening, it's time to start digging into the code. Look for any places where you're creating new objects or arrays, but not deleting them when you're finished with them. This is a common cause of memory leaks, because the objects and arrays will continue to stay in memory even after you're finished with them.</p>
<p>There are a few tools that can help you find memory leaks in your JavaScript code:</p>
<ol>
<li><p>The Chrome Developer Tools are a great way to find out what's going on in your web application. Simply open the Developer Tools in your browser, go to the "Memory" tab, and take a look at the "Allocated" and "Used" memory. If the "Used" memory is constantly increasing, then you probably have a memory leak.</p>
</li>
<li><p>Use third party tools.</p>
<p> <a target="_blank" href="https://github.com/nolanlawson/fuite">fuite</a> - Fuite uses Puppeteer with Chrome to automate memory leak testing.</p>
<p> <a target="_blank" href="https://github.com/bnoordhuis/node-heapdump">heapdump</a> - This package can generate a snapshot of your application's memory usage, which can be analyzed to find out where the leaked memory is being allocated.</p>
</li>
<li><p>You can also use a profiler to find out what functions in your code are using the most memory. This type of profiler, called a "sampling profiler", takes periodic snapshots of your application's memory usage. By analyzing these snapshots, you can identify which functions are using the most memory and where the leaks are happening.</p>
</li>
</ol>
<h2 id="heading-how-can-i-fix-a-memory-leak-in-my-javascript-code">How can I fix a memory leak in my JavaScript code?</h2>
<p>There are many ways to fix a memory leak in your JavaScript code. One obvious way is to identify the leaking variable or object and manually call the <code>delete</code> operator on it. Another way is to identify the leaking variable or object and nullify it.</p>
<p>Here are a few more ways to resolve memory leaks:</p>
<ol>
<li><p>Remove unused event listeners: If you're no longer using a certain event listener, be sure to remove it using the <code>removeEventListener()</code> method. This will ensure that it is no longer taking up memory.</p>
</li>
<li><p>Use WeakMaps: WeakMaps are a type of data structure that can be used to store key-value pairs, but with the caveat that the keys must be objects. This is important because it means that the keys can be garbage collected if there are no other references to them. This can be useful for preventing memory leaks if you're using dictionaries to store data that you may not need anymore.</p>
</li>
<li><p>Avoid circular references: Circular references occur when two objects reference each other, creating a "loop". This can lead to memory leaks because the two objects will never be garbage collected as long as they reference each other. To avoid this, make sure that your objects only reference other objects that they absolutely need to.</p>
</li>
</ol>
<p>If you're using a library or framework, you may also be able to find a way to configure it to automatically release memory when it's no longer needed. For example, React has a <code>shouldComponentUpdate</code> lifecycle hook that allows you to prevent a component from re-rendering if its props have not changed. This can help to prevent memory leaks by automatically releasing memory when it's no longer needed.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>I hope this article has helped you to understand what memory leaks are, how they happen in JavaScript, and how you can identify and fix them.</p>
<p>Learn more about memory leaks by reading <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Memory_Management">MDN's article on Memory Management</a>.</p>
<p>If you have any questions, feel free to ask in the comments.</p>
<p>Be sure to follow me for more like this!</p>
]]></content:encoded></item><item><title><![CDATA[Beginner's Guide to Deno]]></title><description><![CDATA[So you want to learn about Deno, the new JavaScript runtime? Well, you've come to the right place! This guide will teach you everything you need to know about Deno.
What is Deno?
Deno is a runtime for JavaScript, TypeScript, and WebAssembly that is b...]]></description><link>https://blog.techsavvytravvy.com/beginners-guide-to-deno</link><guid isPermaLink="true">https://blog.techsavvytravvy.com/beginners-guide-to-deno</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[Deno]]></category><category><![CDATA[Node.js]]></category><category><![CDATA[runtime]]></category><category><![CDATA[ES6]]></category><dc:creator><![CDATA[trav]]></dc:creator><pubDate>Wed, 20 Jul 2022 15:45:53 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1658331855771/E1GJoFXRM.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>So you want to learn about Deno, the new JavaScript runtime? Well, you've come to the right place! This guide will teach you everything you need to know about Deno.</p>
<h2 id="heading-what-is-deno">What is Deno?</h2>
<p>Deno is a runtime for JavaScript, TypeScript, and WebAssembly that is based on the V8 JavaScript engine and the Rust programming language. It was created by Ryan Dahl, the original creator of Node.js, to remedy some the regrets he had when making Node.</p>
<h2 id="heading-why-should-i-use-deno">Why Should I Use Deno?</h2>
<p>Here are a few reasons why you might want to use Deno:</p>
<ol>
<li><p>Secure by default. This means that it uses a sandbox to prevent code execution from outside the Deno process, and all network and file system operations are sandboxed by default.</p>
</li>
<li><p>Built-in support for TypeScript.</p>
</li>
<li><p>Ships with a set of standard libraries, which are written in TypeScript and are located in the Deno namespace. This means that you don't have to install third-party libraries to use Deno.</p>
</li>
<li><p>A plugin system that allows you to import third-party libraries as plugins. This means that you can import only the functionality that you need, and the plugin is sandboxed and can't access the Deno process.</p>
</li>
<li><p>A built-in test runner, which makes it easy to write and run tests for your Deno applications.</p>
</li>
<li><p>Open source and released under the MIT License.</p>
</li>
</ol>
<h2 id="heading-getting-started">Getting Started</h2>
<p>Now that you know a little bit about Deno, let's get started!</p>
<p>First, you need to install Deno. The easiest way to do this is in with curl:</p>
<pre><code class="lang-zsh">curl -fsSL https://deno.land/x/install/install.sh | sh
</code></pre>
<p>If you're on Mac, you can install Deno with a package manager like <a target="_blank" href="https://brew.sh/">Homebrew</a>.</p>
<pre><code class="lang-zsh">brew install deno
</code></pre>
<p>Now that you have Deno installed, you can run Deno programs with the <code>deno</code> command.</p>
<pre><code class="lang-zsh">deno run https://deno.land/std/examples/cat.ts
</code></pre>
<p>This will fetch and run the <code>cat.ts</code> program from the <a target="_blank" href="https://deno.land/std/">Deno Standard Library</a>. The Deno Standard Library contains a collection of reusable Deno programs.</p>
<p>Now that you know how to run Deno programs, let's write our own! Create a file called <code>hello.ts</code> and add the following code to it:</p>
<pre><code class="lang-typescript"><span class="hljs-built_in">console</span>.log(<span class="hljs-string">"Hello, world!"</span>);
</code></pre>
<p>You can run this program with the <code>deno</code> command:</p>
<pre><code class="lang-bash">deno run hello.ts
</code></pre>
<p>You should see the output <code>Hello, world!</code>.</p>
<p>That's it! You've written your first Deno program!</p>
<h2 id="heading-writing-deno-programs">Writing Deno Programs</h2>
<p>Now that you know the basics of Deno, let's dive a bit deeper. In this section, we'll learn about some of the more advanced concepts in Deno.</p>
<h3 id="heading-scripts-and-modules">Scripts and Modules</h3>
<p>In Deno, there are two ways to structure your code: scripts and modules.</p>
<p>Scripts are simple programs that are run with the <code>deno</code> command. Modules are program modules that can be imported by other programs.</p>
<p>Let's see an example of each.</p>
<p>First, let's create a script. Create a file called <code>script.ts</code> and add the following code to it:</p>
<pre><code class="lang-typescript"><span class="hljs-built_in">console</span>.log(<span class="hljs-string">"This is a script."</span>);
</code></pre>
<p>You can run this script with the <code>deno</code> command:</p>
<pre><code class="lang-bash">deno run script.ts
</code></pre>
<p>Next, let's create a module. Create a file called <code>module.ts</code> and add the following code to it:</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">export</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">hello</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">"Hello, world!"</span>);
}
</code></pre>
<p>This module exports a single function called <code>hello</code>. We can import this function into another program and call it.</p>
<p>Create a file called <code>main.ts</code> and add the following code to it:</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">import</span> { hello } <span class="hljs-keyword">from</span> <span class="hljs-string">"./module.ts"</span>;

hello();
</code></pre>
<p>This program imports the <code>hello</code> function from the <code>module.ts</code> module and calls it.</p>
<p>You can run this program with the <code>deno</code> command:</p>
<pre><code class="lang-bash">deno run main.ts
</code></pre>
<p>You should see the output <code>Hello, world!</code>.</p>
<h3 id="heading-libraries">Libraries</h3>
<p>In Deno, libraries are collections of modules that are bundled together. Libraries can be published to <a target="_blank" href="https://deno.land/x">Deno's Registry</a> so that they can be easily reused by others.</p>
<p>Let's see an example of how to use a library. We're going to use the <a target="_blank" href="https://deno.land/x/gravatar/">gravatar</a> library to generate Gravatar URLs.</p>
<p>Create a file called <code>main.ts</code> and add the following code to it:</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">import</span> { gravatar } <span class="hljs-keyword">from</span> <span class="hljs-string">"https://deno.land/x/gravatar/mod.ts"</span>;

<span class="hljs-built_in">console</span>.log(gravatar(<span class="hljs-string">"example@example.com"</span>));
</code></pre>
<p>This program imports the <code>gravatar</code> function from the <code>gravatar</code> library and calls it with the email address <code>example@example.com</code>.</p>
<p>You can run this program with the <code>deno</code> command:</p>
<pre><code class="lang-bash">deno run main.ts
</code></pre>
<p>You should see the output <code>https://www.gravatar.com/avatar/00000000000000000000000000000000?d=mp&amp;s=80</code>.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>You should now have a good understanding of Deno and be able to start writing your own programs. For more information, check out the <a target="_blank" href="https://deno.land/manual">Deno documentation</a>.</p>
<p>Let me know in the comments if this was helpful or if you have any questions.</p>
<p>Be sure to follow me for more like this!</p>
]]></content:encoded></item><item><title><![CDATA[Beginner's Guide to GraphQL]]></title><description><![CDATA[If you're new to GraphQL, you might be wondering what all the fuss is about. GraphQL is a query language for APIs that allows developers to request data in a more efficient way. In this article, we'll take a look at what GraphQL is, how it works, and...]]></description><link>https://blog.techsavvytravvy.com/beginners-guide-to-graphql</link><guid isPermaLink="true">https://blog.techsavvytravvy.com/beginners-guide-to-graphql</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[Node.js]]></category><category><![CDATA[GraphQL]]></category><category><![CDATA[guide]]></category><dc:creator><![CDATA[trav]]></dc:creator><pubDate>Wed, 20 Jul 2022 14:26:48 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1658327133847/XwJhPxk7j.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>If you're new to GraphQL, you might be wondering what all the fuss is about. GraphQL is a query language for APIs that allows developers to request data in a more efficient way. In this article, we'll take a look at what GraphQL is, how it works, and why you should be using it.</p>
<p>GraphQL is a query language for APIs that was developed by Facebook. It enables developers to request data in a more efficient way than traditional REST APIs. GraphQL is also more flexible, allowing developers to query for specific fields and data types.</p>
<p>GraphQL is slowly becoming the standard for API development, and more and more companies are adopting it. If you're not using GraphQL yet, now is the time to start.</p>
<h2 id="heading-what-is-graphql">What is GraphQL?</h2>
<p>GraphQL is a query language for APIs that was developed by Facebook. It enables developers to request data in a more efficient way than traditional REST APIs. GraphQL is also more flexible, allowing developers to query for specific fields and data types.</p>
<p>GraphQL is slowly becoming the standard for API development, and more and more companies are adopting it. If you're not using GraphQL yet, now is the time to start.</p>
<h2 id="heading-how-does-graphql-work">How does GraphQL work?</h2>
<p>GraphQL queries are made up of three parts: fields, types, and arguments.</p>
<p>Fields are the specific data that you're requesting. For example, if you're querying for a list of users, you might specify the fields "id", "name", and "email".</p>
<p>Types are the data types of the fields that you're requesting. GraphQL has a number of built-in types, such as "Int", "Float", "String", and "Boolean".</p>
<p>Arguments are used to filter the data that you're requesting. For example, you might use an argument to only query for users who have a certain "id" or "name".</p>
<h2 id="heading-why-should-i-use-graphql">Why should I use GraphQL?</h2>
<p>There are a number of reasons to use GraphQL.</p>
<p>First, GraphQL is more efficient than traditional REST APIs. This is because you can specify exactly the data that you want, and you don't have to make multiple requests to different URLs to get the data that you need.</p>
<p>Second, GraphQL is more flexible. With REST APIs, you're limited to the data that's returned from the URL that you request. With GraphQL, you can specify exactly the fields and data types that you want.</p>
<p>Third, GraphQL is slowly becoming the standard for API development. more and more companies are adopting GraphQL, so it's a good idea to get ahead of the curve and start using it now.</p>
<h2 id="heading-using-graphql-with-nodejs">Using GraphQL with Node.js</h2>
<p>Now that we've seen what GraphQL is and how it works, let's take a look at how to use GraphQL with Node.js.</p>
<p>The first thing you'll need to do is install the "graphql" npm package.</p>
<pre><code><span class="hljs-built_in">npm</span> install graphql
</code></pre><p>Next, you'll need to create a file called "schema.js" and define your GraphQL schema.</p>
<pre><code>const {
  GraphQLObjectType,
  GraphQLString,
  GraphQLSchema
} <span class="hljs-operator">=</span> <span class="hljs-built_in">require</span>(<span class="hljs-string">'graphql'</span>);

const UserType <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> GraphQLObjectType({
  name: <span class="hljs-string">'User'</span>,
  fields: {
    id: { <span class="hljs-keyword">type</span>: GraphQLString },
    name: { <span class="hljs-keyword">type</span>: GraphQLString },
    email: { <span class="hljs-keyword">type</span>: GraphQLString },
  }
});

const QueryType <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> GraphQLObjectType({
  name: <span class="hljs-string">'Query'</span>,
  fields: {
    user: {
      <span class="hljs-keyword">type</span>: UserType,
      args: {
        id: { <span class="hljs-keyword">type</span>: GraphQLString }
      },
      resolve: (root, args) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {
        <span class="hljs-keyword">return</span> {
          id: args.id,
          name: <span class="hljs-string">'User '</span> <span class="hljs-operator">+</span> args.id,
          email: args.id <span class="hljs-operator">+</span> <span class="hljs-string">'@example.com'</span>,
        };
      }
    }
  }
});

module.exports <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> GraphQLSchema({
  query: QueryType
});
</code></pre><p>In this file, we've defined a GraphQL schema with a "User" type and a "Query" type. The "Query" type defines a "user" field, which accepts an "id" argument and returns a "User" type.</p>
<p>Next, we need to create a file called "index.js" and write some code to execute our GraphQL query.</p>
<pre><code>const { graphql, buildSchema } <span class="hljs-operator">=</span> <span class="hljs-built_in">require</span>(<span class="hljs-string">'graphql'</span>);

const schema <span class="hljs-operator">=</span> <span class="hljs-built_in">require</span>(<span class="hljs-string">'./schema'</span>);

graphql(schema, <span class="hljs-string">'{ user(id: "1") { name, email } }'</span>).then((result) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {
  console.log(result);
});
</code></pre><p>In this file, we've imported the "graphql" and "buildSchema" functions from the "graphql" npm package. We've also imported our "schema" module.</p>
<p>Finally, we've used the "graphql" function to execute our GraphQL query. This function accepts our schema and a GraphQL query string. The query string defines the data that we want to fetch. In this case, we're fetching the "name" and "email" fields for the user with an "id" of "1".</p>
<p>If we run this file, we should see the following output:</p>
<pre><code>{
  <span class="hljs-attribute">data</span>: {
    <span class="hljs-attribute">user</span>: {
      <span class="hljs-attribute">name</span>: <span class="hljs-string">'User 1'</span>,
      <span class="hljs-attribute">email</span>: <span class="hljs-string">'1@example.com'</span>
    }
  }
}
</code></pre><h2 id="heading-conclusion">Conclusion</h2>
<p>In this article, we've taken a look at what GraphQL is, how it works, and why you should be using it. We've also seen how to use GraphQL with Node.js.</p>
<p>If you're not using GraphQL yet, I highly encourage you to give it a try. It's a great way to make your API development more efficient and flexible.</p>
<p>Let me know if you found this article helpful in the comments or if you have any questions.</p>
<p>Be sure to follow me for more like this!</p>
]]></content:encoded></item><item><title><![CDATA[Beginner's Guide to TypeScript]]></title><description><![CDATA[If you're new to TypeScript and want to know more then you've come to the right place!
TypeScript was created to relieve some of the pain-points of JavaScript. Using TypeScript can help you avoid bugs you would otherwise encounter when writing regula...]]></description><link>https://blog.techsavvytravvy.com/beginners-guide-to-typescript</link><guid isPermaLink="true">https://blog.techsavvytravvy.com/beginners-guide-to-typescript</guid><category><![CDATA[TypeScript]]></category><category><![CDATA[beginner]]></category><category><![CDATA[guide]]></category><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[trav]]></dc:creator><pubDate>Wed, 20 Jul 2022 14:12:03 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1658326219963/oZo7n6_gU.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>If you're new to TypeScript and want to know more then you've come to the right place!</p>
<p>TypeScript was created to relieve some of the pain-points of JavaScript. Using TypeScript can help you avoid bugs you would otherwise encounter when writing regular JS. It is also Open Source, and has wide adoption and support.</p>
<p>This guide includes everything you need to get started with TypeScript, and nothing you don't.</p>
<h2 id="heading-what-is-typescript">What is TypeScript?</h2>
<p>TypeScript is a programming language that is a typed superset of JavaScript. That means that it contains all of the functionality of JavaScript, but with additional features that make it more powerful and easier to use. TypeScript is compiled to plain JavaScript, so it can be used in any JavaScript environment.</p>
<h2 id="heading-why-use-typescript">Why Use TypeScript?</h2>
<p>TypeScript is a great way to improve your code. It can catch errors and help you write more maintainable code.</p>
<p>TypeScript offers developers a number of benefits, including:</p>
<ol>
<li><p>TypeScript provides static type checking. This can help you find bugs in your code more easily.</p>
</li>
<li><p>TypeScript code can be compiled to JavaScript code that runs on any browser or platform. The compiling process also allows developers to catch errors before runtime.</p>
</li>
<li><p>TypeScript comes with a number of tools that make it easy to work with, including an interactive shell and a compiler.</p>
</li>
</ol>
<h2 id="heading-getting-started">Getting Started</h2>
<p>To get started with TypeScript, you will need to install it. The easiest way to do this is through <a target="_blank" href="https://www.npmjs.com/">npm</a>.</p>
<p>Once you have TypeScript installed, you can compile TypeScript files using the <code>tsc</code> command. This will generate a corresponding JavaScript file.</p>
<pre><code><span class="hljs-selector-tag">tsc</span> <span class="hljs-selector-tag">filename</span><span class="hljs-selector-class">.ts</span>
</code></pre><p>You can also use the <code>-w</code> flag to watch for changes and automatically recompile your files.</p>
<pre><code><span class="hljs-selector-tag">tsc</span> <span class="hljs-selector-tag">-w</span> <span class="hljs-selector-tag">filename</span><span class="hljs-selector-class">.ts</span>
</code></pre><h2 id="heading-basic-types">Basic Types</h2>
<p>TypeScript offers a number of basic types that you can use to annotate your variables.</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">let</span> foo: <span class="hljs-built_in">string</span> = <span class="hljs-string">"bar"</span>;
<span class="hljs-keyword">let</span> baz: <span class="hljs-built_in">number</span> = <span class="hljs-number">42</span>;
<span class="hljs-keyword">let</span> qux: <span class="hljs-built_in">boolean</span> = <span class="hljs-literal">true</span>;
</code></pre>
<p>You can also use the <code>any</code> type if you don't want to annotate your variables, though it's not recommended.</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">let</span> foo: <span class="hljs-built_in">any</span> = <span class="hljs-string">"bar"</span>;
<span class="hljs-keyword">let</span> baz: <span class="hljs-built_in">any</span> = <span class="hljs-number">42</span>;
<span class="hljs-keyword">let</span> qux: <span class="hljs-built_in">any</span> = <span class="hljs-literal">true</span>;
</code></pre>
<h2 id="heading-interfaces">Interfaces</h2>
<p>Interfaces are a powerful way to define contracts in your code. They can be used to define the shape of objects and functions.</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">interface</span> Point {
  x: <span class="hljs-built_in">number</span>;
  y: <span class="hljs-built_in">number</span>;
}

<span class="hljs-keyword">let</span> p: Point = { x: <span class="hljs-number">0</span>, y: <span class="hljs-number">0</span> };
</code></pre>
<p>You can also use interfaces to define the types of function parameters and return values.</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">interface</span> Point {
  x: <span class="hljs-built_in">number</span>;
  y: <span class="hljs-built_in">number</span>;
}

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">addPoints</span>(<span class="hljs-params">p1: Point, p2: Point</span>): <span class="hljs-title">Point</span> </span>{
  <span class="hljs-keyword">return</span> { x: p1.x + p2.x, y: p1.y + p2.y };
}

<span class="hljs-keyword">let</span> p1: Point = { x: <span class="hljs-number">0</span>, y: <span class="hljs-number">0</span> };
<span class="hljs-keyword">let</span> p2: Point = { x: <span class="hljs-number">1</span>, y: <span class="hljs-number">1</span> };

<span class="hljs-keyword">let</span> p3: Point = addPoints(p1, p2);
</code></pre>
<h2 id="heading-classes">Classes</h2>
<p>Classes are a way to encapsulate data and behavior. They can be used to define types and create objects.</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">class</span> Point {
  x: <span class="hljs-built_in">number</span>;
  y: <span class="hljs-built_in">number</span>;

  <span class="hljs-keyword">constructor</span>(<span class="hljs-params">x: <span class="hljs-built_in">number</span>, y: <span class="hljs-built_in">number</span></span>) {
    <span class="hljs-built_in">this</span>.x = x;
    <span class="hljs-built_in">this</span>.y = y;
  }

  add(p: Point) {
    <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> Point(<span class="hljs-built_in">this</span>.x + p.x, <span class="hljs-built_in">this</span>.y + p.y);
  }
}

<span class="hljs-keyword">let</span> p1: Point = <span class="hljs-keyword">new</span> Point(<span class="hljs-number">0</span>, <span class="hljs-number">0</span>);
<span class="hljs-keyword">let</span> p2: Point = <span class="hljs-keyword">new</span> Point(<span class="hljs-number">1</span>, <span class="hljs-number">1</span>);

<span class="hljs-keyword">let</span> p3: Point = p1.add(p2);
</code></pre>
<h2 id="heading-modules">Modules</h2>
<p>Modules are a way to organize your code. They can be used to define types and encapsulate behavior.</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">module</span> MyModule {
  <span class="hljs-keyword">export</span> <span class="hljs-keyword">class</span> Point {
    x: <span class="hljs-built_in">number</span>;
    y: <span class="hljs-built_in">number</span>;

    <span class="hljs-keyword">constructor</span>(<span class="hljs-params">x: <span class="hljs-built_in">number</span>, y: <span class="hljs-built_in">number</span></span>) {
      <span class="hljs-built_in">this</span>.x = x;
      <span class="hljs-built_in">this</span>.y = y;
    }

    add(p: Point) {
      <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> Point(<span class="hljs-built_in">this</span>.x + p.x, <span class="hljs-built_in">this</span>.y + p.y);
    }
  }
}

<span class="hljs-keyword">let</span> p1: MyModule.Point = <span class="hljs-keyword">new</span> MyModule.Point(<span class="hljs-number">0</span>, <span class="hljs-number">0</span>);
<span class="hljs-keyword">let</span> p2: MyModule.Point = <span class="hljs-keyword">new</span> MyModule.Point(<span class="hljs-number">1</span>, <span class="hljs-number">1</span>);

<span class="hljs-keyword">let</span> p3: MyModule.Point = p1.add(p2);
</code></pre>
<h2 id="heading-decorators">Decorators</h2>
<p>Decorators are a way to add metadata to your code. They can be used to annotate classes, properties, and methods.</p>
<pre><code class="lang-typescript"><span class="hljs-meta">@Component</span>({
  selector: <span class="hljs-string">'my-component'</span>,
  template: <span class="hljs-string">'&lt;div&gt;Hello, world!&lt;/div&gt;'</span>
})
<span class="hljs-keyword">class</span> MyComponent {}
</code></pre>
<h2 id="heading-thats-all-folks">That's All, Folks!</h2>
<p>That's all you need to know to get started with TypeScript. For more information, check out the <a target="_blank" href="https://www.typescriptlang.org/docs/handbook/2/everyday-types.html">TypeScript Handbook</a>.</p>
<p>Let me know in the comments if this was helpful or if you have any questions.</p>
<p>Be sure to follow me for more like this!</p>
]]></content:encoded></item></channel></rss>