<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:media="http://search.yahoo.com/mrss/"><channel><title><![CDATA[Future Studio]]></title><description><![CDATA[Skyrocket in Android and Node.js! Build up your knowledge in modern Android and Node.js backend development.]]></description><link>http://futurestud.io/blog/</link><generator>Ghost 0.11</generator><lastBuildDate>Tue, 07 Apr 2026 08:09:45 GMT</lastBuildDate><atom:link href="http://futurestud.io/blog/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[grep — Search in Selected Files]]></title><description><![CDATA[<p>grep is a powerful tool on Linux and UNIX-based operating systems. It searches for patterns in files and is flexible enough to search through multiple files. You may select a set of files manually or use a glob pattern to find the files to grep on.</p>

<p>This tutorial shows you</p>]]></description><link>http://futurestud.io/blog/grep-search-in-selected-files/</link><guid isPermaLink="false">0e5babaa-b2c8-40a6-9af0-156aa0857504</guid><category><![CDATA[grep]]></category><category><![CDATA[Server]]></category><category><![CDATA[Ubuntu]]></category><category><![CDATA[Debian]]></category><dc:creator><![CDATA[Marcus Pöhls]]></dc:creator><pubDate>Thu, 10 Apr 2025 07:00:00 GMT</pubDate><content:encoded><![CDATA[<p>grep is a powerful tool on Linux and UNIX-based operating systems. It searches for patterns in files and is flexible enough to search through multiple files. You may select a set of files manually or use a glob pattern to find the files to grep on.</p>

<p>This tutorial shows you how to search a pattern in multiple files using grep.</p>



<h2 id="searchinselectedfileswithgrep">Search in Selected Files with grep</h2>

<p>You can select specific files and pass them as arguments to grep when searching for patterns. The selected files can be of different file types. You may combine a log file and a language-specific file, like the <code>package.json</code>:</p>

<pre><code class="language-bash">grep "pattern" storage/logs/app.log package.json  
</code></pre>

<h2 id="searchinaspecifictypeoffileswithgrep">Search in a Specific Type of Files with grep</h2>

<p>You may not know all the files in a directory and need a dynamic approach to select the files in which you want to search for the keyword. Use a glob pattern with grep to let the tool find all files matching the pattern.  </p>

<pre><code class="language-bash">grep "pattern" storage/logs/*.log  
</code></pre>

<p>The output will have the file name as a prefix of the matching line. Everything after the file name is the matching content found in the related file.</p>

<p>Here’s a preview of how the results will look like:</p>

<pre><code class="language-bash">$ grep "pattern" storage/logs/*.log
storage/logs/app.log:{"hostname":"55ec743122e6", …}  
storage/logs/cms.log:{"hostname":"12ab554433f7", …}  
</code></pre>

<h2 id="searchrecursivelyinfilesofagiventypewithgrep">Search Recursively in Files of a Given Type with grep</h2>

<p>You may add flags to grep when searching through files. For example, if you want to recursively find matches in your JavaScript files use the <code>--recursive</code> flag and a glob pattern for the file path.</p>

<p>Here’s a sample call for that:</p>

<pre><code class="language-bash">grep -r "pattern" src/**/*.js  
</code></pre>

<p>Here’s a preview of how the results are printed. Notice that the output contains the line’s indention as well as comments.</p>

<pre><code class="language-bash">src/utils/index.js:    //     you may use a different pattern here  
src/database/driver.js:   console.log('the b-tree pattern works nicely')  
</code></pre>

<p>That’s it!</p>]]></content:encoded></item><item><title><![CDATA[JavaScript — How to Check if a Value is a ULID]]></title><description><![CDATA[<p>We’re using Universally Unique Lexicographically Sortable Identifier (ULID) in our projects to identify entities. ULIDs are unique, sortable identifiers similar to UUIDs. The claim that ULIDs are better than UUIDs is that they are sortable, keeping a monotonic sort order, encoded as a 26-character string (36 characters for UUIDs)</p>]]></description><link>http://futurestud.io/blog/javascript-how-to-check-if-a-value-is-a-ulid/</link><guid isPermaLink="false">7c62231f-10b3-4119-aa29-a20759486c7d</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[TypeScript]]></category><category><![CDATA[Node.js]]></category><dc:creator><![CDATA[Marcus Pöhls]]></dc:creator><pubDate>Thu, 03 Apr 2025 07:00:00 GMT</pubDate><content:encoded><![CDATA[<p>We’re using Universally Unique Lexicographically Sortable Identifier (ULID) in our projects to identify entities. ULIDs are unique, sortable identifiers similar to UUIDs. The claim that ULIDs are better than UUIDs is that they are sortable, keeping a monotonic sort order, encoded as a 26-character string (36 characters for UUIDs), and more.</p>

<p>You may need to detect whether a given value is a ULID string as opposed to a string with no specific meaning. This tutorial shows you how to detect whether a string is a ULID.</p>



<h2 id="detectifastringvalueisaulidinjavascript">Detect if a String Value is a ULID in JavaScript</h2>

<p>ULIDs follow a strict pattern by consisting of numbers and uppercase letters and always being 26 characters long. We can use this strict format to create a regular expression to test a given input value.</p>

<p>Here’s a helper function to determine whether a given value is a ULID:</p>

<pre><code class="language-js">const ulidPattern = /^[0-9A-HJKMNP-TV-Z]{26}$/;

/**
 * Determine whether the given `value` is a ULID.
 *
 * @param {string} value
 *
 * @returns {boolean}
 */
function isUlid(value) {  
  if (typeof value !== 'string') {
    throw new TypeError(`Invalid value passed to isUlid: expected string, received ${typeof value}`);
  }

  return ulidPattern.test(value);
}
</code></pre>

<p>That’s it!</p>]]></content:encoded></item><item><title><![CDATA[grep — Search in Multiple Log Files]]></title><description><![CDATA[<p>Bugs in a production environment are stressful. The search for context information typically starts by searching the log files. It can be tedious to find the context you’re looking for in (rotated) log files or you’re pushing a large amount of data to your logs.</p>

<p>A nice thing</p>]]></description><link>http://futurestud.io/blog/grep-search-in-multiple-log-files/</link><guid isPermaLink="false">1808e453-ab97-4028-9d9e-a6844cb75531</guid><category><![CDATA[grep]]></category><category><![CDATA[Server]]></category><category><![CDATA[Ubuntu]]></category><category><![CDATA[Debian]]></category><dc:creator><![CDATA[Marcus Pöhls]]></dc:creator><pubDate>Thu, 27 Mar 2025 08:00:00 GMT</pubDate><content:encoded><![CDATA[<p>Bugs in a production environment are stressful. The search for context information typically starts by searching the log files. It can be tedious to find the context you’re looking for in (rotated) log files or you’re pushing a large amount of data to your logs.</p>

<p>A nice thing about grep is that it can search for a pattern in multiple files at the same time. Simultaneously search in selected files or use a glob pattern that resolves all files for you. This tutorial shows you how to search in multiple log files using grep.</p>



<h2 id="searchinselectedlogfileswithgrep">Search in Selected Log Files with grep</h2>

<p>grep allows you to search for a pattern in more than one file. You may search in selected log files if your application sends logs to different files. For example, you may search your default <code>app.log</code> and an extra <code>delete-audit.log</code> file. Add your selected files as separate arguments to grep:</p>

<pre><code class="language-bash">grep "pattern" storage/logs/app.log storage/logs/delete-audit.log  
</code></pre>

<h2 id="searchinalllogfileswithgrep">Search in all <code>.log</code> Files with grep</h2>

<p>You can also use a glob pattern to search within all files having the <code>.log</code> file extension. The following line searches for the given pattern in all log files within the <code>storage/logs</code> directory. It won’t search through subdirectories and stay on the selected directory’s level to pick the files:</p>

<pre><code class="language-bash">grep "pattern" storage/logs/*.log  
</code></pre>

<h2 id="examples">Examples</h2>

<p>Here’s a sample output of how grep prints the matches to the console. Notice that a matching line is printed with the prefixed log file name. This helps you detect what log file could have more details:</p>

<pre><code class="language-bash">$ grep "request" storage/logs/*.log
storage/logs/app.log:INFO: ======= request finished successful ======&gt; {"took":"0.052s","status_code":200}  
storage/logs/delete-audit.log:DEBUG: User deletion requested {"userId":"1"}  
storage/logs/delete-audit.log:DEBUG: User successfully deleted {"userId":"1"}  
</code></pre>

<p>That’s it!</p>]]></content:encoded></item><item><title><![CDATA[grep — Search all Files in a Directory (Non-Recursively)]]></title><description><![CDATA[<p>grep is a powerful tool for searching for a pattern in files. You can search in a single file, all directory files, or <a href="https://futurestud.io/tutorials/grep-search-recursive-in-subdirectories">recursively through all files in a directory</a>.</p>

<p>A use case to search through all files in a directory is finding information in application log files. You may</p>]]></description><link>http://futurestud.io/blog/grep-search-all-files-in-a-directory-non-recursively/</link><guid isPermaLink="false">20d3a4f3-f71b-448a-a38d-c86a246e7e15</guid><category><![CDATA[grep]]></category><category><![CDATA[Server]]></category><category><![CDATA[Ubuntu]]></category><category><![CDATA[Debian]]></category><dc:creator><![CDATA[Marcus Pöhls]]></dc:creator><pubDate>Thu, 20 Mar 2025 08:00:00 GMT</pubDate><content:encoded><![CDATA[<p>grep is a powerful tool for searching for a pattern in files. You can search in a single file, all directory files, or <a href="https://futurestud.io/tutorials/grep-search-recursive-in-subdirectories">recursively through all files in a directory</a>.</p>

<p>A use case to search through all files in a directory is finding information in application log files. You may want to retrieve more context information about a request and that could involve multiple files. This tutorial shows you how to search non-recursively through all files in a directory.</p>



<h2 id="searchnonrecursivelyallfilesinadirectorywithgrep">Search Non-Recursively all Files in a Directory with grep</h2>

<p>You may provide a file or directory path to grep and it starts its search. A thing to keep in mind is that grep expects a file path by default. When passing a directory path to grep it will tell you that the path is a directory and you need to be more specific on what to search for:</p>

<pre><code class="language-bash">$ grep "hostname" storage/logs
grep: data/logs: Is a directory  
</code></pre>

<h3 id="greppingallfilesinadirectory">Grepping all Files in a Directory</h3>

<p>Use glob patterns in the directory path to tell grep to search all files in a given directory. A glob pattern representing all files in a directory is the <code>*</code>.</p>

<p>Here’s a code snippet showing you how to search for a pattern in the current directory:</p>

<pre><code class="language-bash"># search through all files in the current directory
grep "pattern" *  
</code></pre>

<p>You may also search in a nested directory and append the <code>*</code> to the path provided to grep:</p>

<pre><code class="language-bash"># search through all log files
grep "pattern" storage/logs/*  
</code></pre>

<p>That’s it!</p>

<hr>

<h4 id="mentionedresources">Mentioned Resources</h4>

<ul>
<li>Future Studio tutorial on <a href="https://futurestud.io/tutorials/grep-search-recursive-in-subdirectories">searching recursively through all files in a directory</a></li>
</ul>]]></content:encoded></item><item><title><![CDATA[grep — Search Recursive in Subdirectories]]></title><description><![CDATA[<p>grep allows you to search for a pattern in a file’s content. This tool searches even through large files, like application logs. You may also search recursively for a pattern in files of a directory and related subdirectories.</p>

<p>This tutorial shows you how to run a recursive search on</p>]]></description><link>http://futurestud.io/blog/grep-search-recursive-in-subdirectories/</link><guid isPermaLink="false">9712da5b-05b0-40f5-9e18-971cc74870fa</guid><category><![CDATA[grep]]></category><category><![CDATA[Debian]]></category><category><![CDATA[Ubuntu]]></category><category><![CDATA[Server]]></category><dc:creator><![CDATA[Marcus Pöhls]]></dc:creator><pubDate>Thu, 13 Mar 2025 08:00:00 GMT</pubDate><content:encoded><![CDATA[<p>grep allows you to search for a pattern in a file’s content. This tool searches even through large files, like application logs. You may also search recursively for a pattern in files of a directory and related subdirectories.</p>

<p>This tutorial shows you how to run a recursive search on all files in a directory.</p>



<h2 id="searchrecursivelyinsubdirectorieswithgrep">Search Recursively in Subdirectories with grep</h2>

<p>You can’t pass a directory path to grep. You’ll see an error message that your given path is a directory:</p>

<pre><code class="language-bash">$ grep "hostname" storage/logs
grep: data/logs: Is a directory  
</code></pre>

<p>grep expects a file path by default. A directory path requires you to add specific options. For example, <a href="https://man7.org/linux/man-pages/man1/grep.1.html">grep supports a ￼<code>--recursive</code>￼ flag</a> to search through all files within the <code>storage/logs</code> directory:</p>

<pre><code class="language-bash">grep --recursive "pattern" storage/logs

# use the "-r" shorthand for "--recursive"
grep -r "pattern" storage/logs  
</code></pre>

<p>The <code>--recursive</code> flag tells grep to take the path argument and treat it as a directory and the starting point for the search through all files within the directory itself or any subdirectory. Any match for the search pattern has the file name as a prefix in the output:</p>

<pre><code class="language-bash">$ grep --recursive "hostname" storage/logs
storage/logs/default.log:{"hostname":"55ec743122e6", …}  
storage/logs/cms.log:{"hostname":"55ec743122e6", …}  
storage/logs/cli/default.log:{"hostname":"68ab13594b24", …}  
storage/logs/cli/delete-audit.log:{"hostname":"68ab13594b24", …}  
</code></pre>

<p>That’s it!</p>

<hr>

<h4 id="mentionedresources">Mentioned Resources</h4>

<ul>
<li><a href="https://man7.org/linux/man-pages/man1/grep.1.html">grep’s man page describing the <code>--recursive</code>￼ flag</a></li>
</ul>]]></content:encoded></item><item><title><![CDATA[grep — Case Insensitive Search]]></title><description><![CDATA[<p>Searching for a pattern in files using <code>grep</code> is case-sensitive by default. Case-sensitive means that grep looks for an exact match of your pattern in the related file. This may not surface all search value matches because of different writing styles for a given text.</p>

<p>This tutorial shows you how</p>]]></description><link>http://futurestud.io/blog/grep-case-insensitive-search/</link><guid isPermaLink="false">25b999ab-666c-456d-ac10-c063b1230b15</guid><category><![CDATA[Server]]></category><category><![CDATA[Ubuntu]]></category><category><![CDATA[Debian]]></category><category><![CDATA[grep]]></category><dc:creator><![CDATA[Marcus Pöhls]]></dc:creator><pubDate>Thu, 06 Mar 2025 08:00:00 GMT</pubDate><content:encoded><![CDATA[<p>Searching for a pattern in files using <code>grep</code> is case-sensitive by default. Case-sensitive means that grep looks for an exact match of your pattern in the related file. This may not surface all search value matches because of different writing styles for a given text.</p>

<p>This tutorial shows you how to search a pattern case-insensitive in a file to see all matches, regardless the pattern’s writing style. </p>



<h2 id="caseinsensitivesearchwithgrep">Case-Insensitive Search with grep</h2>

<p><a href="https://man7.org/linux/man-pages/man1/grep.1.html">grep has a ￼<code>--ignore-case</code>￼ flag</a> to ignore the casing when searching for a pattern in a file. This flag tells grep to treat all letters in the pattern and the text in the source file the same, no matter the casing.</p>

<p>You can use the <code>--ignore-case</code> flag or its shorthand <code>-i</code> for case-insensitive searching:</p>

<pre><code class="language-bash">grep --ignore-case "pattern" storage/logs/app.log

# use the "-i" shorthand for "--ignore-case"
grep -i "pattern" storage/logs/app.log  
</code></pre>

<h3 id="examples">Examples</h3>

<p>Let’s have a look at an example output of grep when searching for a string with the case-insensitive flag:</p>

<pre><code class="language-bash">$ grep -i "request" storage/logs/app.log
INFO: ======= REQUEST FINISHED SUCCESSFUL ======&gt; {"took":"0.052s","status_code":200}  
</code></pre>

<p>Here’s the related grep search without the case-insensitive flag. It won’t find a match because the search value <code>request</code> isn’t part of the <code>app.log</code> file:</p>

<pre><code class="language-bash">$ grep -i "request" storage/logs/app.log

# empty output, nothing found
</code></pre>

<p>That’s it!</p>

<hr>

<h4 id="mentionedresources">Mentioned Resources</h4>

<ul>
<li><a href="https://man7.org/linux/man-pages/man1/grep.1.html">man page for grep’s <code>--ignore-case</code>￼ flag</a></li>
</ul>]]></content:encoded></item><item><title><![CDATA[GitHub Actions — How to Get the Short Git Commit Hash]]></title><description><![CDATA[<p>GitHub Actions is a great integration tool in the software platform. For example, you may run your test suite when pushing to the repository or deployment when pushing to a branch connected to a deployed environment.</p>

<p>We’re using GitHub Actions for both examples: running our test suite and deployments.</p>]]></description><link>http://futurestud.io/blog/github-actions-how-to-get-the-short-git-commit-hash/</link><guid isPermaLink="false">01c35fde-2b1f-4854-bbd4-2b540415096e</guid><category><![CDATA[GitHub]]></category><category><![CDATA[bash]]></category><dc:creator><![CDATA[Marcus Pöhls]]></dc:creator><pubDate>Thu, 27 Feb 2025 08:00:00 GMT</pubDate><content:encoded><![CDATA[<p>GitHub Actions is a great integration tool in the software platform. For example, you may run your test suite when pushing to the repository or deployment when pushing to a branch connected to a deployed environment.</p>

<p>We’re using GitHub Actions for both examples: running our test suite and deployments. When deploying, we’re using the short git commit hash as part of the release identifier. But there’s one downside in GitHub Actions: they don’t provide the short git commit hash as a variable by default.</p>

<p>This tutorial shows you how to get the short, seven-character git commit hash within GitHub Actions.</p>



<h2 id="usetheshortgitcommithashingithubactions">Use the Short Git Commit Hash in GitHub Actions</h2>

<p>GitHub Actions provide a comprehensive set of <a href="https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/accessing-contextual-information-about-workflow-runs">contextual information</a>. For example, you’re receiving the context data for the <code>env</code>ironment or the <code>job</code> or specific <a href="https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/accessing-contextual-information-about-workflow-runs#github-context"><code>github</code></a> data.</p>

<p>The <code>github</code> context contains the <code>github.sha</code> variable that triggered the workflow. It’s the git commit SHA in full length, like <code>ffac537e6cbbf934b08745a378932722df287a53</code>.</p>

<p>You can retrieve the short commit SHA using <a href="https://stackoverflow.com/questions/428109/extract-substring-in-bash/428580#428580">bash parameter expansion</a>. With parameter expansion, you can extract a substring from a given variable. You’re providing an offset and the substring length.</p>

<p>Here’s an example outlining the use of parameter expansion to retrieve the short git commit hash:</p>

<pre><code class="language-bash">github_sha_hash=${{ github.sha }}  
github_sha_short="${github_sha_hash:0:7}"  
</code></pre>

<h3 id="githubactionsexampleworkflowwithshortgitcommithash">GitHub Actions Example Workflow With Short Git Commit Hash</h3>

<p>The following GitHub Actions workflow shows you how to get and use short git SHA. We’re retrieving the full <code>github.sha</code> context variable and using parameter expansion to get the first seven characters from it. We’re also storing the short commit hash within a local <code>github_sha_short</code> variable that can be used later, in our case to echo out the value:</p>

<pre><code class="language-yaml">name: Production Deployment

on:  
  workflow_run:
    workflows: [Run tests]

jobs:  
  deploy:
    runs-on: ubuntu-24.04

    steps:
      …

      - name: Run your script
        run: |
          github_sha_hash=${{ github.sha }}
          github_sha_short="${github_sha_hash:0:7}"

          echo "GitHub Short Commit Hash hash: ${github_sha_short}"
</code></pre>

<p>That’s it!</p>

<hr>

<h4 id="mentionedresources">Mentioned Resources</h4>

<ul>
<li><a href="https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/accessing-contextual-information-about-workflow-runs">GitHub Actions contextual information</a></li>
<li><a href="https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/accessing-contextual-information-about-workflow-runs#github-context">GitHub Actions <code>github</code> context data</a></li>
<li><a href="https://stackoverflow.com/questions/428109/extract-substring-in-bash/428580#428580">StackOverflow thread for bash parameter expansion</a></li>
</ul>]]></content:encoded></item><item><title><![CDATA[MySQL — Add New Column as the First Column in a Table]]></title><description><![CDATA[<p>In the previous tutorial, we looked at <a href="https://futurestud.io/tutorials/mysql-add-new-column-after-an-existing-column">adding a new column after an existing column in MySQL</a>. That tutorial showed you how to add a new column at any position in a table, except the first.</p>

<p>In this tutorial, we’re adding a new column to the beginning of a</p>]]></description><link>http://futurestud.io/blog/mysql-add-new-column-as-the-first-column-in-a-table/</link><guid isPermaLink="false">aa63eccc-687f-4e52-934f-f7ca5436aede</guid><category><![CDATA[MySQL]]></category><dc:creator><![CDATA[Marcus Pöhls]]></dc:creator><pubDate>Thu, 20 Feb 2025 08:00:00 GMT</pubDate><content:encoded><![CDATA[<p>In the previous tutorial, we looked at <a href="https://futurestud.io/tutorials/mysql-add-new-column-after-an-existing-column">adding a new column after an existing column in MySQL</a>. That tutorial showed you how to add a new column at any position in a table, except the first.</p>

<p>In this tutorial, we’re adding a new column to the beginning of a table using the <code>ALTER TABLE … ADD COLUMN … FIRST</code> syntax.</p>



<h2 id="addinganewfirstcolumninamysqltable">Adding a New First Column in a MySQL Table</h2>

<p>MySQL allows you to add a new column to the beginning of a table. Use the <code>ALTER TABLE … ADD COLUM</code> query to add a new column. Then put the <code>FIRST</code> modified after the column name to make it the new, first column of that table.</p>

<p>Here’s an example of adding a new <code>uuid</code> column to the beginning of the table. This new <code>uuid</code> column pushes all other columns to their position:</p>

<pre><code class="language-sql">ALTER TABLE users  
  ADD COLUMN uuid VARCHAR(50) FIRST;
</code></pre>

<p>You may add more than one column to your table and combine the positions as you want. For example, add a new column to the beginning and add another column after a given column in the table.</p>

<pre><code class="language-sql">ALTER TABLE users  
  ADD COLUMN uuid VARCHAR(50) FIRST
  ADD COLUMN fullname VARCHAR(150) NULL AFTER lastname
  ADD COLUMN updatedon DATETIME;
</code></pre>

<p>The statement above adds the following fields to the <code>users</code> table: <br>
- a new first <code>uuid</code> column
- a <code>fullname</code> column after the existing <code>lastname</code> column
- an <code>updatedon</code> column at the end, as the new last column in the table</p>

<p>That’s it!</p>

<hr>

<h4 id="mentionedresources">Mentioned Resources</h4>

<ul>
<li>Future Studio tutorial on <a href="https://futurestud.io/tutorials/mysql-add-new-column-after-an-existing-column">adding a new MySQL column after an existing one</a></li>
</ul>]]></content:encoded></item><item><title><![CDATA[MySQL — Add New Column After an Existing Column]]></title><description><![CDATA[<p>Adding a new column to a MySQL table will put it at the end of the table. When adding a new column to a table you sometimes want to place it at a given position, next to an existing column in the table.</p>

<p>MySQL allows you to place a new</p>]]></description><link>http://futurestud.io/blog/mysql-add-new-column-after-an-existing-column/</link><guid isPermaLink="false">662c2a4c-e8fd-4efe-b523-a3f770e5be3b</guid><category><![CDATA[MySQL]]></category><dc:creator><![CDATA[Marcus Pöhls]]></dc:creator><pubDate>Thu, 13 Feb 2025 08:00:00 GMT</pubDate><content:encoded><![CDATA[<p>Adding a new column to a MySQL table will put it at the end of the table. When adding a new column to a table you sometimes want to place it at a given position, next to an existing column in the table.</p>

<p>MySQL allows you to place a new column after an existing one using the <code>AFTER &lt;column-name&gt;</code> syntax. Read on to get more details.</p>



<h2 id="addanewfieldafteranexistingcolumninamysqltable">Add a New Field After an Existing Column in a MySQL Table</h2>

<p>Use the <code>ALTER TABLE … ADD COLUMN</code> syntax in MySQL to add a new column. This command supports the <code>AFTER</code> keyword telling MySQL to add a new column after an existing one.</p>

<p>Here’s a sample SQL query that adds a new <code>fullname</code> column after the existing <code>lastname</code>: </p>

<pre><code class="language-sql">ALTER TABLE users  
  ADD COLUMN fullname VARCHAR(150) NULL AFTER lastname;
</code></pre>

<p>You can add multiple columns in a single statement and combine the creation with the <code>AFTER</code> syntax as well. Every new column defines their position using <code>AFTER</code>:</p>

<pre><code class="language-sql">ALTER TABLE users  
  ADD COLUMN uuid VARCHAR(50) NULL AFTER id
  ADD COLUMN fullname VARCHAR(150) NULL AFTER uuid;
</code></pre>

<p>That’s it!</p>]]></content:encoded></item><item><title><![CDATA[MySQL — Order By Columns Whichever is Not Null]]></title><description><![CDATA[<p>MySQL is flexible in the data model and allows you to have nullable columns. For example, you’re using <code>NULL</code> as the default date-time value until a given action happens. When displaying the data you may want to apply a specific sorting. But if the sorting column allows <code>NULL</code> values,</p>]]></description><link>http://futurestud.io/blog/mysql-order-by-columns-whichever-is-not-null/</link><guid isPermaLink="false">f9fb6c1a-fb77-42e3-94ea-1a003b1bd79a</guid><category><![CDATA[MySQL]]></category><dc:creator><![CDATA[Marcus Pöhls]]></dc:creator><pubDate>Thu, 06 Feb 2025 08:00:00 GMT</pubDate><content:encoded><![CDATA[<p>MySQL is flexible in the data model and allows you to have nullable columns. For example, you’re using <code>NULL</code> as the default date-time value until a given action happens. When displaying the data you may want to apply a specific sorting. But if the sorting column allows <code>NULL</code> values, you may want to fall back to another column that contains a value (possibly because of a <code>NOT NULL</code> assignment).</p>

<p>This tutorial shows you how to order values in MySQL by multiple columns that use the first non-null one.</p>



<h2 id="usethefirstnonnullvaluefromalistoffields">Use the First Non-Null Value From a List of Fields</h2>

<p>MySQL has the <a href="https://dev.mysql.com/doc/refman/8.4/en/comparison-operators.html#function_coalesce"><code>COALESCE</code></a> function that returns the first non-<code>NULL</code> column from a given list, or <code>NULL</code> if all values are <code>NULL</code>.</p>

<p>Here’s a simple example showing the functionality of <code>COALESCE</code>:</p>

<pre><code class="language-sql">SELECT COALESCE(NULL, 1);  
# 1
</code></pre>

<p>Let’s use the <code>COALESCE</code> function in another example. Let’s say you want to sort the users of your application based on when they confirmed their account. This sorting will show the newest users, that are allowed to interact with your app, at the beginning of the listing. If a user hasn’t confirmed their account, you want to use the registration date.</p>

<p>Here’s an example using <code>COALESCE</code> to retrieve the confirmation or creation date of a given user:</p>

<pre><code class="language-sql">SELECT *  
FROM users  
ORDER BY COALESCE(confirmedon, createdon) DESC;  
</code></pre>

<p>You can also use <code>COALESCE</code> in the list of selected fields. The following example uses a named field <code>confirmedonOrCreatedon</code> that contains the first non-<code>NULL</code> value from the two fields:</p>

<pre><code class="language-sql">SELECT  
  *,
  COALESCE(confirmedon, createdon) as confirmedonOrCreatedon
FROM users  
ORDER BY confirmedonOrCreatedon DESC;  
</code></pre>

<p>That’s it!</p>

<hr>

<h4 id="mentionedresources">Mentioned Resources</h4>

<ul>
<li><a href="https://dev.mysql.com/doc/refman/8.4/en/comparison-operators.html#function_coalesce">MySQL docs on the <code>COALESCE</code> function</a></li>
</ul>]]></content:encoded></item><item><title><![CDATA[MySQL — Rename a Column]]></title><description><![CDATA[<p>An application in production evolves by adding new features. You may also detect inconsistencies from previous developments that you want to improve, such as the naming in your database schema or adjustments in casing.</p>

<p>You can rename columns in MySQL easily and this tutorial shows you how.</p>



<h2 id="mysql8xandlater">MySQL 8.x</h2>]]></description><link>http://futurestud.io/blog/mysql-rename-a-column/</link><guid isPermaLink="false">94f20751-95fa-4f22-a340-3b03e2ccf436</guid><category><![CDATA[MySQL]]></category><dc:creator><![CDATA[Marcus Pöhls]]></dc:creator><pubDate>Thu, 30 Jan 2025 08:00:00 GMT</pubDate><content:encoded><![CDATA[<p>An application in production evolves by adding new features. You may also detect inconsistencies from previous developments that you want to improve, such as the naming in your database schema or adjustments in casing.</p>

<p>You can rename columns in MySQL easily and this tutorial shows you how.</p>



<h2 id="mysql8xandlater">MySQL 8.x (and later)</h2>

<p>You can rename columns in MySQL 8.0 (and above) using the <code>ALTER TABLE</code> command. The following syntax renames a column:</p>

<pre><code class="language-sql">ALTER TABLE users RENAME COLUMN first_name TO firstname;  
</code></pre>

<p>The <code>ALTER TABLE … RENAME COLUMN</code> command is readable and understandable. It changes the column name but doesn’t allow you to the definition. For example, if you need to change the length of the VARCHAR field, you need to use the <code>ALTER TABLE … CHANGE</code> syntax. Read the next section for MySQL 5.6/5.7 for that syntax.</p>

<h2 id="mysql56and57">MySQL 5.6 and 5.7</h2>

<p>In MySQL 5.x you must use the <code>ALTER TABLE … CHANGE</code> syntax to rename a column. You must provide the full column definition:</p>

<pre><code class="language-sql">ALTER TABLE users CHANGE first_name firstname VARCHAR(100) NOT NULL;

# change column name + definition
ALTER TABLE users CHANGE first_name firstname VARCHAR(150) NOT NULL;  
</code></pre>

<p><strong>Notice:</strong> any unstated attribute from the existing column definition goes back to default if you’re not restating the full column definition when renaming a column. For example, omitting <code>NOT NULL</code> in the definition will result in allowing NULL values.</p>

<p>That’s it!</p>]]></content:encoded></item><item><title><![CDATA[JavaScript — Check if a Date is on a Weekend or Weekday]]></title><description><![CDATA[<p>Working with dates may involve checking whether a given date is a weekday or a weekend. For example, you don’t want to send an email on weekends but on weekdays, and vice versa. This tutorial shows you how to determine whether a given JavaScript date is a weekend or</p>]]></description><link>http://futurestud.io/blog/javascript-check-if-a-date-is-on-a-weekend-or-week-day/</link><guid isPermaLink="false">4b9c04eb-f8a7-45b4-9836-535e8bf7487a</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[Node.js]]></category><dc:creator><![CDATA[Marcus Pöhls]]></dc:creator><pubDate>Thu, 23 Jan 2025 08:00:00 GMT</pubDate><content:encoded><![CDATA[<p>Working with dates may involve checking whether a given date is a weekday or a weekend. For example, you don’t want to send an email on weekends but on weekdays, and vice versa. This tutorial shows you how to determine whether a given JavaScript date is a weekend or weekday.</p>



<h2 id="checkifadateisonaweekendinjavascript">Check if a Date is on a Weekend in JavaScript</h2>

<p>The following code snippet outlines how to check whether a given date is on a weekend. We’re using the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getDay"><code>Date#getDay</code></a> function to retrieve the number for the day of the week. This number is according to the local time and represents a day between <code>0</code> and <code>6</code>:</p>

<ul>
<li><code>0=Sunday</code></li>
<li><code>1=Monday</code></li>
<li><code>2=Tuesday</code></li>
<li>…</li>
<li><code>6=Saturday</code></li>
</ul>

<p>The numbers for Saturday <code>6</code> and Sunday <code>0</code> are a multiple of <code>6</code> and we can use the modulo operator to check for a remainder of <code>0</code> to detect the weekend:</p>

<pre><code class="language-js">function isWeekend(date) {  
  if (date instanceof Date) {
    return date.getDay() % 6 === 0
  }

  throw new Error('Cannot check if date is weekend: [date] parameter is not a Date')
}
</code></pre>

<h2 id="checkifadateisaweekdayinjavascript">Check if a Date is a Weekday in JavaScript</h2>

<p>For weekdays, we’re using <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getDay"><code>Date#getDay</code></a> as well to retrieve the number for the day of the week. This time we’re checking for a remainder other than <code>0</code> to detect the days Monday to Friday:</p>

<pre><code class="language-js">function isWeekday(date) {  
  if (date instanceof Date) {
    return date.getDay() % 6 !== 0
  }

  throw new Error('Cannot check if date is week day: [date] parameter is not a Date')
}
</code></pre>

<p>That’s it!</p>

<hr>

<h4 id="mentionedresources">Mentioned Resources</h4>

<ul>
<li>MDN docs for <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getDay"><code>Date#getDay</code></a></li>
</ul>]]></content:encoded></item><item><title><![CDATA[nano — Open Files at a Given Line Number]]></title><description><![CDATA[<p>The nano text editor is included in Debian-based operating systems. Because Ubuntu is based on Debian you’ll find nano pre-installed as well. The nano editor comes in handy when working in environments where you don’t have a user interface. For example, in server environments or using remote connections</p>]]></description><link>http://futurestud.io/blog/nano-open-files-at-a-given-line-number/</link><guid isPermaLink="false">dd74095e-3dd7-4aff-bb62-af08f3cc3e5a</guid><category><![CDATA[bash]]></category><category><![CDATA[Ubuntu]]></category><category><![CDATA[Debian]]></category><dc:creator><![CDATA[Marcus Pöhls]]></dc:creator><pubDate>Thu, 16 Jan 2025 08:00:00 GMT</pubDate><content:encoded><![CDATA[<p>The nano text editor is included in Debian-based operating systems. Because Ubuntu is based on Debian you’ll find nano pre-installed as well. The nano editor comes in handy when working in environments where you don’t have a user interface. For example, in server environments or using remote connections via the command line.</p>

<p>Editing large files with nano can be tedious, especially when the line of interest is hundreds of lines away from the start. This tutorial shows you how to open a file with nano at a given line number.</p>



<h2 id="openfilesinnanoeditoratlinenumber">Open Files in nano Editor at Line Number</h2>

<p>You can jump to a specific line in nano using <code>nano +&lt;line-number&gt; app.js</code>. The “plus” flag tells nano to jump to line n for the opening file:</p>

<pre><code class="language-bash"># open my-file.js at line 377
nano +377 my-file.js  
</code></pre>

<p>Nano jumps to the last line of the selected file if you’re providing a line number that exceeds the total number of lines.</p>

<p><strong>Notice:</strong> you can’t use a negative jump like <code>nano -1 app.js</code> to jump to the last line.</p>

<p>Enjoy!</p>]]></content:encoded></item><item><title><![CDATA[git — Clone Into Current Directory]]></title><description><![CDATA[<p>Typically we’re cloning a git repository into a dedicated directory. The cloned directory then has the name of the repository which, by default, is the repository’s slug. You may also define the directory name in which the git repository’s contents will be cloned.</p>

<p>Recently we prepared the</p>]]></description><link>http://futurestud.io/blog/git-clone-into-current-directory/</link><guid isPermaLink="false">58b63ead-1378-4a31-be13-597c33778044</guid><category><![CDATA[git]]></category><category><![CDATA[GitHub]]></category><category><![CDATA[GitLab]]></category><dc:creator><![CDATA[Marcus Pöhls]]></dc:creator><pubDate>Thu, 09 Jan 2025 20:30:00 GMT</pubDate><content:encoded><![CDATA[<p>Typically we’re cloning a git repository into a dedicated directory. The cloned directory then has the name of the repository which, by default, is the repository’s slug. You may also define the directory name in which the git repository’s contents will be cloned.</p>

<p>Recently we prepared the directory structure on a local computer before cloning the remote repository. When cloning the repository we wanted git to put the contents into the current directory. This tutorial shows you how to do that.</p>



<h2 id="clonearemotegitrepositoryintothecurrentdirectory">Clone a Remote git Repository into the Current Directory</h2>

<p>The <code>git clone</code> command allows you to clone a git repository from a remote machine to your local hard drive. The signature of <code>git clone</code> expects a repository URL as the first argument. You may provide an optional second argument which is the directory name in which to put the contents.</p>

<p>You may also use the dot <code>.</code> as the target directory for the clone. The dot represents the current directory and git properly resolves it:</p>

<pre><code class="language-bash"># put a dot after the git repository URL to clone into the current directory
git clone git@github.com:user/my-project.git .  
</code></pre>

<p>That’s it!</p>]]></content:encoded></item><item><title><![CDATA[bash — Show Hidden Files and Folders with `ls`]]></title><description><![CDATA[<p>The <code>ls</code> command is essential when navigating a file system. <code>ls</code> displays files and directories in a given file system path. Yet, there’s a nuance when displaying files using the plain <code>ls</code> command: it’s not listing dotfiles.</p>

<p>Dotfiles are the “hidden” files on your hard disk that start</p>]]></description><link>http://futurestud.io/blog/bash-show-hidden-files-and-folders-with-ls/</link><guid isPermaLink="false">1f89e9ab-52cd-4021-a745-2eb4f3758974</guid><category><![CDATA[Linux]]></category><category><![CDATA[bash]]></category><category><![CDATA[Ubuntu]]></category><category><![CDATA[Server]]></category><dc:creator><![CDATA[Marcus Pöhls]]></dc:creator><pubDate>Thu, 02 Jan 2025 08:00:00 GMT</pubDate><content:encoded><![CDATA[<p>The <code>ls</code> command is essential when navigating a file system. <code>ls</code> displays files and directories in a given file system path. Yet, there’s a nuance when displaying files using the plain <code>ls</code> command: it’s not listing dotfiles.</p>

<p>Dotfiles are the “hidden” files on your hard disk that start with a dot. Typically, a file explorer hides such files. A common dotfile is the <code>.bashrc</code> file, or a directory example is the <code>.git</code> folder in a git repository.</p>

<p>This tutorial shows you how to display all files and folders in a directory, including dotfiles.</p>



<h2 id="displayallfilesandfolders">Display All Files and Folders</h2>

<p>Use <code>ls -a</code> to display all files and folders in a file path. The <code>-a</code> flag is an alias for the <code>—all</code> flag and tells <code>ls</code> not to hide dotfiles: </p>

<pre><code class="language-bash">ls -a

# or with full flag name
ls --all  
</code></pre>

<h3 id="exampleshowallfilesandfoldersincolumns">Example: Show All Files and Folders in Columns</h3>

<p>Here’s an example showing all files and folders in a project directory. We’ve reduced the number of files and folders for a better overview. You can see that the <code>ls -a</code> command displays dotfiles like <code>.gitignore</code> and also hidden directories like <code>.project</code>. Also, it shows the implicit <code>.</code> and <code>..</code> paths:</p>

<pre><code class="language-bash">$ ls -a
.                  .gitignore         package.json
..                 .project           vite.config.ts
</code></pre>

<h3 id="allfilesandfoldersasalist">All Files and Folders as a List</h3>

<p>Instead of printing them in columns, you can also list the files and folders. Append the <code>-l</code> flag or combine them in a single flag to <code>ls -al</code>. Notice, <code>ls -la</code> is the same as <code>ls -al</code>. You can change the order of flags as you want.</p>

<pre><code class="language-bash">$ ls -al
.
..
.gitignore
package.json  
.project
vite.config.ts  
</code></pre>

<h2 id="displayalmostallfilesandfolders">Display Almost All Files and Folders</h2>

<p>The <code>ls -a</code> flag displays the implicit <code>.</code> and <code>..</code> paths. The <code>ls</code> command offers the <code>—almost-all</code> flag to hide these paths. You may also use the <code>-A</code> alias instead of the full <code>—almost-all</code>:</p>

<pre><code class="language-bash">ls -A

# or with full flag name
ls --almost-all  
</code></pre>

<h3 id="almostallfilesandfoldersincolumns">Almost All Files and Folders in Columns</h3>

<p>Displaying almost all files and folders in a given file path surfaces the dotfiles and hides the implicit <code>.</code> and <code>..</code> paths.</p>

<pre><code class="language-bash">$ ls -A
.gitignore         package.json
.project           vite.config.ts
</code></pre>

<h3 id="almostallfilesandfoldersasalist">Almost All Files and Folders as a List</h3>

<p>You can also print the files and folders as a list. Append the <code>-l</code> flag to print the listing in combination with almost all files and folders:</p>

<pre><code class="language-bash">$ ls -Al
.gitignore
package.json  
.project
vite.config.ts  
</code></pre>

<p>That’s it!</p>]]></content:encoded></item></channel></rss>