<?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:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Matt Hagemann on Medium]]></title>
        <description><![CDATA[Stories by Matt Hagemann on Medium]]></description>
        <link>https://medium.com/@matthagemann?source=rss-ad3addd7bd55------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by Matt Hagemann on Medium</title>
            <link>https://medium.com/@matthagemann?source=rss-ad3addd7bd55------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 19:27:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@matthagemann/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to Change the User for All Your Git Commits]]></title>
            <link>https://matthagemann.medium.com/how-to-change-the-user-for-all-your-git-commits-ffefbacf2652?source=rss-ad3addd7bd55------2</link>
            <guid isPermaLink="false">https://medium.com/p/ffefbacf2652</guid>
            <category><![CDATA[git]]></category>
            <category><![CDATA[gitlab]]></category>
            <category><![CDATA[github]]></category>
            <dc:creator><![CDATA[Matt Hagemann]]></dc:creator>
            <pubDate>Thu, 16 Apr 2020 22:24:33 GMT</pubDate>
            <atom:updated>2021-03-11T22:11:10.130Z</atom:updated>
            <content:encoded><![CDATA[<h4>Over the course of a long-lasting project, your author information may change and the associations to a user profile on GitHub or GitLab may become broken. This is the ultimate guide for how to change the entire commit history.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lcikom2XRzi0tV7902AzCg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@yancymin?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Yancy Min</a> on <a href="https://unsplash.com/s/photos/git?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>You should only do this in repositories that are not widely used yet. The changes are rather intrusive, but easily manageable in a one-person project or within a small team. In any other case, use it when all team members are coordinating this together.</p><p>No matter how we change the information of past commits, we are effectively rewriting the commit history. You will create new commit objects in this process. An altered history can become a serious problem for collaborators if they already have work based on some of the original commits.</p><h3>Rewrite All Affected Commits</h3><p>Rewriting commits is done with git filter-brand to filter the history. The following terminal command will iterate through every commit in your history and update the author information wherever its email address equals OLD_EMAIL. Be sure to replace OLD_EMAIL, NEW_NAME and NEW_EMAIL.</p><p>It allows you to batch-process a large number of commits with a script inside the command. Changes are re-committed. By using --env-filter, we alter the environment in which the re-committing statement takes place. The script checks if a commit was made with the email you want to replace. Upon match, the environment is altered by exporting environment variables used to recommit the changes.</p><p>We also use the additional --tag-name-filter to take care of tags referencing commits.</p><p>The last option --all defines all refs to be processed. It needs to be separated from the filter-branch options with a double-dash.</p><pre>$ git filter-branch --env-filter &#39;<br>OLD_EMAIL=&quot;old@example.com&quot;<br>NEW_NAME=&quot;New Example&quot;<br>NEW_EMAIL=&quot;new@example.com&quot;</pre><pre>if [ &quot;$GIT_COMMITTER_EMAIL&quot; = &quot;$OLD_EMAIL&quot; ]<br>then<br>  export GIT_COMMITTER_NAME=&quot;$NEW_NAME&quot;<br>  export GIT_COMMITTER_EMAIL=&quot;$NEW_EMAIL&quot;<br>fi<br>if [ &quot;$GIT_AUTHOR_EMAIL&quot; = &quot;$OLD_EMAIL&quot; ]<br>then<br>  export GIT_AUTHOR_NAME=&quot;$NEW_NAME&quot;<br>  export GIT_AUTHOR_EMAIL=&quot;$NEW_EMAIL&quot;<br>fi<br>&#39; --tag-name-filter cat -- --branches --tags</pre><h3>Check the Updated Log</h3><p>You can use the git log command to review above changes done locally. To navigate the log, press the space bar for next page or q to exit the view. If you discover yet more outdated author information, you have to run through the entire process below first before you can repeat it with another email address change.</p><h3>Push Rewritten History</h3><p>To push the rewritten repository, the --force option needs to be added in order to rewrite the history of the remote repository.</p><pre>$ git push origin --force --all</pre><p>The following command is optional and needed only if you use tags. It will additionally force push the tags to the remote server:</p><pre>$ git push origin --force --tags</pre><h3>Common Issue in GitLab</h3><p>In GitLab, I encountered the error “You are not allowed to push code to protected branches on this project.” whenever I did this forced push.</p><p>You can easily resolve it in your repository’s <strong>Settings &gt; Repository &gt; Protected Brances </strong>to unprotect the master branch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tDn6Wazjos0VUzFBCy2TsA.png" /><figcaption>Unprotect master branch in the GitLab repository settings.</figcaption></figure><h3>Update All Clone Repositories</h3><p>Now the repository has been filtered, the commit history has been rewritten, and changes were force pushed to the remote server.</p><p>In the next step, every clone of this repository has to be updated (including the one you’ve been altering). This cannot be done with the usual git pull alone. Use these commands:</p><pre>$ git fetch origin <br>$ git reset --hard origin/master<br>$ git for-each-ref --format=&#39;delete %(refname)&#39; refs/original | git update-ref --stdin<br>$ git reflog expire --expire=now --all<br>$ git gc --prune=now</pre><h3>Multiple Author Changes in Commit History</h3><p>If your author information has changed multiple times throughout history, you’ll have to repeat the above process for each modification.</p><p>If you forgot to fetch from origin, you may encounter this error message when trying to do a 2nd round:</p><pre>Cannot create a new backup.<br>A previous backup already exists in refs/original/<br>Force overwriting the backup with -f</pre><p>Always remember to perform a new fetch after pushing the changed commit history by running the commands listed above.</p><h3>Remember to Set Author Information</h3><p>It’s needless to say that you should update the author information on your terminal. This will avoid future commits with the old email or name again. Either set them for the local repository or globally.</p><p>The below command, when executed inside the repository directory, changes the author’s name and email address used to commit:</p><pre>$ git config user.name &quot;New Example&quot;<br>$ git config user.email &quot;new@example.com&quot;</pre><p>When --global is added to the above commands, the settings are set globally rather than just for the current repository. A globally set name and email address are used as long as there is no name or email set in the repository itself.</p><h3>Conclusion</h3><p>You should now have updated all your commits with the correct author information that you wanted. This is especially useful if you want to ensure that your contributions are correctly linked to your GitHub or GitLab profile. If your profiles match the author’s email address, you should see all commits correctly linked.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ffefbacf2652" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How You Can Bulk Validate VAT ID Numbers]]></title>
            <link>https://matthagemann.medium.com/how-you-can-bulk-validate-vat-id-numbers-18e1df837cad?source=rss-ad3addd7bd55------2</link>
            <guid isPermaLink="false">https://medium.com/p/18e1df837cad</guid>
            <category><![CDATA[compliance]]></category>
            <category><![CDATA[validation]]></category>
            <category><![CDATA[taxes]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Matt Hagemann]]></dc:creator>
            <pubDate>Fri, 13 Dec 2019 21:20:18 GMT</pubDate>
            <atom:updated>2020-11-14T15:10:07.599Z</atom:updated>
            <content:encoded><![CDATA[<h3>How You Can Bulk Validate VAT Numbers</h3><h4>If you need to check a few VAT numbers the VIES website is a good place to go, but validating more gets time-consuming. This guide explores a bulk VAT verification service for VAT numbers.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cQHWV5c1xsQJN1pL0FOizw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@tfrants?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Tyler Franta</a> on <a href="https://unsplash.com/collections/3831891/business?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>There are a few bulk VAT number verification services out there that can perform the task for you. One that I’ve come across recently is an <a href="https://taxtechsorcery.com/how-can-you-mass-validate-vat-numbers/">Excel-based macro</a> that will obtain results from VIES.</p><p>Since I’m personally a fan of cloud-based services I wanted to look beyond what the first few Google results suggested to me.</p><p>A bulk validation service that could be particularly attractive to a wider audience is <a href="https://vatstack.com/">Vatstack</a> because it lets you control everything from a dashboard.</p><h3>Why a Cloud-Based Solution</h3><p>The advantage of Vatstack’s solution is that all VAT number validation requests are stored in the cloud for future retrieval. This makes it easy for me to look into historical records for potential changes in my customer’s VAT registration status.</p><p>Furthermore, Vatstack will re-validate unsuccessful attempts automatically as government services across the 28 EU member states can be <a href="http://ec.europa.eu/taxation_customs/vies/help.html">down regularly due to maintenance</a>. I don’t need to re-run them for hours myself. The idea is that I upload a list of VAT numbers and let the validation process run in the background.</p><p>Another advantage is that it also validates VAT numbers for Australia, Switzerland and Norway. Something that no other service I’ve tried is capable of.</p><h3>Import a CSV File Through the Dashboard</h3><p>Although Vatstack is primarily an API-based VAT service, it conveniently allows you to import a list of VAT numbers to a batch process. Prepare a CSV file according to their template, give your batch process a descriptive name and you’re good to go.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oL0EB6VGjUKXL3gkuWxrMw.png" /><figcaption>Upload CSV file containing a list of VAT numbers to validate on Vatstack.</figcaption></figure><p>The screen will look like this after import:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HB-Zo7LF3LOOybC6THlQjQ.png" /><figcaption>Prepared batch validation process after import.</figcaption></figure><p>Click the <strong>Start Validation</strong> button to begin the batch process and Vatstack will run through your entire list. Invalid VAT number formats are automatically detected and marked accordingly.</p><p>If any VAT number could not be check against the government databases, the process will continue to run until all results were obtained.</p><h3>The Finished Report</h3><p>The finished report is downloadable in CSV which makes it easy for anyone to evaluate the results in a spreadsheet software for example. Your list will include all relevant information:</p><ul><li>VAT number that was tested</li><li>Whether it’s valid or invalid</li><li>A unique reference number and the requested date (acts as proof for tax administrations)</li><li>Company name and address (note that names and addresses are not public in Germany and Spain)</li><li>Country code</li></ul><h3>Conclusion</h3><p>I hope this article helped you discover a useful bulk VAT validation service and that it helped you save a ton of manual work.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=18e1df837cad" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Charge EU VAT on Digital Products and Subscriptions]]></title>
            <link>https://matthagemann.medium.com/how-to-charge-eu-vat-on-digital-products-and-subscriptions-1a9594d4792d?source=rss-ad3addd7bd55------2</link>
            <guid isPermaLink="false">https://medium.com/p/1a9594d4792d</guid>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[entrepreneurship]]></category>
            <category><![CDATA[taxes]]></category>
            <category><![CDATA[vat-registration]]></category>
            <category><![CDATA[compliance]]></category>
            <dc:creator><![CDATA[Matt Hagemann]]></dc:creator>
            <pubDate>Wed, 11 Dec 2019 22:37:27 GMT</pubDate>
            <atom:updated>2020-11-14T15:09:08.676Z</atom:updated>
            <content:encoded><![CDATA[<h4>Accounting for EU VAT could be one of the most challenging hurdles to new software companies that want to implement compliant online payments for their digital products and subscriptions. This tutorial has an easy solution.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*67QECQ9Le5Jmrmr6iFp9AQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@markusspiske?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Markus Spiske</a> on <a href="https://unsplash.com/s/photos/europe-flag?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>You’ve probably heard of it and maybe you already had to answer to a customer who demanded a VAT invoice. It’s EU VAT, the headache that started in 2015 with VAT MOSS and continues to wreak havoc to non-compliant startups, even outside the European Union.</p><p>This tutorial applies to <a href="https://vatstack.com/articles/what-are-digital-products">digital goods and services</a>. These are <strong>telecommunications, broadcasting and electronic services (TBE)</strong>, or officially called <em>electronically supplied services</em> by the European Commission. They can be e-books, audiobooks, online courses, subscription and hosting services, basically anything that can be sold online and digitally in an automated manner.</p><p>Even if your startup is based outside the EU, whether you’re based in India, Australia, United States or on a deserted island in Indonesia, listen up.</p><h3>Why is EU VAT Important for a Startup</h3><p>Before we criticize taxes by default, I want to point out that the laws (or ‘directives’ as they are called) around EU VAT are actually quite progressive and forward-thinking.</p><p>You should understand that the nature of a value added tax (VAT), known in some countries as a goods and services tax (GST), isn’t to tax you as a startup, but to tax the <strong>end-consumer</strong>, your customer. In effect, you’re being held accountable as the middleman who collects tax <strong>on behalf of</strong> the tax administrations.</p><p>Germany and France were the first countries to implement VAT during World War I and more and more countries are seeing the benefits of it as over <a href="https://academic.oup.com/ser/article-abstract/15/4/797/3002644?redirectedFrom=fulltext">20% of the world’s tax revenue is raised through VAT</a>. Even the United States is discussing the implementation of a nationwide US VAT.</p><h3>What If I Just Ignore EU VAT</h3><p>If you, as a business, do not collect VAT from your EU customers, you’re practically assisting the customer in evading tax payments that she should have paid and you’re thereby withholding tax from tax administrations in the EU. They don’t like that at all. Since VAT a major source of income for them, prosecution can result in heavy penalties regardless whether your startup is based inside or outside the EU.</p><p>Your non-compliance could be picked up whenever one of your EU customers tries to reclaim VAT from their tax administration or sends in tax returns that involve a transaction with your startup.</p><p>When you break the rules accidentally or just because you didn’t know, tax authorities normally estimate how much tax you have due and charge you. In some countries you’ll also have to pay overdue interest. If you break the rules intentionally, that’s a tax crime and a court case. However, each member state in the EU enforces their laws their own way.</p><p>Before you panic, I have good news for you. A number of SaaS are working very hard to help you deal with VAT or even handle VAT entirely for you. I’ll get to them further below.</p><h3>Who Needs to Comply with EU VAT</h3><p>The short answer is: every single business in the world that sells digital products in an automated manner. There are allowances and thresholds if your business is based in the EU.</p><h4>EU Businesses</h4><p>In January 2019, a new <a href="https://ec.europa.eu/taxation_customs/business/vat/digital-single-market-modernising-vat-cross-border-ecommerce_en">threshold to ease the regulatory tax burden of micro-businesses and SMEs</a> came into effect:</p><ul><li>If your annual turnover for digital products sold in the EU is below 10,000 EUR, you can charge the <strong>VAT rate of your home country</strong>.</li><li>Once you pass the 10,000 EUR threshold, you must charge the <strong>VAT rate of your customer’s country</strong>.</li></ul><p>Furthermore, you may neither need to register for VAT nor charge VAT if the member state you’re in offers thresholds. It would be better to consult your trusted tax advisor to discuss your individual case.</p><h4>Non-EU Businesses</h4><p>The rules for businesses outside the EU are much easier: There are no thresholds at all. You have to register for VAT <strong>within 10 days of the first sale</strong> of your digital product or subscription to an EU customer.</p><p>You register with the tax administration of the EU member state where your customer resides. Wait, what? There are 28 countries in the EU (27 after Brexit, but that doesn’t help) and if you have customers across the EU, this quickly becomes a bureaucratic nightmare.</p><p>That’s where VAT MOSS enters the picture. Since 2015, a so-called ‘Mini One Stop Shop’ (MOSS) scheme lets suppliers submit quarterly VAT returns to a single tax administration of their choice and that tax administration will do the distribution of funds to each EU member state. EU-based businesses simply activate their existing VAT number for VAT MOSS. Non-EU businesses will likely register for VAT MOSS with the UK or Ireland due to the language. Since Brexit, the safer option is Ireland.</p><h3>How to Charge VAT and How Much</h3><p>Here’s where discussions within your team should start. Once you know that you can’t escape the rules, you need to strategize how you want to implement them in your checkout process while keeping the UI/UX experience seamless for your customer.</p><p>Note that EU customers are already accustomed to being charged a VAT, although prices there are generally <strong>inclusive of VAT</strong>.</p><p>Many online businesses, however, simply add the VAT on top of their base price in order not to lose out on profits. It’s up to you, really, how you want to structure your pricing. Bottom line is that your prices are transparent for your customer and that the taxman gets his fair share.</p><h4>Use a Merchant of Record (MOR)</h4><p>Micro-businesses and one-man-shows that are just starting out and don’t even know whether they’ll make a buck should simply sign up with a merchant of record (MOR) and be done with it.</p><p>MORs help you brush off VAT handling entirely. Example MORs are <a href="https://paddle.com/">Paddle</a> and <a href="https://gumroad.com/">Gumroad</a>. If you’re selling an e-book or an online course, Gumroad gives you a beautiful widget to embed on your website for instant purchases. I especially like that you can upload multiple files for a single product, allowing you to sell multi-part PDF courses, for example.</p><p>Paddle is the more suitable candidate if you’re offering a subscription with charges on a regular interval. I’ve heard that their customer support is terrible to non-existent, but hey, we should shape our own opinions. Both process the transaction with your customer and are contractually their trading partner. You’ll be paid out after all VAT obligations have been taken care of.</p><h4>Use a Payment Processor With a 3rd Party API</h4><p>Once your startup is a little bigger, <a href="https://stripe.com/">Stripe</a> is practically the status quo when it comes to online transactions and processing payments. It’s super flexible, and the latest API updates carry a number of improvements for taxes. You can add customer tax identification numbers to their profile and manage tax rates.</p><p>The drawback is that you have to know what you’re doing because international tax rules are not natively implemented (although being agnostic is also the very advantage of Stripe). Below chart in conjunction with the European Commission’s <a href="http://ec.europa.eu/taxation_customs/tic/public/vatRates/vatrates.html">VAT rates lookup</a> is a rough start.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kx3_lTIniYlZJLclK_BD-A.png" /><figcaption>EU VAT rules for businesses located inside and outside EU.</figcaption></figure><p>It’s vastly inefficient if every business were to implement the same rules over and over, and keep them updated with regulatory changes.</p><p>I’ve come to enjoy using a 3rd party API for determining tax treatments during pre-checkout. <a href="https://vatstack.com/">Vatstack</a> is an affordable add-on to use before a charge goes through. You can use their <a href="https://vatstack.com/docs/quotes">Quotes API</a> to perform VAT calculations and it will automatically come up with the right amount to charge based on your price and the locations between you as the merchant and your customer. It also computes VAT-inclusive or VAT-exclusive prices. I can now use that information to charge the correct amount on Stripe.</p><p>I discourage you from using PayPal as they’ve remained utterly ignorant when it comes to accounting for VAT.</p><h3>When Not to Charge VAT</h3><p>Alright. The last part is about the exceptions. Business customers are exempt from VAT. Here’s the thing: How do you know if a customer is in fact a registered business? The answer is that you have to validate their VAT number in real-time, before the transaction occurs. You can do that with the respective government services that your customer is residing in.</p><p>In the EU, you can check VAT numbers with <a href="http://ec.europa.eu/taxation_customs/vies/vatRequest.html">VIES, the VAT Information Exchange System</a>. It’s a downright cumbersome SOAP API on quasi-WSDL definitions. I’m also using Vatstack’s <a href="https://vatstack.com/docs/validations">Validations API</a> for that purpose as it’s working with a much easier JSON format on REST and I combine it with the price quotations mentioned above. A unique reference ID is stored for me, an official proof that I validated a customer’s VAT number with the government.</p><p>If the number is valid, the API will reduce the VAT to zero for that sale. Take note that stating the validated VAT number on a customer invoice is now becoming <strong>mandatory as of January 2020</strong>, and you have to file an <strong>European Commission Sales List (ESL)</strong> for all transactions with your EU business customers.</p><h3>Conclusion</h3><p>I hope this tutorial has helped you get an overview over the complexities of handling VAT. But I also hope that I could point out a few really fantastic tools that simplify the life of a young startup and that it was able to save you a ton of time and compliance nuisances.</p><p>Please share other tools with me that you’ve come across and I’d be happy to include them in this article.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1a9594d4792d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Validate VAT Numbers Before Every Invoice Charge]]></title>
            <link>https://matthagemann.medium.com/how-to-validate-vat-numbers-before-every-invoice-charge-b1d0091d5f66?source=rss-ad3addd7bd55------2</link>
            <guid isPermaLink="false">https://medium.com/p/b1d0091d5f66</guid>
            <category><![CDATA[vat]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[saas]]></category>
            <category><![CDATA[platform]]></category>
            <category><![CDATA[taxes]]></category>
            <dc:creator><![CDATA[Matt Hagemann]]></dc:creator>
            <pubDate>Wed, 30 Oct 2019 14:54:41 GMT</pubDate>
            <atom:updated>2020-11-14T15:07:33.748Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to Automate VAT Number Checks for Recurring Payments</h3><h4>Business customers enjoy special tax treatment because they are not charged a VAT in the EU. This tutorial attempts to automate VAT number re-validations for your subscription business.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Eh1ju0aZiQP5Q6UJ-KdevQ.jpeg" /></figure><p>If you run an online subscription business, you’ll ultimately end up signing up customers from the European Union.</p><h3>Tax Treatment for Business Customers</h3><p>A business customer does not need to pay VAT. In order to verify that your customer is in fact a business customer, you have to ask for their VAT identification number and validate it in real-time.</p><p>If you use <a href="https://stripe.com/">Stripe</a> to handle subscription charges (there’s no reason why you shouldn’t), then you can simply add your business customer’s VAT number to the customer account. Stripe will initially <a href="https://stripe.com/docs/billing/taxes/tax-ids">validate EU VAT numbers for you</a>, but only once.</p><p>Upon validation, the reverse-charge mechanism applies. Reverse-charge is a legal term and means that the obligation to report VAT on a transaction has been reversed from the supplier to the customer. The customer is now made responsible to report and pay VAT, but since a business does not need to pay VAT, it’s a zero-sum in B2B.</p><p>Here’s the catch for recurring payments such as subscriptions: <strong>How do you know that the VAT number of your customer is still valid?</strong> You have to regularly re-validate it before every charge.</p><p>If you never re-validate a VAT number after the initial sign up and your customer’s VAT number expires (yes, it does happen), you suddenly face an unfortunate situation whereby you owe a VAT amount which you’ve never collected from your customer.</p><h3>Webhook Events Trigger Re-Validation</h3><p>Stripe emits webhook events whenever an invoice becomes due for charge. You can listen to the invoice.upcoming event and look up your customer by the customer ID included in the event’s payload. This type of event is emitted when an invoice is due in 7 and 3 days, respectively. I bet other payment aggregators offer similar webhook events.</p><p>If you store your customer’s VAT number in Stripe’s records, you can pass the tax ID stored in the customer_tax_ids field to perform a re-validation with a dedicated service. I like to use <a href="https://vatstack.com/">Vatstack</a> because it stores all validation records securely in the cloud and I have full traceability of my customer’s tax treatment status.</p><p>What I do on my backend is to query whether Vatstack has an entry for the same VAT number within the past 28 days (this accounts for shorter months such as February). The invoice.upcoming event is ideal to trigger re-validation. It’s sent twice, 7 and 3 days before a charge by default and I want to re-validate only on one occurrence.</p><pre>const axios = require(&#39;axios&#39;)<br>const moment = require(&#39;moment&#39;)</pre><pre>// Exportable router module for Express.js<br>module.exports.stripe = async (req, res, next) =&gt; {<br>  // Extract event object from Stripe’s payload.<br>  if (event.type === &#39;invoice.upcoming&#39;) {<br>    // Iterate through stored tax IDs for the Stripe customer.<br>    await Promise.all(event.object.customer_tax_ids.map(taxId =&gt; {<br>      var threshold = moment().subtract(&#39;28&#39;, &#39;days&#39;).format(&#39;YYYY-MM-DD&#39;)<br>      var { data } = <em>await </em>axios.get(&#39;https://api.vatstack.com/v1/validations&#39;, {<br>        params: {<br>          key: process.env.VATSTACK_API_KEY,<br>          query: taxId.value,<br>          requested_since: threshold,<br>        }<br>      })</pre><pre>      ...</pre><pre>    }))<br>  }<br>}</pre><p>The above code uses the <a href="https://www.npmjs.com/package/axios">axios</a> and <a href="https://www.npmjs.com/package/moment">moment</a> NPM libraries to check whether Vatstack has any historical records for the VAT number I’m querying. The API key is given to you upon registration and you store it in your environment variables.</p><p>If there’s a result from the past 28 days, I obviously want to skip the re-validation process as it’s either the 2nd invoice.upcoming event or could be a recent signup.</p><p>Otherwise, I need to proceed:</p><pre>...</pre><pre>// Using &quot;data&quot; variable from the above code.</pre><pre><em>if</em> (data.validations_count === 0) {<br>  var result = <em>await </em>axios.post(&#39;https://api.vatstack.com/v1/validations&#39;, {<br>    vat_id: taxId<br>  }, {<br>    headers: { Authorization: `Credential ${ process.env.VATSTACK_API_KEY }` }<br>  })</pre><pre>  // Further processing if result.data.valid === false.<br>}</pre><pre>...</pre><p>This creates a validation request with Vatstack and, in most cases, it will respond with an official result immediately. The response contains a valid boolean which I can use to process further.</p><h3>Automate Change of Tax Treatment</h3><p>You can automate the change of tax treatment until there is no human intervention involved on your side. Several approaches come to my mind:</p><ul><li>You can send your customer an automated email with the message that their VAT number is no longer valid and, as a result, you’re going to cancel the reverse-charge mechanism unless they enter a new VAT number (which will have to be validated of course).</li><li>A failure to add a new VAT number would result in you collecting a VAT at their local rate in the upcoming invoices. <a href="https://vatstack.com/docs/quotes">Geolocated price quotes</a> can also be done with Vatstack and the obtained tax rate updated in Stripe.</li><li>Remove the outdated VAT number from Stripe’s customer field customer_tax_ids.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b1d0091d5f66" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Get Visitor’s IP Address in Nginx and Express.js Application]]></title>
            <link>https://matthagemann.medium.com/how-to-get-visitors-ip-address-in-nginx-and-express-js-application-5823959eb6cb?source=rss-ad3addd7bd55------2</link>
            <guid isPermaLink="false">https://medium.com/p/5823959eb6cb</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[expressjs]]></category>
            <category><![CDATA[nginx]]></category>
            <dc:creator><![CDATA[Matt Hagemann]]></dc:creator>
            <pubDate>Mon, 14 Oct 2019 10:22:57 GMT</pubDate>
            <atom:updated>2019-10-14T10:22:57.773Z</atom:updated>
            <content:encoded><![CDATA[<h4>Activating the forwarding of IP addresses requires some configuration on your server. This tutorial shows you how to obtain a visitor’s IP address in 3 simple steps.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ghAfLlpVi94HcxSOZGX6rQ.jpeg" /></figure><h3>Express App Behind Proxies</h3><p>When running an Express app behind a proxy, you have to set the application variable trust proxy to true. Express offers a few <a href="https://expressjs.com/en/guide/behind-proxies.html">other trust proxy values</a> which you can review in their documentation, but for now, we don’t have to mind them.</p><p>Without further ado, these are the steps to reveal a visitor’s IP address to your app:</p><ol><li>app.set(&#39;trust proxy&#39;, true) in your Express app.</li><li>Add proxy_set_header X-Forwarded-For $remote_addr in the Nginx configuration for your server block.</li><li>You can now read off the client’s IP address from the req.ip property.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5823959eb6cb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Use Your Custom Domain Name with Gmail for Receiving and Sending]]></title>
            <link>https://matthagemann.medium.com/how-to-use-your-custom-domain-name-with-gmail-for-receiving-and-sending-7e62cf42af5a?source=rss-ad3addd7bd55------2</link>
            <guid isPermaLink="false">https://medium.com/p/7e62cf42af5a</guid>
            <category><![CDATA[email-provider]]></category>
            <category><![CDATA[domain-names]]></category>
            <category><![CDATA[gmail]]></category>
            <category><![CDATA[email]]></category>
            <dc:creator><![CDATA[Matt Hagemann]]></dc:creator>
            <pubDate>Thu, 16 May 2019 14:05:03 GMT</pubDate>
            <atom:updated>2021-02-18T10:01:45.841Z</atom:updated>
            <content:encoded><![CDATA[<h4>Sending and receiving emails with a custom domain name generally implied subscribing to a full-fledged email provider such as Google’s G Suite or Microsoft’s Office 365. This tutorial shows how you can send and receive emails using Gmail for free.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zr5j-v534sDUpkVocN-6bQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/photos/3Mhgvrk4tjM?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Host Sorter</a> on <a href="https://unsplash.com/search/photos/gmail?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Many domain name registrars offer free email forwarding to every domain name you register with them. I’m using Namecheap which does exactly that.</p><p>While I cannot discuss the setup procedure for every single registrar out there, I hope to lay it out to you by showing Namecheap as an example for receiving and forwarding emails to your Gmail account.</p><ul><li>In the list of your domain names, click <strong>Manage</strong> for the domain name you want to receive emails with.</li><li>Under the “Domain” tab in the nameservers section, ensure that name servers have been set to “Namecheap BasicDNS”. If you have set custom DNS settings for your domain name, be sure to know what you’re doing because changing nameservers can break running systems.</li><li>In the “Redirect Email” section, you can add email forwarders like shown in the screenshot below. Add as many as you want, or add a catch-all alias that forwards to your Gmail address.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ekdK8-I1yemng-KcxzeZWQ.png" /></figure><p>Give it a spin and test whether emails sent to your custom domain name arrive in your Gmail inbox. Once they do, proceed to the next step of setting up sending emails from your Gmail inbox.</p><p>An email address is of little use if you can’t send from it. Right now, you can receive an email, but once you want to reply to it, the recipient will see your Gmail address as the sender. Let’s change that.</p><p>There are two paths from here and it depends whether you’ve set up Two-Factor Authentication (2FA) in your Google account. 2FA is highly recommended as it protects your account with a unique sign-in token generated on your mobile phone.</p><h3>Sending Email Without 2FA:</h3><ul><li>Go to Gmail settings &gt; Accounts &gt; Add another email address</li><li>Enter the name and email address you want to send from (first ensure that email forwarding to your Gmail inbox is working), uncheck “Treat as an alias”, click <strong>Next</strong>.</li><li>SMTP Server: smtp.gmail.com, Username: <em>Your Gmail email address</em>, Password: <em>Your Gmail password</em>, click <strong>Add Account</strong>.</li><li>Wait for the verification code to reach your inbox. Enter it once you’ve received it and done.</li></ul><h3>Sending Email With 2FA:</h3><h4>Create a New App Password</h4><p>In order to sign into any Google service using a 3rd party app, you’ll have to do so with a dedicated app password. This can be generated within your Google account.</p><ul><li>Go to your Google account &gt; Security &gt; App Passwords (refer to <a href="https://support.google.com/accounts/answer/185833?hl=en">Google’s documentation</a> if you don’t see the <em>App Passwords</em> option).</li><li>Create a new app password by assigning an app and device. These fields are merely used for your own reference and have no further significance. I selected “Mail” for app and “Other” for device so I could give it a custom name such as “Gmail”.</li><li>Click “Generate”.</li><li>The password will be shown to you temporarily. Copy it to your clipboard and proceed to adding another email account in your Gmail settings.</li></ul><h4>Add Another Email Address</h4><ul><li>Go to Gmail settings &gt; Accounts &gt; Add another email address</li><li>Enter the name and email address you want to send from (first ensure that email forwarding to your Gmail inbox is working), uncheck “Treat as an alias”</li><li>Click <strong>Next</strong>.</li><li>SMTP Server: smtp.gmail.com, Username: <em>Your Gmail email address</em>, Password: <em>The password generated above.</em></li><li>Click <strong>Add Account</strong>.</li><li>Wait for the verification code to reach your inbox. Enter it once you’ve received it and done.</li></ul><h3>Set as Default Sending Address</h3><p>In the Accounts settings page, you can now set the new email address as the default sending address by tapping the <em>make default</em> button.</p><p>I would also select the <em>Always reply from default address</em> option to ensure that you reply back with your new default address even if someone still sends to your Gmail address.</p><h3>Conclusion</h3><p>You’ve now set up email receiving and sending from your custom domain name without paying for a full-fledged email service.</p><p>This is a great and cheap solution for small businesses or freelancers who want to give a professional impression to their clients. The only expense is the yearly renewal fee for your domain name.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7e62cf42af5a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Fix SSH “Permission Denied” with Git Clone]]></title>
            <link>https://matthagemann.medium.com/how-to-fix-ssh-permission-denied-with-git-clone-f669b65f90ac?source=rss-ad3addd7bd55------2</link>
            <guid isPermaLink="false">https://medium.com/p/f669b65f90ac</guid>
            <category><![CDATA[permission]]></category>
            <category><![CDATA[https]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[terminal]]></category>
            <category><![CDATA[git]]></category>
            <dc:creator><![CDATA[Matt Hagemann]]></dc:creator>
            <pubDate>Mon, 06 May 2019 14:27:37 GMT</pubDate>
            <atom:updated>2020-01-15T13:51:37.882Z</atom:updated>
            <content:encoded><![CDATA[<h4>Are you frustrated that cloning your Git repository over SSH always results in a “permission denied” error message in the terminal? Here’s how to fix it once and for all.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XWCrOtVijQ8gqcEWKuWMBA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/photos/1K9T5YiZ2WU?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Tim Gouw</a> on <a href="https://unsplash.com/search/photos/frustration?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>I operate several droplets on <a href="https://m.do.co/c/bc865bbc2fe0">DigitalOcean</a> and this issue has been bugging me for ages. When I couldn’t take it anymore, I spent a whole hour searching for and trying out various suggested fixes with absolutely no avail. Then I reflected on what I was doing in the first place and figured out the logic behind the operations.</p><p>Before we start, I wanted to let you know that you can start your own droplet on DigitalOcean with a $100 credit. Simply follow this link:</p><p><a href="https://m.do.co/c/bc865bbc2fe0">DigitalOcean - The developer cloud</a></p><p>If you’re not logged in as the root user on your machine, you’ll likely have tried this command to clone your Git repository (GitLab in this case):</p><pre>sudo git clone git@gitlab.com:<em>PROJECT</em>/<em>REPOSITORY</em>.git</pre><p>And this error keeps re-appearing:</p><pre>Cloning into &#39;<em>REPOSITORY</em>&#39;...</pre><pre>git@gitlab.com: Permission denied (publickey).<br>fatal: Could not read from remote repository.</pre><pre>Please make sure you have the correct access rights<br>and the repository exists.</pre><h3>Generate SSH Keys and Test SSH Authentication</h3><p>First of all, ensure that your SSH key has been generated and the file containing the corresponding public key id_rsa.pub has been added to the account where your Git repository is hosted (scroll below to find a list of Git hosting services and where to add your public key).</p><p>If you haven’t generated an SSH key yet, this should be your first step. Run the following command on the machine you plan to Git clone in:</p><pre>ssh-keygen</pre><p>Press return for all questions by keeping the defaults and empty passphrase. This will generate two files in the ~/.ssh directory within your home directory:</p><ul><li>~/.ssh/id_rsa</li><li>~/.ssh/id_rsa.pub</li></ul><p>Copy and paste the content of the newly-generated id_rsa.pub file into the account where your repository is hosted. In my case, this is GitLab.</p><ul><li><strong>GitLab:</strong> Navigate to your <em>User Settings &gt; SSH Keys</em></li><li><strong>GitHub:</strong> Navigate to your <em>Settings</em> &gt; <em>SSH and GPG Keys</em></li><li><strong>BitBucket:</strong> Navigate to your <em>Bitbucket settings</em> &gt; <em>SSH keys</em></li></ul><p>Now you can do an SSH authentication test using this command:</p><pre>ssh -T git@gitlab.com</pre><p>Authentication should succeed with this return message:</p><pre>Welcome to GitLab, @mhagemann!</pre><p>Everything should work, but I still cannot clone my Git repository. Argh!</p><h3>Solution 1: Use HTTPS</h3><p>This is the most effortless solution at hand. Simply switch to cloning from the HTTPS path for your Git repository. But the convenience of never having to enter your credentials again and letting the SSH keys authenticate you will forever haunt you.</p><p>Each git pull will ask for authentication over and over again. That’s not the solution you were looking for. Me neither.</p><h3>Solution 2: Use ‘sudo git clone’</h3><h4>Move SSH Key Files to root’s .ssh Directory</h4><p>When performing operations while not logged in with the root user, we are accustomed to precede all commands with sudo. But sudo implies that SSH keys need to be available in the <strong>root’s</strong> home directory.</p><p>This solution is the most elegant because it allows you to continue with the same directory permissions that you had been working with thus far. No radical permission changes will be performed (we’ll get to that in the 3rd solution below).</p><p>All you do is move the SSH keys we’ve generated above to the root’s SSH directory located at /root/.ssh. If you try sudo git clone now, you’ll likely encounter this error:</p><pre>Cloning into &#39;api&#39;...<br>@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@<br>@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @<br>@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@<br>Permissions 0644 for &#39;/root/.ssh/id_rsa&#39; are too open.<br>It is required that your private key files are NOT accessible by others.<br>This private key will be ignored.<br>Load key &quot;/root/.ssh/id_rsa&quot;: bad permissions<br>git@gitlab.com: Permission denied (publickey).<br>fatal: Could not read from remote repository.</pre><pre>Please make sure you have the correct access rights<br>and the repository exists.</pre><p>While this warning won’t let you proceed any further, there is a simple fix to it. Set the file permissions to <em>600</em> (owner read-write) and retry sudo git clone.</p><p>It should work now.</p><h3>Solution 3: Use ‘git clone’ (without sudo)</h3><h4>Amend Permissions of the Target Directory</h4><p>This solution requires a change of file permissions for entire directories. As it’s quite intrusive, this isn’t my favorite option.</p><p>You can actually git clone without the sudo, but will probably run into writing permission errors like these:</p><pre>fatal: could not create work tree dir &#39;api&#39;: Permission denied</pre><p>A workaround is to amend the target’s directory permissions so that your non-root user can clone the necessary files into it. I followed a simple tutorial to <a href="https://www.digitalocean.com/community/questions/permissions-on-var-www-html-for-uploading-web-site-files-via-sftp">correct permissions on /var/www</a>:</p><ol><li>Change the directory owner and group:<br>sudo chown www-data:www-data /var/www</li><li>Allow the group to write to the directory with appropriate permissions:<br>sudo chmod -R 775 /var/www</li><li>Add yourself to the www-data group:<br>sudo usermod -a -G www-data <em>USER</em></li></ol><p>Replace <em>USER</em> with your account’s user name. That’s it. You should now be able to clone into the desired directory under /var/www.</p><h3>Conclusion</h3><p>I hope either one of three solutions suggested above will help you in fixing the persistent permission errors. It’s just a matter of using common sense: SSH-ing with the superuser command means that SSH will look for keys in the root’s home directory.</p><p>Not using the superuser command is generally unconventional. At least it will look up SSH keys in <em>your</em> home directory, but requires appropriate directory writing permissions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f669b65f90ac" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Add a New User to a MongoDB Database]]></title>
            <link>https://matthagemann.medium.com/how-to-add-a-new-user-to-a-mongodb-database-d896776b5362?source=rss-ad3addd7bd55------2</link>
            <guid isPermaLink="false">https://medium.com/p/d896776b5362</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[mongodb]]></category>
            <category><![CDATA[database-administration]]></category>
            <category><![CDATA[database]]></category>
            <dc:creator><![CDATA[Matt Hagemann]]></dc:creator>
            <pubDate>Fri, 09 Nov 2018 11:26:01 GMT</pubDate>
            <atom:updated>2020-01-15T13:52:08.197Z</atom:updated>
            <content:encoded><![CDATA[<h4>After you’ve installed MongoDB, you will want to create separate users for each database to avoid vulnerabilities if any of the users gets compromised. This MongoDB tutorial shows how.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eG2MFl0sGRKFmd_USgA_8Q.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/photos/QckxruozjRg?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Annie Spratt</a> on <a href="https://unsplash.com/search/photos/team?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>If you haven’t installed MongoDB on your server yet, please follow my <a href="https://medium.com/@mhagemann/how-to-install-mongodb-3-6-on-ubuntu-17-10-ac0bc225e648">MongoDB installation guide here</a>. I personally run MongoDB on a <a href="https://m.do.co/c/bc865bbc2fe0">DigitalOcean</a> droplet which was really easy to install. If you like, you can give it a try with a $100 credit by simply following this link:</p><p><a href="https://m.do.co/c/bc865bbc2fe0">DigitalOcean - The developer cloud</a></p><h3>Multiple Database Users vs. Single User</h3><p>Should you maintain multiple database users or a single user with access to all databases? I highly recommend to keep them separate (one user per database). If any of your sites has a vulnerability and gets compromised, someone may use it to gain access to all your other databases. Using a single user puts every other database in danger. If users are restricted to merely one database each, you can be assured that other sites won’t be affected.</p><p>Enter the MongoDB shell with your administration credentials via this command in your terminal:</p><pre>$ mongo -u &#39;your_username&#39; -p &#39;your_password&#39; --authenticationDatabase &#39;admin&#39;</pre><p>You should now see a new line with a &gt; sign, meaning that you can start typing your MongoDB queries. Enter the database you want to add a new user for. Don’t worry about creating that database first because it will be created on the fly.</p><pre>use your_new_database</pre><h3>Create a New MongoDB Database User</h3><p>You have now switched to the database ‘your_new_database’. Create a new user for that database:</p><pre>db.createUser({<br>    user: &#39;new_username&#39;,<br>    pwd: &#39;new_password&#39;,<br>    roles: [<br>        { role: &#39;readWrite&#39;, db: &#39;your_new_database&#39; }<br>    ]<br>})</pre><p>I’m giving the new user merely permission to read and write into the database, hence the readWrite role which is well-documented in <a href="https://docs.mongodb.com/manual/reference/built-in-roles/#readWrite">MongoDB’s docs</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d896776b5362" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Change the Hostname on Ubuntu]]></title>
            <link>https://matthagemann.medium.com/how-to-change-the-hostname-on-ubuntu-9a7615f0ba38?source=rss-ad3addd7bd55------2</link>
            <guid isPermaLink="false">https://medium.com/p/9a7615f0ba38</guid>
            <category><![CDATA[cli]]></category>
            <category><![CDATA[ubuntu]]></category>
            <category><![CDATA[servers]]></category>
            <dc:creator><![CDATA[Matt Hagemann]]></dc:creator>
            <pubDate>Sat, 15 Sep 2018 19:04:29 GMT</pubDate>
            <atom:updated>2019-07-04T09:02:21.434Z</atom:updated>
            <content:encoded><![CDATA[<h4>Whenever you log into your server, you’ll notice a command language interface (CLI) prompt starting with <em>user@hostname</em>. This tutorial shows you how to change that hostname.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*84wQvgcY-qeS92WYYvJBTA.jpeg" /></figure><p><em>This tutorial was originally published on </em><a href="https://gatemill.com/tutorials/how-to-change-the-hostname-on-ubuntu"><em>Gatemill</em></a><em>:</em></p><p><a href="https://gatemill.com/tutorials/how-to-change-the-hostname-on-ubuntu">How to Change the Hostname on Ubuntu</a></p><p>Type the following command to change the hostname with immediate effect:</p><pre>$ sudo hostname &lt;new-hostname&gt;</pre><p>If you re-login to the CLI, you’ll be greeted with that new hostname you have set.</p><h3>Additional Configuration Files to Edit</h3><p>There are additional configuration files to ensure that the hostname is changed across the board. It has been saved in <em>/etc/hostname</em> and <em>/etc/hosts</em>, as well.</p><pre>$ sudo nano /etc/hostname</pre><p>In the text editor, update the hostname to the one above and save by existing and confirming with <em>Yes</em>.</p><p>Let’s proceed to the <em>/etc/hosts</em> file:</p><pre>$ sudo nano /etc/hosts</pre><p>Change 127.0.1.1 &lt;current-hostname&gt; to 127.0.1.1 &lt;new-hostname&gt; and save the file.</p><h3>FQDN Not Written Out by Default</h3><p>The CLI prompt only shows up to the first ‘.’ using the default setup. If you change your hostname to a fully qualified domain name (FQDN) and expect it to show on the CLI prompt, it won’t without a change.</p><p>In case you want the FQDN shown, change the prompt to \H in <em>.bashrc</em>. To find out how to do it exactly, <a href="https://www.digitalocean.com/community/tutorials/how-to-customize-your-bash-prompt-on-a-linux-vps">check out this tutorial</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9a7615f0ba38" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating Command Aliases for the Mac Terminal]]></title>
            <link>https://matthagemann.medium.com/creating-command-aliases-for-the-mac-terminal-5443298ac9ca?source=rss-ad3addd7bd55------2</link>
            <guid isPermaLink="false">https://medium.com/p/5443298ac9ca</guid>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[mac]]></category>
            <dc:creator><![CDATA[Matt Hagemann]]></dc:creator>
            <pubDate>Sat, 08 Sep 2018 16:48:59 GMT</pubDate>
            <atom:updated>2019-12-05T13:42:18.588Z</atom:updated>
            <content:encoded><![CDATA[<h4>You have certainly heard about keyboard shortcuts, but this tutorial will introduce you to something even more powerful: command aliases.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qfby4grbV5OdQ4m7nHCYfw.jpeg" /></figure><p><em>This tutorial was originally published on </em><a href="https://gatemill.com/tutorials/creating-command-aliases-for-the-mac-terminal"><em>Gatemill</em></a><em>:</em></p><p><a href="https://gatemill.com/tutorials/creating-command-aliases-for-the-mac-terminal">Creating Command Aliases for the Mac Terminal</a></p><p>While using Mac’s Terminal, you might be typing the same commands constantly. Wouldn’t you appreciate a way to avoid typing them out all the time with the help of shorthands? There is such a thing and is called an <em>alias</em>.</p><p>I operate several droplets on DigitalOcean, each having their own unique IP address that I have to SSH into regularly from my terminal. To manage this, I’ve associated custom shorthands to actual commands. You can associate them temporarily (for the current Terminal window) or permanently (using a <em>.bash_profile</em> file).</p><h3>Creating a Temporary Alias</h3><p>To create a temporary alias that is valid for the current Terminal session, you will use the following command to create the alias:</p><pre>alias your_shorthand=&quot;actual command to be performed&quot;</pre><p>Any command can be associated with an alias. The following command will let you SSH to an IP address merely by typing in ssh_ip:</p><pre>alias ssh_ip=&quot;ssh root@127.0.0.1&quot;</pre><p>Once the command has been assigned to its alias, you can type in the alias itself to perform the action assigned to the alias.</p><h3>Creating a Permanent Alias</h3><p>It rarely makes sense to keep aliases temporary. Therefore, we are going to create a permanent alias with the help of a file called <em>.bash_profile</em>.</p><p>To edit your <em>.bash_profile</em> file, use the following command:</p><pre>nano ~/.bash_profile</pre><p>This will open nano, a command line text editor. Type in the aliases (one per line) that you wish to save, just as you did when creating a temporary alias.</p><p>When you quit and re-open the Terminal, your aliases will work without having to re-create them each time. Terminal loads your <em>.bash_profile</em> only during launch. Alternatively, you can use the new alias without restarting the Terminal using below command. This tip was kindly provided by <a href="https://medium.com/u/f13002df1ef9">George Deprez</a>.</p><pre>source ~/.bash_profile</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5443298ac9ca" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>