<?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>DEV Community: Quentin Delcourt</title>
    <description>The latest articles on DEV Community by Quentin Delcourt (@kant312).</description>
    <link>https://dev.to/kant312</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%2F205174%2F29133abb-4c98-4944-a7b9-30a8f1f93a6b.jpg</url>
      <title>DEV Community: Quentin Delcourt</title>
      <link>https://dev.to/kant312</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kant312"/>
    <language>en</language>
    <item>
      <title>Opinions worth sharing</title>
      <dc:creator>Quentin Delcourt</dc:creator>
      <pubDate>Fri, 07 Aug 2020 22:46:40 +0000</pubDate>
      <link>https://dev.to/kant312/opinions-worth-sharing-3655</link>
      <guid>https://dev.to/kant312/opinions-worth-sharing-3655</guid>
      <description>&lt;p&gt;Very often in my career, I was faced with colleagues or managers' decisions that I thought would bring some trouble.&lt;/p&gt;

&lt;p&gt;There is sometimes an opportunity, before the decision starts actually triggering real life effects, where there is still time to raise your voice and share your concerns with your team.&lt;/p&gt;

&lt;p&gt;I am not an extrovert and convincing people has never been my forte, which sometimes prevented me to speak when I should have spoken.&lt;/p&gt;

&lt;p&gt;I once heard about a decision to change a legacy CMS to replace it with a brand new, also custom CMS. On top of bringing absolutely zero new advantage to the end users, I also knew about &lt;a href="https://www.joelonsoftware.com/2000/04/06/things-you-should-never-do-part-i/"&gt;Spolsky's law&lt;/a&gt;, aka you never rewrite a software from scratch.&lt;/p&gt;

&lt;p&gt;I tried to fight it, but struggled to make my point. I gave up pretty quickly and thought that maybe the people leading the decision knew better. Despite my gut feeling. And of course I was very wrong.&lt;/p&gt;

&lt;p&gt;I should have make my voice heard and share my opinions. The decision led us to many performance problems and a system that was not necessarily better than the previous one. And no gain for the end users. Hence, by not raising my voice, I brought myself in a very uncomfortable situation.&lt;/p&gt;

&lt;p&gt;When you think something is not right, don't  keep it to yourself, share it with your colleagues. You might thank you later 🙂&lt;/p&gt;




&lt;p&gt;&lt;span&gt;Cover photo by &lt;a href="https://unsplash.com/@snowshade?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Oleg Laptev&lt;/a&gt; on &lt;a href="https://unsplash.com/?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Unsplash&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;

</description>
      <category>culture</category>
      <category>communication</category>
      <category>work</category>
      <category>opinion</category>
    </item>
    <item>
      <title>Computer science students: do you have classes about tools?</title>
      <dc:creator>Quentin Delcourt</dc:creator>
      <pubDate>Tue, 04 Aug 2020 19:24:11 +0000</pubDate>
      <link>https://dev.to/kant312/computer-science-students-do-you-have-classes-about-tools-345l</link>
      <guid>https://dev.to/kant312/computer-science-students-do-you-have-classes-about-tools-345l</guid>
      <description>&lt;p&gt;I'm talking about things like version control, the command line, IDEs, etc.&lt;br&gt;
Things that are wonderfully explained in the following MIT course, "The Missing Semester of your CS Education"&lt;br&gt;
&lt;a href="https://missing.csail.mit.edu/"&gt;https://missing.csail.mit.edu/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And I'm wondering, since I got out of school in 2004 and such classes weren't in the cursus: is it still the case? And is there a difference between "classic" schools and bootcamps?&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>computerscience</category>
      <category>students</category>
    </item>
    <item>
      <title>Vim Survival Toolkit</title>
      <dc:creator>Quentin Delcourt</dc:creator>
      <pubDate>Tue, 30 Jun 2020 12:48:28 +0000</pubDate>
      <link>https://dev.to/kant312/vim-survival-toolkit-1fbn</link>
      <guid>https://dev.to/kant312/vim-survival-toolkit-1fbn</guid>
      <description>&lt;p&gt;TL;DR Skip to the commands.&lt;/p&gt;




&lt;p&gt;I used to hate Vim. &lt;/p&gt;

&lt;p&gt;Back when I was in CS school, teachers took great pleasure in forcing us to use this dinosaur tool that you can only despise after 5 minutes of use. But nowadays I can thank my teachers for getting all this knowledge into my head.&lt;/p&gt;

&lt;p&gt;Indeed, you don't always have the opportunity to have an Atom, a VSCode or a PHPStorm to edit a file.&lt;br&gt;
Sometimes, you have to log in with SSH on a production server to remove a "," from a configuration file that is currently rendering the said server unusable.&lt;br&gt;
And then the ony editor at your disposal might be Vim.&lt;/p&gt;

&lt;p&gt;There are people who use Vim as an IDE, but I'm not among them. Instead, I have a basic knowledge of it that allows me to do only&lt;br&gt;
the very necessary and most simple stuff. Editing, moving around, saving, and most importantly when it comes to Vim: quitting.&lt;/p&gt;

&lt;p&gt;The commands below are, in my humble opinion, the only essential commands you need to know in order to survive with Vim.&lt;/p&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Editing
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
i 👉 start editing at the current position&lt;/li&gt;
&lt;li&gt;
a  👉 same but moves the carret to the next char&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Exiting
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
ESC  👉 gets you back in "command" mode and stops edition of the file&lt;/li&gt;
&lt;li&gt;
:q↩️  👉 quit&lt;/li&gt;
&lt;li&gt;
:q!↩️  👉 quit even if changes were made&lt;/li&gt;
&lt;li&gt;
ZZ↩️  👉 save and quit&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Searching
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
/something↩️ 👉 Finds "something" in the file and moves the carret to the first found occurrence&lt;/li&gt;
&lt;li&gt;
n 👉 Finds the next occurrence of the word you searched for and moves the carret to it&lt;/li&gt;
&lt;li&gt;
N 👉 Previous&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Undoing
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
u 👉 Undo&lt;/li&gt;
&lt;li&gt;
Ctrl + r 👉 Redo&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Moving
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
G 👉 Go to the end of the file&lt;/li&gt;
&lt;li&gt;
gg 👉 Go back to the start of the file&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Playing with lines
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
o 👉 Insert a new line below the carret&lt;/li&gt;
&lt;li&gt;
O 👉 Insert new line above the carret&lt;/li&gt;
&lt;li&gt;
dd 👉 Remove the current line&lt;/li&gt;
&lt;li&gt;
5dd 👉 Remove 5 lines starting from the current line (but you can enter any number you want)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These commands have allowed multiple production servers to be saved over the last 15 years 😁&lt;/p&gt;

</description>
      <category>cheatsheet</category>
      <category>vim</category>
      <category>linux</category>
      <category>devops</category>
    </item>
    <item>
      <title>Don't call jsonSerialize() explicitly</title>
      <dc:creator>Quentin Delcourt</dc:creator>
      <pubDate>Wed, 24 Jun 2020 22:58:07 +0000</pubDate>
      <link>https://dev.to/kant312/don-t-call-jsonserialize-explicitly-28ed</link>
      <guid>https://dev.to/kant312/don-t-call-jsonserialize-explicitly-28ed</guid>
      <description>&lt;p&gt;TL;DR don't call &lt;code&gt;jsonSerialize()&lt;/code&gt; directly, always pass the object implementing it to the &lt;code&gt;json_encode&lt;/code&gt; function.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;JsonSerializable&lt;/code&gt; is a &lt;a href="https://www.php.net/manual/en/class.jsonserializable.php"&gt;handy PHP feature&lt;/a&gt; that was introduced in PHP 5.4.&lt;br&gt;
It lets you define how an object should be transformed into JSON when passed to the &lt;code&gt;json_encode&lt;/code&gt; function.&lt;br&gt;
For example, if you were to order a box of chocolate and send a preview of it to someone you offer it to,&lt;br&gt;
you might want to show the content of the box but not its price.&lt;/p&gt;

&lt;p&gt;By defining an array of properties (but the return value could be anything that could be serialized to JSON), you get to decide what information will be returned in the resulting JSON:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;final&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ChocolateBox&lt;/span&gt; &lt;span class="k"&gt;implements&lt;/span&gt; &lt;span class="nx"&gt;JsonSerializable&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nv"&gt;$price&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;array&lt;/span&gt; &lt;span class="nv"&gt;$chocolates&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="cm"&gt;/* Magic code to build the box... */&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;jsonSerialize&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="k"&gt;array&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="s1"&gt;'chocolates'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;chocolates&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;];&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;So far, so good.&lt;br&gt;
And then, in the client, usually a controller, I sometimes see this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;final&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ChocolateBoxController&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;indexAction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Request&lt;/span&gt; &lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ChocolateBoxService&lt;/span&gt; &lt;span class="nv"&gt;$chocolateBoxService&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Response&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$chocolateBox&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$chocolateBoxService&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;getRandomBox&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="nb"&gt;json_encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$chocolateBox&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;jsonSerialize&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
        &lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;👆 Can you spot the problem in the code above?&lt;/p&gt;

&lt;p&gt;We're calling &lt;code&gt;json_encode&lt;/code&gt; and passing it the result of the &lt;code&gt;jsonSerialize&lt;/code&gt; method.&lt;br&gt;
That's not the idea... &lt;code&gt;json_encode&lt;/code&gt; actually knows about the existence of the function if the object it's being passed&lt;br&gt;
implements the JsonSerializable interface.&lt;/p&gt;

&lt;p&gt;Therefore, simply passing the object to &lt;code&gt;json_encode&lt;/code&gt; is enough:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nb"&gt;json_encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$chocolateBox&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;👇 gives us&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;chocolates&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="cm"&gt;/* delicious list of chocolates */&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;It even works when you bury the object in another structure, such as an array:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nb"&gt;json_encode&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
    &lt;span class="s1"&gt;'data'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$chocolateBox&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;👇 gives us&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;data&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;chocolates&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="cm"&gt;/* delicious list of chocolates */&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;By implementing the interface you allow &lt;code&gt;json_encode&lt;/code&gt; to get what it needs out of an object.&lt;br&gt;
Your work stops right after that, let &lt;code&gt;json_encode&lt;/code&gt; do the rest...&lt;/p&gt;




&lt;p&gt;Originally published on &lt;a href="https://quentin.delcourt.be"&gt;quentin.delcourt.be&lt;/a&gt;&lt;/p&gt;

</description>
      <category>php</category>
      <category>oop</category>
      <category>codequality</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Deploy an Eleventy website using GitLab CI</title>
      <dc:creator>Quentin Delcourt</dc:creator>
      <pubDate>Tue, 11 Feb 2020 13:07:30 +0000</pubDate>
      <link>https://dev.to/kant312/deploy-an-eleventy-website-using-gitlab-ci-5249</link>
      <guid>https://dev.to/kant312/deploy-an-eleventy-website-using-gitlab-ci-5249</guid>
      <description>&lt;p&gt;&lt;em&gt;Here's how to use GitLab CI to easily deploy a static website to a virtual private server.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;When choosing a hosting solution for a static website, there are free and very powerful solutions like &lt;a href="https://netlify.com"&gt;Netlify&lt;/a&gt;  or &lt;a href="https://github.com"&gt;GitHub&lt;/a&gt;.&lt;br&gt;
The former especially excels in providing very easy and lighting fast solution to deploy a website in matter of seconds.&lt;/p&gt;

&lt;p&gt;But what if you want to develop on a good old VPS or metal server, going the self-hosted route?&lt;br&gt;
You might already need your server for other applications and use it as well for static content hosting.&lt;/p&gt;

&lt;p&gt;Wen you used a few automation tools, there is no way back to that time where we were uploading manually our files using (S)FTP.&lt;/p&gt;

&lt;p&gt;Fortunately, you can avoid the chores of manual upload by using a tool such as &lt;a href="https://about.gitlab.com/stages-devops-lifecycle/continuous-integration/"&gt;GitLab CI&lt;/a&gt;.&lt;br&gt;
This allows you to, for example, trigger a copy of the changed files whenever the master branch is updated.&lt;br&gt;
Most of GitLab CI configuration is not done via the GitLab app but rather using a YAML file &lt;em&gt;(it seems most things these days are configured using YAML files)&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;This is the GitLab CI configuration (&lt;code&gt;.gitlab-ci.yml&lt;/code&gt;) I created to automatically push changes to the server.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;stages:
  - build
  - deploy

eleventy:
  stage: build
  image: node:lts-buster
  cache:
    key: "$CI_JOB_NAME"
    paths:
      - node_modules/
  script:
    - npm install
    - npm run build
  artifacts:
    paths:
      - dist/
  only:
    - master

rsync:
  stage: deploy
  image: instrumentisto/rsync-ssh
  script:
  - mkdir "${HOME}/.ssh"
  - echo "${SSH_HOST_KEY}" &amp;gt; "${HOME}/.ssh/known_hosts"
  - echo "${SSH_PRIVATE_KEY}" &amp;gt; "${HOME}/.ssh/id_rsa"
  - chmod 700 "${HOME}/.ssh/id_rsa"
  - rsync -avH dist/* -e ssh ${SSH_USER}@${SSH_HOST}:${WEBROOT_PATH}
  only:
  - master
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;There are two main things happening here:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Eleventy generates the static files.&lt;/li&gt;
&lt;li&gt;The changes are copied to the server.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Defining the order of stages
&lt;/h2&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;stages:
  - build
  - deploy
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The block above will tell GitLab CI to execute all jobs from the build stage first, then the deploy stage.&lt;br&gt;
You can declare several jobs in the configuration file and assign each of these jobs to a particular stage.&lt;/p&gt;
&lt;h2&gt;
  
  
  Build stage
&lt;/h2&gt;

&lt;p&gt;The build stage is for installing all node.js dependencies and run Eleventy to generate the static files.&lt;/p&gt;

&lt;p&gt;We define a "eleventy" job and assign it to the "build" stage:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;eleventy:
  stage: build
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;code&gt;image&lt;/code&gt; is to attach a specific container image to the job. Here we'll use a long term support node version:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  image: node:lts-buster
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The cache is really important to make the deploy faster: it allows us to keep the node_modules folder from&lt;br&gt;
one deployment to the other. Here we use the job's name as key for the cache, so that only this job&lt;br&gt;
retrieves the cache, it will not be used on other cases:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  cache:
    key: "$CI_JOB_NAME"
    paths:
      - node_modules/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now we define the job's work by defining a set of bash instructions to be executed.&lt;br&gt;
We install the node modules and run eleventy:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  script:
    - npm install
    - npm run build
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Our files are generated, we need to store them somewhere to send them on the server.&lt;br&gt;
To accomplish that, GitLab CI provides the "artifacts" system.&lt;br&gt;
We can define the files that will be saved in the artifact and reuse them in another job:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  artifacts:
    paths:
      - dist/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Finally, we ask GitLab CI to run this job only when a commit is pushed to the master branch:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  only:
  - master
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Deploy stage
&lt;/h2&gt;

&lt;p&gt;To deploy the files on my server I use a combination of Rsync and SSH.&lt;br&gt;
The good news is that there is a Docker container that has these two dependencies installed directly, no need to install them at runtime 😎&lt;br&gt;
So let's declare a new job and, for this one, we'll use this new image:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rsync:
  stage: deploy
  image: instrumentisto/rsync-ssh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The first part of the job is to create an SSH configuration within the new container:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  script:
  - mkdir "${HOME}/.ssh"
  - echo "${SSH_HOST_KEY}" &amp;gt; "${HOME}/.ssh/known_hosts"
  - echo "${SSH_PRIVATE_KEY}" &amp;gt; "${HOME}/.ssh/id_rsa"
  - chmod 700 "${HOME}/.ssh/id_rsa"
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;All of these information are very sensitive, that is why we don't store them directly in the .yml, which will&lt;br&gt;
be commited in the repository. Instead we can make use of &lt;a href="https://gitlab.com/help/ci/variables/README#variables"&gt;GitLab CI's environment variables&lt;/a&gt;.&lt;br&gt;
To define these variables, you can go in your repository's settings on GitLab and add the necessary variables there.&lt;/p&gt;

&lt;p&gt;The second part of the script takes care of using rsync to send the changes over SSH:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- rsync -avH dist/* -e ssh ${SSH_USER}@${SSH_HOST}:${WEBROOT_PATH}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;dist&lt;/code&gt; folder will be available to this job, as it was declared as an artifact in the eleventy job.&lt;/p&gt;

&lt;p&gt;Finally, we once again ask GitLab CI to run this job only whenever a change is pushed on the master branch:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  only:
  - master
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;And... voilà!&lt;br&gt;
Now we can push our changes on master and they will be automatically deployed on the server, nothing more to do! 🎊 🎉&lt;/p&gt;

&lt;p&gt;You can find a complete copy of this script on gist:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://gist.github.com/kant312/da097ad3f91ecc110792df54a95ed82f"&gt;https://gist.github.com/kant312/da097ad3f91ecc110792df54a95ed82f&lt;/a&gt;&lt;/p&gt;

</description>
      <category>devops</category>
      <category>tutorial</category>
      <category>git</category>
      <category>node</category>
    </item>
    <item>
      <title>The Demo Effect</title>
      <dc:creator>Quentin Delcourt</dc:creator>
      <pubDate>Wed, 29 Jan 2020 10:36:46 +0000</pubDate>
      <link>https://dev.to/kant312/the-demo-effect-4i74</link>
      <guid>https://dev.to/kant312/the-demo-effect-4i74</guid>
      <description>&lt;p&gt;Developers worldwide share a few common fears: the time when a project manager&lt;br&gt;
asks for an estimate, the fear of being an impostor, the fear of not delivering&lt;br&gt;
on time for a deadline. And then there's a very scary thing that is known in the&lt;br&gt;
development world as the "Demo Effect".&lt;/p&gt;

&lt;p&gt;The Demo Effect happens whenever you need to present your (supposedly finished, &lt;br&gt;
or almost) work to a client, an N+1 or any other kind of spectator.&lt;br&gt;
You will, with pride, show the features you've been working on for &lt;br&gt;
[weeks|months|years]. You feel very confident, you tested it all before,&lt;br&gt;
and all of a sudden, the&lt;br&gt;
application crashes in front of your audience.&lt;br&gt;
This is the &lt;strong&gt;Demo Effect&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Why is it happening? We developers tend to be biased and use data that will&lt;br&gt;
fit our best case scenarios. Once we start fiddling with more realistic data&lt;br&gt;
for the sake of our presentation, that's where the cracks in our programs&lt;br&gt;
begin to appear.&lt;/p&gt;

&lt;h2&gt;
  
  
  DDD: Demo Driven Development
&lt;/h2&gt;

&lt;p&gt;My company recently adopted a new habit, which is the "Friday demo".&lt;br&gt;
The format is quite simple: each department has someone on their team&lt;br&gt;
doing a little, 5 minutes presentation. This is a good idea as the short&lt;br&gt;
format reduces the pressure (it's not like you're doing a one hour talk).&lt;/p&gt;

&lt;p&gt;Our team was asked to present something, and I thought that&lt;br&gt;
I could demo one of our most advanced, but still in development feature.&lt;/p&gt;

&lt;p&gt;I tested many things beforehand and thought that the feature was&lt;br&gt;
ready to go to QA. So naturally I thought this would be a piece of cake.&lt;br&gt;
And of course I was very wrong.&lt;/p&gt;

&lt;p&gt;I started inserting records with real names of real people. With extended&lt;br&gt;
latin characters. That's where I noticed there were collation problems&lt;br&gt;
with the database.&lt;/p&gt;

&lt;p&gt;I started having more than 10 records in my test DB, which showed problems&lt;br&gt;
with the pagination system.&lt;/p&gt;

&lt;p&gt;I started using the application a lot, instead of testing it, which showed&lt;br&gt;
me there were some async problems, and some other bugs.&lt;/p&gt;

&lt;p&gt;I later explained that to my colleagues and, as a joke, said we could now do&lt;br&gt;
DDD: Demo Driven Development. But it might be a really good thing to keep doing&lt;br&gt;
that once in a while, as it helps us get into the users shoes.&lt;/p&gt;

&lt;p&gt;I might start doing &lt;strong&gt;Demo Driven Development&lt;/strong&gt; from now on, and overcome my fear&lt;br&gt;
of the Demo Effect.&lt;/p&gt;

</description>
      <category>testing</category>
      <category>agile</category>
    </item>
  </channel>
</rss>
