<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Felix Swinkels</title>
    <description>The latest articles on Forem by Felix Swinkels (@tgifelix).</description>
    <link>https://forem.com/tgifelix</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F479946%2F3db87cee-1b8b-4686-9689-5d2796fc71a4.jpeg</url>
      <title>Forem: Felix Swinkels</title>
      <link>https://forem.com/tgifelix</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/tgifelix"/>
    <language>en</language>
    <item>
      <title>Backup Your Dotfiles With Version Control</title>
      <dc:creator>Felix Swinkels</dc:creator>
      <pubDate>Fri, 18 Dec 2020 22:01:46 +0000</pubDate>
      <link>https://forem.com/tgifelix/backup-your-dotfiles-with-version-control-239f</link>
      <guid>https://forem.com/tgifelix/backup-your-dotfiles-with-version-control-239f</guid>
      <description>&lt;p&gt;I came across a &lt;code&gt;dotfiles&lt;/code&gt; repository on GitHub the other day and it instantly made me realize I've been backing up mine wrong! Let’s set up our own GitHub repo and start doing it the right way, today.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Dotfiles are text-based configuration files for Unix tools. By backing them up to GitHub we make sure all our favorite configurations, hacks, and tweaks don’t get lost in case of a system crash. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Let’s go!
&lt;/h2&gt;

&lt;p&gt;Create a folder called dotfiles and copy the files we want to back up.&lt;/p&gt;

&lt;h4&gt;
  
  
  Create the folder
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;dotfiles
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Copy the files you want to backup
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cp&lt;/span&gt; ~/.&amp;lt;filename&amp;gt; ~/dotfiles/.&amp;lt;filename&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For example, I’ve added my &lt;code&gt;.zshrc&lt;/code&gt; and &lt;code&gt;.vimrc&lt;/code&gt; files&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cp&lt;/span&gt; ~/.zshrc ~/dotfiles/.zshrc
&lt;span class="nb"&gt;cp&lt;/span&gt; ~/.vimrc ~/dotfiles/.vimrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  First commit
&lt;/h2&gt;

&lt;p&gt;Create a new repository called &lt;code&gt;dotfiles&lt;/code&gt; on GitHub or use the &lt;a href="https://cli.github.com"&gt;GitHub CLI tool&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  Initialize and add the files
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;dotfiles
git init
git add &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Commit and push
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git commit &lt;span class="nt"&gt;-m&lt;/span&gt; “first commit”
git push origin master
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Automate it!
&lt;/h2&gt;

&lt;p&gt;Let’s create a simple bash script and add it to &lt;code&gt;crontabs&lt;/code&gt; to run automatically.&lt;/p&gt;

&lt;h4&gt;
  
  
  create the script
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="s2"&gt;"#!/bin/bash/"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; backup_dotfiles.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Open the file in your favorite editor and add the following
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# create a timestamp alias for the commit message&lt;/span&gt;
timestamp&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nb"&gt;date&lt;/span&gt; +&lt;span class="s2"&gt;"%d-%m-%Y @ %T"&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;# files to backup&lt;/span&gt;
&lt;span class="nb"&gt;cp&lt;/span&gt; ~/.zshrc ~/dotfiles/.zshrc
&lt;span class="nb"&gt;cp&lt;/span&gt; ~/.vimrc ~/dotfiles/.vimrc

&lt;span class="c"&gt;# pull &amp;amp; push&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="sb"&gt;`&lt;/span&gt;git status &lt;span class="nt"&gt;--porcelain&lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    &lt;/span&gt;git pull origin master
    git add &lt;span class="nb"&gt;.&lt;/span&gt;
    git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"Update: &lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;timestamp&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
    git push origin master
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see I’ve added the &lt;code&gt;.zshrc&lt;/code&gt; and &lt;code&gt;.vimrc&lt;/code&gt; files again. You can add any (config)files you want here!&lt;/p&gt;

&lt;h4&gt;
  
  
  To add the job to cron, type
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;crontab &lt;span class="nt"&gt;-e&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can use &lt;a href="https://crontab.guru"&gt;crontab.guru&lt;/a&gt; to generate how frequent you want the backup script to run. Let’s do every Monday at 10:00 by adding the following line to the cron file and save it&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;0 10 &lt;span class="k"&gt;*&lt;/span&gt; &lt;span class="k"&gt;*&lt;/span&gt; 1 bash backup_dotfiles.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  That’s it!
&lt;/h3&gt;

&lt;p&gt;We’ve created a &lt;a href="https://github.com/tgifelix/dotfiles"&gt;GitHub repo&lt;/a&gt; to back up dotfiles to, and automated the process with a bash script that runs periodically with cron. As always, drop your feedback in the comments! ✌️&lt;/p&gt;

</description>
      <category>dotfiles</category>
      <category>bash</category>
      <category>github</category>
    </item>
    <item>
      <title>Build &amp; Deploy a webpage with Gatsby and Surge</title>
      <dc:creator>Felix Swinkels</dc:creator>
      <pubDate>Fri, 18 Dec 2020 21:36:38 +0000</pubDate>
      <link>https://forem.com/tgifelix/build-deploy-with-gatsby-and-surge-54oh</link>
      <guid>https://forem.com/tgifelix/build-deploy-with-gatsby-and-surge-54oh</guid>
      <description>&lt;p&gt;Welcome to the &lt;strong&gt;first part&lt;/strong&gt; in this &lt;em&gt;mini-series&lt;/em&gt; called &lt;code&gt;Build &amp;amp; Deploy&lt;/code&gt; where I combine tools for building websites and applications plus the tools to deploy them online. Follow my &lt;a href="https://www.tgifelix.com"&gt;&lt;strong&gt;blog&lt;/strong&gt;&lt;/a&gt; or find me on &lt;a href="https://twitter/_tgifelix"&gt;&lt;strong&gt;Twitter&lt;/strong&gt;&lt;/a&gt; for updates!&lt;/p&gt;

&lt;h3&gt;
  
  
  Gatsby &amp;amp; Surge
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;Gatsby&lt;/code&gt; is a React-based open source framework for creating websites and apps. It’s amazingly fast and has a great workflow.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Surge&lt;/code&gt; is a CLI tool that deploys your static pages for free within seconds. In this article, I will show you how to use both to quickly build and deploy a static webpage. &lt;/p&gt;

&lt;h3&gt;
  
  
  Install
&lt;/h3&gt;

&lt;p&gt;Open a terminal and use &lt;a href="https://www.npmjs.com"&gt;npm&lt;/a&gt; to install Gatsby and Surge&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm i &lt;span class="nt"&gt;-g&lt;/span&gt; gatsby-cli surge
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Login to surge&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;surge login
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Build
&lt;/h3&gt;

&lt;p&gt;Create a new project with Gatsby&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gatsby new &amp;lt;project-name&amp;gt;
&lt;span class="c"&gt;# or&lt;/span&gt;
gatsby new &amp;lt;project-name&amp;gt; &amp;lt;starter-repo&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Gatsby offers &lt;a href="https://www.gatsbyjs.com/starters/"&gt;a great bunch of free templates&lt;/a&gt; on their website to get started quickly!&lt;/p&gt;

&lt;p&gt;Fire it up!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; &amp;lt;project-name&amp;gt;
gatsby develop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;develop&lt;/code&gt; command starts a development server where you can interact with your webpage while you're building. You can access it locally at &lt;code&gt;http://localhost:8000/&lt;/code&gt;. To learn more about the Gatsby file structure check out: &lt;a href="https://www.gatsbyjs.com/docs/gatsby-project-structure/"&gt;Gatsby Project Structure&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;When you are finished making your webpage &lt;strong&gt;awesome&lt;/strong&gt;, run the &lt;code&gt;build&lt;/code&gt; command to generate an optimized static HTML site in the &lt;code&gt;public&lt;/code&gt; folder&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gatsby build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;br&gt;
shell&lt;br&gt;
You can test the production by running the &lt;code&gt;serve&lt;/code&gt; command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gatsby serve
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Deploy
&lt;/h3&gt;

&lt;p&gt;Surge offers many awesome futures but works as simple as typing &lt;code&gt;surge&lt;/code&gt; in your public folder.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;public
surge
&lt;span class="c"&gt;# or&lt;/span&gt;
surge public/
&lt;span class="c"&gt;# or&lt;/span&gt;
surge public/ &amp;lt;your-domain&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And &lt;strong&gt;BAM&lt;/strong&gt;! Your webpage is live! &lt;/p&gt;

&lt;p&gt;Create a &lt;code&gt;CNAME&lt;/code&gt; document with the URL to skip the prompt on your next &lt;em&gt;surge&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &amp;lt;your-url&amp;gt;.surge.sh &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; CNAME
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or use a custom domain name&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo &lt;/span&gt;your-website.com &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; CNAME
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To use a custom domain name, the &lt;code&gt;DNS&lt;/code&gt; from the domain provider will need to be changed. More info: &lt;a href="https://surge.sh/help/adding-a-custom-domain"&gt;Adding a custom domain&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  WTH just happened?
&lt;/h4&gt;

&lt;p&gt;We’ve built a &lt;code&gt;static webpage&lt;/code&gt; with &lt;code&gt;Gatsby&lt;/code&gt; and deployed it to &lt;code&gt;Surge&lt;/code&gt; with these commands&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm i &lt;span class="nt"&gt;-g&lt;/span&gt; gatsby-cli surge
surge login
gatsby new &amp;lt;project-name&amp;gt;
gatsby develop
gatsby build
gatsby serve
surge
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h4&gt;
  
  
  Resources
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.gatsbyjs.com/"&gt;gatsbyjs.com&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.surge.sh"&gt;surge.sh&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>gatsby</category>
      <category>surge</category>
      <category>build</category>
      <category>deploy</category>
    </item>
  </channel>
</rss>
