<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://jeremydagorn.com/feed.xml" rel="self" type="application/atom+xml" /><link href="https://jeremydagorn.com/" rel="alternate" type="text/html" /><updated>2026-07-19T14:48:39+00:00</updated><id>https://jeremydagorn.com/feed.xml</id><title type="html">Jeremy Dagorn - Software Engineer and Crêpe Maker.</title><subtitle></subtitle><entry><title type="html">Becoming a farmer, kind of.</title><link href="https://jeremydagorn.com/2023/11/09/becoming-a-farmer-kind-of.html" rel="alternate" type="text/html" title="Becoming a farmer, kind of." /><published>2023-11-09T00:00:00+00:00</published><updated>2023-11-09T00:00:00+00:00</updated><id>https://jeremydagorn.com/2023/11/09/becoming-a-farmer-kind-of</id><content type="html" xml:base="https://jeremydagorn.com/2023/11/09/becoming-a-farmer-kind-of.html"><![CDATA[<p><em>Note: This is a pretty unedited post. More of a reflection or venting or rambling. Don’t read too much into it.</em></p>

<p>Almost a full year has passed since my last post. I guess the resolution of trying to write once a week was a failure, once again. At least I am consistent in the way I fail. This year has been tough in some ways, I keep going back and forth actually. Last year’s trip was mainly to discover parts of the US we’ve never been to, but also had a secondary objective to take a breather from work as it was a bit too much front and center. I have been feeling that my passion for writing software has been decreasing slowly. I have been feeling desillusioned about the industry, and how inefficient software companies are in terms of energy spent doing - not much. I thought focusing on something else would help in recovering some of that lost passion, but, well, didn’t happen.</p>

<p>There has been this trend (or meme) about software engineers wanting to pivot to becoming farmers. This is pretty amusing as being a farmer is so much harder than being working on software. We have cushy jobs, mostly working from home, while not breaking our backs. Nonetheless, the idea of becoming a farmer is more about being able of reaping the benefits of our work directly, while doing some good I guess, and being self-sustainable probably?</p>

<p>The meme has merit. The more I think about it, the more I feel like my perfect job would be to own my little software company. I don’t dream of anything big. I would want to find a niche problem to fix through software, write the code, deploy it, debug it, add some new features that make sense here and there. Seeing people using my software and like it would be a great feeling.
I think the closest I got to that was when I worked on iheartreading, a “track your reading” web application that was used by a few classrooms when my wife was still a teacher. Hearing “they tried to do &lt;this&gt; but &lt;that&gt; broke” was almost magical (sure, it was broken, but they used it! I can just fix it quickly).</p>

<p>Bref, I am rambling. I guess that’s kind of the point of that post, just letting thoughts out.</p>

<p><em>What about the title?</em><br /></p>

<p>Oh yeah, we moved from San Diego, California to Buffalo, NY.<br /></p>

<p><em>Wait why? It is so cold</em>.<br /></p>

<p>I don’t know, we wanted a change.<br /></p>

<p><em>What about the farmer part?</em> <br /></p>

<p>Oh, we bought something that will need some minor renovation work. I am not handy whatsoever. I could not drill with the hammer to save my life! (Attempt at humor here, let me know). So yeah not becoming a farmer, but at least my mind will be somewhat busy with non-work stuff on my free time. I won’t feel pressure about not having side projects, or not playing with new libraries or framework, or leetcoding. I will just be thinking about what I need to do to make our place super nice, as cheaply as possible.<br /></p>

<p>Isn’t it crazy what the software industry has become? If you don’t know how to use &lt;insert new framework of the month here&gt; a week after it is out, you are made to be obsolete?</p>

<p>I really have a dislike for tech influencers. I get it, you promote your stuff, but god it is annoying. I hate resume-driven development. I don’t care about Astro or Next.js, or React Server components. I just care about fixing problems, and will figure out what solution I should be using in a pragmatic way when it comes to it.
I am at the point where I start to see the wheel being reinvented, and people touting those new approaches as the best thing since sliced bread. Honestly, just give me Laravel or Rails. Perfect solutions 99% of the time for 99% of problems out there.</p>

<p>Bref, I am rambling. I wish I could go back to being a junior. You know, kind of when older people were telling you as you were growing up: “Enjoy those years, they fly by”. That’s how I feel now, “Enjoy your junior years, when you are just a sponge, everything is exciting, you just need to code, figure out things without too much pressure”. Ah, how I wish I could be a junior for life (if money was not an issue of course). No ADRs to write, no performance feedback to give, <a href="https://blog.idonethis.com/sandwich-feedback-performance-management/">no shit sandwich</a> to manage when bringing up issues, no “don’t bring problems if you don’t have solution” speeches, no agile-_ish_ ceremonies when you are delivering software in a waterfall fashion, not being aware of execs compensated 150 times what ICs are. Just living in an idealized world of feeling excited when your small and mighty PRs get approved, or feeling stressed out when you broke a build and it felt like the end of the world. Now? The build broke, yeah, those tests haven’t passed in two years. How come? Oh who knows, reorgs and change of ownership I guess? I don’t know, I just work here.</p>

<p>Bref, I am rambling.</p>]]></content><author><name></name></author><summary type="html"><![CDATA[Note: This is a pretty unedited post. More of a reflection or venting or rambling. Don’t read too much into it.]]></summary></entry><entry><title type="html">Setting up a database the hard way in 2023</title><link href="https://jeremydagorn.com/2023/02/10/database-access-the-hard-way.html" rel="alternate" type="text/html" title="Setting up a database the hard way in 2023" /><published>2023-02-10T00:00:00+00:00</published><updated>2023-02-10T00:00:00+00:00</updated><id>https://jeremydagorn.com/2023/02/10/database-access-the-hard-way</id><content type="html" xml:base="https://jeremydagorn.com/2023/02/10/database-access-the-hard-way.html"><![CDATA[<p>As I am coming back from a 10-weeks long trip across the US, living the camper life, I thought it could be fun to create a small website to showcase where we went through pictures, and potentially some blog posts about living in a van, while working on the road (disclaimer: you don’t really work <strong>from</strong> the van).</p>

<p>I could have kept a very minimal setup, for example a simple static site where I could display a bunch of pictures, but I wanted something a bit more dynamic. I always wanted to explore Next.js, so I decided on using Next.js and Vercel, with Prisma as an ORM. I used Swarm to keep track of cool places we have been to, so I have some scripts to fetch those checkins through the Foursquare API and display them on a map. OK, I could use a simple JSON file to hold those checkins, but where is the fun in that!</p>

<h3 id="creating-an-ec2-instance-with-terraform-and-install-mariadb">Creating an EC2 instance with Terraform, and install MariaDB.</h3>
<p>Using AWS RDS felt overkill for this, and I like to stay in the free tier in AWS as much as possible. I decided on using a micro EC2 instance where I would install MariaDB on it. I don’t want to do it through the UI, so I could use Cloudformation for IAC (Infrastructure as Code). Not having experience with Terraform, and having a few side-projects to work on in mind, I decided on using it for this project as the initial one.</p>

<p>Terraform supports modules to simplify reusability, and help in keeping things a bit more separated.
My infra structure is as follow for now:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>.
├── README.md
├── config.s3.tfbackend
├── main.tf
├── modules
│   ├── test-module
│   │   ├── ec2-user-data-db-cache.sh
│   │   ├── main.tf
│   │   ├── outputs.tf
│   │   └── variables.tf
│   ├── network
│   │   ├── main.tf
│   │   ├── outputs.tf
│   │   └── variables.tf
│   └── security
│       ├── main.tf
│       ├── outputs.tf
│       └── variables.tf
├── secret.tfvars
├── terraform.tfstate
├── terraform.tfstate.backup
└── variables.tf
</code></pre></div></div>

<p>I created a new module for this specific project, and use it in my main module (main.tf at the project root):</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>locals {
  region = "us-west-1"
}

terraform {

  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "&gt;= 2.7.0"
    }
  }

  backend "s3" {
  }
}

provider "aws" {
  region = local.region
}

module "network" {
  source = "./modules/network"
}

module "test-module" {
  source = "./modules/test-module"

  public_subnet_id  = module.network.public_subnet_id
  ec2_key_pair_name = var.ec2_key_pair_name
}

</code></pre></div></div>

<p>By doing it that way, I can keep things mostly scoped to a single project, while the big pieces of my infrastructure (VPC, Security groups and so on) are kept at a higher level. I like to think of it as the base building blocks, and then each project is a more specialized block that focus only on what is needed for it, the rest is already taken care of.</p>

<p>Granted, for now, we don’t need much for this project, we need to have a single EC2 instance.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>resource "aws_instance" "test-instance" {
  ami = "ami-00d8a762cb0c50254"

  instance_type = "t3.micro"
  tags = {
    Name      = "test-instance"
    Terraform = true
  }

  subnet_id = var.public_subnet_id # defined in network module
  key_name  = var.ec2_key_pair_name # passed in from secrets.tfvars file
}
</code></pre></div></div>

<p>The <code class="language-plaintext highlighter-rouge">tfvars</code> file is the equivalent of a <code class="language-plaintext highlighter-rouge">.env</code> file that is commonly used to hold environment variables. This is how I visualize it at least!</p>

<p>When applying our changes with Terraform, we can pass a file containing our secret variables to be used:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>terraform apply -var-file="secret.tfvars"
</code></pre></div></div>

<p><img src="/assets/img/database-access-the-hard-way/terraform-apply.png" alt="Terraform apply in command line" /></p>

<p>Let’s type <code class="language-plaintext highlighter-rouge">yes</code> and here we go!</p>

<p><img src="/assets/img/database-access-the-hard-way/ec2-creation.png" alt="Created EC2 instance" /></p>

<h4 id="setting-up-mariadb">Setting up MariaDB</h4>

<p>When an EC2 instance is created, there is a way to run a user script after it is successfully booted. This is what we are going to use to install MariaDB.</p>

<p>The first part of this section will focus on what is available to us on a barebone EC2 instance, as it comes with a lot of things out of the box! Then, the second part will give some more details about the Terraform configuration and how we should apply those changes if we already have an existing instance.</p>

<p>The AMI we used for our EC2 instance is Amazon Linux 2, and it comes with the <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/amazon-linux-ami-basics.html#extras-library">Extras library</a>, which lets us install some specific packages (known as topic easily).</p>

<p>To see what’s available to use, let’s run <code class="language-plaintext highlighter-rouge">amazon-linux-extras list</code>.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> ...
 38  nginx1                   available    [ =stable ]
 39  ruby2.6                  available    [ =2.6  =stable ]
 40  mock                     available    [ =stable ]
 41  postgresql11             available    [ =11  =stable ]
 43  livepatch                available    [ =stable ]
 44  python3.8                available    [ =stable ]
 45  haproxy2                 available    [ =stable ]
 46  collectd                 available    [ =stable ]
 47  aws-nitro-enclaves-cli   available    [ =stable ]
 48  R4                       available    [ =stable ]
  _  kernel-5.4               available    [ =stable ]
 50  selinux-ng               available    [ =stable ]
 51  php8.0                   available    [ =stable ]
 52  tomcat9                  available    [ =stable ]
 53  unbound1.13              available    [ =stable ]
 54  mariadb10.5              available    [ =stable ]
 55  kernel-5.10=latest       enabled      [ =stable ]
 56  redis6                   available    [ =stable ]
</code></pre></div></div>

<p>We can see that mariadb is available. Let’s enable and install it:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo amazon-linux-extras enable mariadb10.5
sudo yum clean metadata
sudo yum install mariadb10.5
</code></pre></div></div>

<p>Now the service is still not running, we use to start it with <code class="language-plaintext highlighter-rouge">systemctl</code>.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo systemctl start mariadb
</code></pre></div></div>

<p>You can verify it is running by issuing <code class="language-plaintext highlighter-rouge">sudo systemctl status mariadb</code> and see that it is marked as <code class="language-plaintext highlighter-rouge">active</code>:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>● mariadb.service - MariaDB 10.5 database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
   Active: active (running) since Sun 2023-02-12 00:27:10 UTC; 3s ago
     Docs: man:mariadbd(8)
           https://mariadb.com/kb/en/library/systemd/
  Process: 6462 ExecStartPost=/usr/libexec/mariadb-check-upgrade (code=exited, status=0/SUCCESS)
  Process: 6299 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS)
  Process: 6275 ExecStartPre=/usr/libexec/mariadb-check-socket (code=exited, status=0/SUCCESS)
 Main PID: 6408 (mariadbd)
   Status: "Taking your SQL requests now..."
   CGroup: /system.slice/mariadb.service
           └─6408 /usr/libexec/mariadbd --basedir=/
</code></pre></div></div>

<p>We also want to make sure it is restarted everytime we reboot our EC2 instance. Once again, <code class="language-plaintext highlighter-rouge">systemctl</code> is the tool to use: <code class="language-plaintext highlighter-rouge">sudo systemctl enable mariadb</code>.</p>

<p>This is where our automation will stop for now. We still need to setup a secure installation for mariadb. To get started enter <code class="language-plaintext highlighter-rouge">sudo mysql_secure_installation</code> and follow the prompts.
It is possible to automate what you provide to <code class="language-plaintext highlighter-rouge">mysql_secure_installation</code> but I didn’t spend much time trying to figure it out so that we don’t have to store passwords in plain-text in some random script, so I skipped over for the sake of time.</p>

<h4 id="creating-our-user-data-script">Creating our user-data script</h4>

<p>In the previous section, we went through those steps manually, but we can automate all of it up to <code class="language-plaintext highlighter-rouge">mysql_secure_installation</code>. We will rely on a <a href="TODO add ref">user data script</a> for this and make it run as part of our Terraform <code class="language-plaintext highlighter-rouge">apply</code> command.</p>

<p>The script is run as a super user, so no need to specify <code class="language-plaintext highlighter-rouge">sudo</code> for each of the commands.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>#!/bin/bash
yum update -y #auto-approve
amazon-linux-extras install epel -y
amazon-linux-extras enable mariadb10.5
yum clean metadata
yum install mariadb -y # auto-approve
systemctl enable --now mariadb
systemctl start mariadb
</code></pre></div></div>

<p>Then, we can update our <code class="language-plaintext highlighter-rouge">aws_instance</code> instance resource in our Terraform code:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>resource "aws_instance" "test-instance" {
  ami = "ami-00d8a762cb0c50254"

  instance_type = "t3.micro"
  tags = {
    Name      = "test-instance"
    Terraform = true
  }

  subnet_id = var.public_subnet_id
  key_name  = var.ec2_key_pair_name
  user_data = file("${path.module}/ec2-user-data-db-cache.sh")
}
</code></pre></div></div>

<p><code class="language-plaintext highlighter-rouge">path.module</code> refers to our terraform module. Your path might be different if you don’t have the same folder structure as in this example.</p>

<h4 id="recreating-our-ec2-instance">Recreating our EC2 instance</h4>

<p>By <a href="https://aws.amazon.com/premiumsupport/knowledge-center/execute-user-data-ec2/">default</a>, the user-data script runs only on the creation of an EC2 instance, so we cannot simply apply that terraform update to our current instance. We could destroy the one we currently have and create another one, but there is a better way to do it, if your instance is not in usage. We can simply for the recreating of it.</p>

<p>The <code class="language-plaintext highlighter-rouge">--replace</code> <a href="https://developer.hashicorp.com/terraform/cli/commands/plan#replace-address">option</a> of our <code class="language-plaintext highlighter-rouge">plan</code>/<code class="language-plaintext highlighter-rouge">apply</code> command is the key to make it happen.
<code class="language-plaintext highlighter-rouge">terraform plan -var-file="secret.tfvars" --replace=module.your-module-name.aws_instance.test-instance</code>.</p>

<p>The plan should show that the instance will be destroyed, then recreated, making sure our user-data script is run on boot.
Once this is done, ssh to your instance and run <a href="https://mariadb.com/kb/en/mysql_secure_installation"><code class="language-plaintext highlighter-rouge">mysql_secure_installation</code></a> to get all set up.</p>

<h3 id="creating-self-signed-ssl-certificates-for-secure-access">Creating self-signed SSL certificates for secure access</h3>

<p>Now, we want to create a self-signed certificates to enforce secure connections. We will be using <code class="language-plaintext highlighter-rouge">openssl</code> to do so, so make sure it is installed on your machine.</p>

<ol>
  <li>Create a private RSA key acting as the CA key: <code class="language-plaintext highlighter-rouge">sudo openssl genrsa 2048 &gt; ca-key.pem</code>.</li>
  <li>Generate a public certificate valid for a 1000 years from that key: <code class="language-plaintext highlighter-rouge">sudo openssl req -new -x509 -nodes -days 365000 -key ca-key.pem -out ca-cert.pem</code>.</li>
</ol>

<p>The next step will be to generate the server private key and certificate:</p>

<ol>
  <li><code class="language-plaintext highlighter-rouge">sudo openssl req -newkey rsa:2048 -days 365000 -nodes -keyout server-key.pem -out server-req.pem</code></li>
  <li><code class="language-plaintext highlighter-rouge">sudo openssl rsa -in server-key.pem -out server-key.pem</code></li>
  <li>Sign  the server certificate: <code class="language-plaintext highlighter-rouge">sudo openssl x509 -req -in server-req.pem -days 365000 -CA ca-cert.pem -CAkey ca-key.pem -set_serial 01 -out server-cert.pem</code></li>
</ol>

<p>And finally, for the client:</p>

<ol>
  <li><code class="language-plaintext highlighter-rouge">sudo openssl req -newkey rsa:2048 -days 365000 -nodes -keyout client-key.pem -out client-req.pem</code></li>
  <li><code class="language-plaintext highlighter-rouge">sudo openssl rsa -in client-key.pem -out client-key.pem</code></li>
  <li>Sign the client certificate: <code class="language-plaintext highlighter-rouge">sudo openssl x509 -req -in client-req.pem -days 365000 -CA ca-cert.pem -CAkey ca-key.pem -set_serial 01 -out client-cert.pem</code></li>
</ol>

<p>You can verify that all those certificates are valid with: <code class="language-plaintext highlighter-rouge">openssl verify -CAfile ca-cert.pem server-cert.pem client-cert.pem</code>.
If you see all <code class="language-plaintext highlighter-rouge">OK</code> in the output, you are good to go.</p>

<p>All the credits for this section goes to this <a href="https://www.cyberciti.biz/faq/how-to-setup-mariadb-ssl-and-secure-connections-from-clients/">article</a> as I definitely didn’t know how to approach this, but it is something on my to-do list to revisit, so that I <strong>really</strong> understand what happens here.</p>

<p>Now let’s copy the server keys to our database server with <code class="language-plaintext highlighter-rouge">scp -i &lt;your-keyname-pair.pem&gt; -r self-signed-certificates ec2-user@&lt;ec2-instance-ip&gt;:~/self-signed-certificates</code></p>

<p>Then ssh to your instance and copy the server key and cert, in addition to the CA cert to <code class="language-plaintext highlighter-rouge">/etc/mysql</code>:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo cp ca-cert.pem /etc/mysql/ca-cert.pem
sudo cp server-cert.pem /etc/mysql/server-cert.pem
sudo cp server-key.pem /etc/mysql/server-key.pem
</code></pre></div></div>

<p>Open your mariadb config files, e.g <code class="language-plaintext highlighter-rouge">/etc/my.cnf.d/mariadb-server.cnf</code> and add the following in the mariadb section:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>[mariadb]
ssl_cert = /etc/mysql/ssl/server-cert.pem
ssl_key = /etc/mysql/ssl/server-key.pem
ssl_ca = /etc/mysql/ssl/ca-cert.pem
</code></pre></div></div>

<p>Restart mariadb with <code class="language-plaintext highlighter-rouge">sudo sysctl restart mariadb</code>.</p>

<h3 id="enforce-secure-client-connections">Enforce secure client connections</h3>

<p>To start let’s create a mysql user for our test.
After running <code class="language-plaintext highlighter-rouge">mysql -u root -p</code> on the EC2 instance to connect to the DB as root, run:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>CREATE DATABASE random
CREATE USER 'test-user'@'localhost' IDENTIFIED BY 'my-password';
GRANT ALL PRIVILEGES ON random.* TO 'test-user'@'localhost';
FLUSH PRIVILEGES;
</code></pre></div></div>

<p>Exit out of mysql and run <code class="language-plaintext highlighter-rouge">mysql -u test-user -p</code>, and you should be able to access the database.</p>

<p>Now, login to mysql as root, and we will enforce SSL for that <code class="language-plaintext highlighter-rouge">test-user</code> we just created.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>GRANT ALL PRIVILEGES ON random.* TO 'test-user'@'localhost' IDENTIFIED BY 'my-password' REQUIRE SSL WITH GRANT OPTION;
</code></pre></div></div>

<p>Exit out of mysql and attempt to login to the DB as <code class="language-plaintext highlighter-rouge">test-user</code>. 
You should see an error: <code class="language-plaintext highlighter-rouge">ERROR 1045 (28000): Access denied for user 'test-user'@'localhost' (using password: YES)</code>.</p>

<p>Good! Now let’s specify a client certificate and key to use to ensure our connection is secured.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>mysql -u test-user --ssl-cert ./self-signed-certificates/client-cert.pem --ssl-key ./self-signed-certificates/client-key.pem -p
</code></pre></div></div>

<p>And you should be in! Yay!</p>

<h3 id="integration-with-nextjs">Integration with Next.js</h3>

<p>Now, the final part, let’s use all of this for our Next.js application, with a few gotchas.
When using the command-line we have access to all the different certificates and keys. In the case of Next.js and Vercel, for our API endpoints, it is using Serverless functions as a backend, meaning an ephemeral file system. This results in having to create a file on demand, so that we can have encrypted connections to our database.
The idea is to have the content of the key and cert file as environment variables, and we will fetch their values to create a temporary file, before attempting to connect to our database.</p>

<p>This is discussed at length in https://github.com/prisma/prisma/issues/1673 and this is how it can be implemented:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>if (process.env.NODE_ENV === 'production') {
    try {
      console.log(`Creating client-key.pem in /tmp from env variable CLIENT_KEY`)
      const clientKeyPem = process.env.CLIENT_KEY_PEM!
      let path = `${tmpdir()}/client-key.pem`
      await fs.writeFile(
        path,
        clientKeyPem,
      )
      console.log(`file created at ${path}`)

      console.log(`Creating client-cert.pem in /tmp from env variable CLIENT_CERT_PEM`)
      const clientCertPem = process.env.CLIENT_CERT_PEM!
      path = `${tmpdir()}/client-cert.pem`
      await fs.writeFile(
        path,
        clientCertPem,
      )
      console.log(`file created at ${path}`)
    } catch (e) {
      console.log(`[ERROR] getDBClient: ${(e as Error).message}`)
    }
  }
</code></pre></div></div>

<p>and we need to have an mysql connection string looking like <code class="language-plaintext highlighter-rouge">mysql://test-user:my-password@&lt;instance-ip&gt;:3306/random?sslcert=/tmp/client-cert.pem&amp;sslkey=/tmp/client-key.pem</code>.</p>

<h3 id="conclusion">Conclusion</h3>

<p>This is not bulletproof, and is me experimenting around. If my side-project becomes something more serious, I would definitely be moving to either AWS RDS or something like <a href="https://planetscale.com/">Planetscale</a> to not have to deal with database security as such a low-level. Neverthless, it is interesting and helpful to know what gets into managing a database server, as it is nowadays somethind we are usually further off unless you work in an SRE or sysadmin capacity.</p>

<h3 id="references">References</h3>

<ul>
  <li><a href="https://aws.amazon.com/amazon-linux-2/faqs/">Amazon Linux 2 FAQs</a></li>
  <li><a href="https://www.redhat.com/sysadmin/getting-started-systemctl">Getting started with systemctl</a></li>
  <li><a href="https://mariadb.com/kb/en/mysql_secure_installation">mysql_secure_installation</a></li>
  <li><a href="https://mariadb.com/kb/en/securing-connections-for-client-and-server/">Securing Connections for Client and Server</a></li>
  <li><a href="https://www.cyberciti.biz/faq/how-to-setup-mariadb-ssl-and-secure-connections-from-clients/">How to set up MariaDB SSL and secure connections from clients</a></li>
</ul>]]></content><author><name></name></author><summary type="html"><![CDATA[As I am coming back from a 10-weeks long trip across the US, living the camper life, I thought it could be fun to create a small website to showcase where we went through pictures, and potentially some blog posts about living in a van, while working on the road (disclaimer: you don’t really work from the van).]]></summary></entry><entry><title type="html">To-Do list for new laptop setup (updated)</title><link href="https://jeremydagorn.com/2022/08/15/new-mac-setup.html" rel="alternate" type="text/html" title="To-Do list for new laptop setup (updated)" /><published>2022-08-15T00:00:00+00:00</published><updated>2022-08-15T00:00:00+00:00</updated><id>https://jeremydagorn.com/2022/08/15/new-mac-setup</id><content type="html" xml:base="https://jeremydagorn.com/2022/08/15/new-mac-setup.html"><![CDATA[<p>I had my personal Macbook for almost 10 years now, so it is bound to die anytime soon. Over the last year, I had to set up my development environment from scratch at least three times, due to a new job, some contracting work, and on a replacement laptop due to my battery dying.</p>

<p>As a reminder to myself, I think it could be smart to have a To-Do list handy for next time.
I will try to keep this list up to date, as I am doing it from memory right now.</p>

<h2 id="applications">Applications</h2>

<ul>
  <li><a href="https://www.spectacleapp.com/">Spectacle</a>: for windows management as I usually have 2/3 monitors on my day to day</li>
  <li><a href="https://git-fork.com/">Fork</a>: my favorite Git GUI for no particular reason</li>
  <li>Visual Studio Code: has been my IDE of choice for a few years now</li>
  <li><a href="https://obsidian.md/">Obsidian</a>: for note taking and work journal</li>
  <li>1Password: used for password management</li>
  <li>Flux: takes care of the ligthing of my screen as time goes by</li>
  <li>ITerm: my terminal of choice</li>
  <li>Sequel Pro: GUI for MySql</li>
</ul>

<h2 id="command-line-libraries">Command line libraries</h2>
<ul>
  <li>tree (through <code class="language-plaintext highlighter-rouge">brew install tree</code>) to display directory structures as a nicely laid out tree.</li>
</ul>

<h2 id="tools">Tools</h2>

<ul>
  <li>nvm: most of my work is in javascript nowadays so <code class="language-plaintext highlighter-rouge">nvm</code> is super handy to switch node versions on the fly</li>
  <li><a href="https://ohmyz.sh/">oh-my-zsh</a>: I use the <code class="language-plaintext highlighter-rouge">agnoster</code> theme.</li>
  <li><a href="https://chrome.google.com/webstore/detail/aws-extend-switch-roles/jpmkfafbacpgapdghgdpembnojdlgkdl">AWS Extend Switch Roles</a> Chrome extension: to make switching AWS profiles a breeze!</li>
  <li><a href="https://github.com/aciidic/thegreatsuspender-notrack">The Great Suspender No Track</a>: I tend to have a lot of tabs open so I like this extension to unload them after an hour or so if there is no activity.</li>
</ul>]]></content><author><name></name></author><summary type="html"><![CDATA[I had my personal Macbook for almost 10 years now, so it is bound to die anytime soon. Over the last year, I had to set up my development environment from scratch at least three times, due to a new job, some contracting work, and on a replacement laptop due to my battery dying.]]></summary></entry><entry><title type="html">Sequelize Cheatsheet / Gotchas</title><link href="https://jeremydagorn.com/2021/02/06/sequelize-gotchas-cheatsheet.html" rel="alternate" type="text/html" title="Sequelize Cheatsheet / Gotchas" /><published>2021-02-06T00:00:00+00:00</published><updated>2021-02-06T00:00:00+00:00</updated><id>https://jeremydagorn.com/2021/02/06/sequelize-gotchas-cheatsheet</id><content type="html" xml:base="https://jeremydagorn.com/2021/02/06/sequelize-gotchas-cheatsheet.html"><![CDATA[<h2 id="postgres">Postgres</h2>

<h3 id="uuids-columns">UUIDs columns</h3>

<ul>
  <li>Tested with postgres 13.1 and sequelize-cli 6.2.0.</li>
</ul>

<p>If you want to use uuids with a default value you cannot rely on using Sequelize.UUIDV4 or an equivalent.</p>

<p>As a workaround you can:</p>
<ol>
  <li>
    <p>make sure the <code class="language-plaintext highlighter-rouge">uuid-ossp</code> is installed and enabled on your postgres server:<br />
<code class="language-plaintext highlighter-rouge">CREATE EXTENSION IF NOT EXISTS "uuid-ossp";</code></p>
  </li>
  <li>
    <p>in your schema definition (in this case, a migration file):</p>
    <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>await queryInterface.createTable('your-table', {
 uuid: {
     type: Sequelize.UUID,
     defaultValue: Sequelize.fn('uuid_generate_v4'),
     allowNull: false,
     primaryKey: true,
 }
});
</code></pre></div>    </div>
  </li>
</ol>

<h3 id="default-timestamp-for-column">Default timestamp for column</h3>
<ul>
  <li>Tested with postgres 13.1 and sequelize-cli 6.2.0.</li>
</ul>

<p>As part of your migration:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>createdAt: {
    type: Sequelize.DATE,
    defaultValue: Sequelize.fn('now'),
}
</code></pre></div></div>]]></content><author><name></name></author><summary type="html"><![CDATA[Postgres]]></summary></entry><entry><title type="html">Your code is not your code.</title><link href="https://jeremydagorn.com/2020/12/28/your-code-is-not-your-code.html" rel="alternate" type="text/html" title="Your code is not your code." /><published>2020-12-28T00:00:00+00:00</published><updated>2020-12-28T00:00:00+00:00</updated><id>https://jeremydagorn.com/2020/12/28/your-code-is-not-your-code</id><content type="html" xml:base="https://jeremydagorn.com/2020/12/28/your-code-is-not-your-code.html"><![CDATA[<p>It has taken me a few years to realize, but I get really attached to the code I write.
I finally start to understand what people mean when they say “the code you write is not your code”.</p>

<p>Here are a few things I think about when I start to get frustrated/concerned when the code I have written start to change.</p>

<ul>
  <li>all code is meant to be changed, it is not set in stone.</li>
  <li>people can iterate on it because it acts as a base for your teammates.</li>
  <li>deleting code is better than adding code.</li>
  <li>no code is perfect on the first iteration, and in a startup, you usually don’t have the luxury of having multiple iterations to refine it. That is fine.</li>
  <li>it is not because code you wrote is being rewritten/modified that people think your implementation was bad.</li>
  <li>it is just code, it is just a job.</li>
</ul>

<p>A few things that can help:</p>

<ul>
  <li>if you can, and want to, work on small side projects to keep programming fun, and nobody will rewrite it. :)</li>
  <li>talk with your teammates about the specific reasons something needed to be rewritten.</li>
  <li><strong>it does not matter.</strong></li>
</ul>]]></content><author><name></name></author><summary type="html"><![CDATA[It has taken me a few years to realize, but I get really attached to the code I write. I finally start to understand what people mean when they say “the code you write is not your code”.]]></summary></entry><entry><title type="html">No news good news</title><link href="https://jeremydagorn.com/2020/10/29/no-news-good-news.html" rel="alternate" type="text/html" title="No news good news" /><published>2020-10-29T00:00:00+00:00</published><updated>2020-10-29T00:00:00+00:00</updated><id>https://jeremydagorn.com/2020/10/29/no-news-good-news</id><content type="html" xml:base="https://jeremydagorn.com/2020/10/29/no-news-good-news.html"><![CDATA[<p>2020 has been a crazy year so far. Nothing new here. I have the habit to read news in the morning, like a lot of people. Nothing special there. With the presidential election coming up, the different news outlets are just going with what is mostly sensationalism. That impacts the mood of people in ways that I didn’t really consider before. For some interesting reading about this, check <a href="https://www.theatlantic.com/family/archive/2020/10/reading-too-much-political-news-bad-happiness/616651">Reading Too Much Political News Is Bad for Your Well-Being</a> or the <a href="https://news.ycombinator.com/item?id=24818637">HN thread</a>.</p>

<p>I wanted to run a similar experiment as what some of the commenters on that thread mentioned,  <strong>“Avoid reading the news”</strong>. The logic behind it is pretty simple:</p>

<ol>
  <li>If something is really important, you will hear about it outside of your morning reading.</li>
  <li>It <em>can</em> put you in a bad mood/mess with your emotional state early in the morning, switching your mindset for part of the day.</li>
  <li>It takes time, if you want to be somewhat thorough and read from multiple sources on specific issues.</li>
  <li>At the end, most of the news of today don’t matter a week from now.</li>
</ol>

<p>I did try that for more than a week now. I don’t check twitter as much, and avoid social media. I only get a news digest by email once a day that I don’t read. I don’t miss reading news. Most of it carry a negative tone. We need some positive news, while having good and neutral reporting on COVID, and objective and fact-driven reporting on politics.</p>

<p>Not reading news also gives me time to read other type of articles, whether they are technical or straight Wikipedia page about random things, it feeds my brain with more questions that are worth answering more than the reality-tv show we are currently living in.</p>

<p>Hoping for a better 2021.</p>]]></content><author><name></name></author><summary type="html"><![CDATA[2020 has been a crazy year so far. Nothing new here. I have the habit to read news in the morning, like a lot of people. Nothing special there. With the presidential election coming up, the different news outlets are just going with what is mostly sensationalism. That impacts the mood of people in ways that I didn’t really consider before. For some interesting reading about this, check Reading Too Much Political News Is Bad for Your Well-Being or the HN thread.]]></summary></entry><entry><title type="html">What a good hike can do?</title><link href="https://jeremydagorn.com/2020/10/23/what-a-good-hike-can-do.html" rel="alternate" type="text/html" title="What a good hike can do?" /><published>2020-10-23T00:00:00+00:00</published><updated>2020-10-23T00:00:00+00:00</updated><id>https://jeremydagorn.com/2020/10/23/what-a-good-hike-can-do</id><content type="html" xml:base="https://jeremydagorn.com/2020/10/23/what-a-good-hike-can-do.html"><![CDATA[<ol>
  <li>get your steps for the day (~13.000).</li>
  <li>lets you catch up on podcasts:
    <ul>
      <li><a href="https://syntax.fm/show/294/spooky-web-dev-stories-part-1">Spooky Web Dev Stories — Part 1</a></li>
      <li><a href="https://syntax.fm/show/293/hasty-treat-stretching-for-developers-with-scott">Hasty Treat - Stretching For Developers with Scott</a></li>
      <li><a href="https://reactpodcast.com/episodes/112">112: Kent C. Dodds on Epic React</a></li>
      <li><a href="https://solvehq.com/podcast/">Solve</a>
        <ul>
          <li>First time listening to it. Feels it would be a lot more enjoyable if you could take part into the investigation itself by chatting with other people, etc.</li>
        </ul>
      </li>
    </ul>
  </li>
  <li>got a new side project idea (this one is the one, trust me!).</li>
  <li>enjoy some fresh air and some rain.</li>
  <li>makes you hungry.</li>
</ol>]]></content><author><name></name></author><summary type="html"><![CDATA[get your steps for the day (~13.000). lets you catch up on podcasts: Spooky Web Dev Stories — Part 1 Hasty Treat - Stretching For Developers with Scott 112: Kent C. Dodds on Epic React Solve First time listening to it. Feels it would be a lot more enjoyable if you could take part into the investigation itself by chatting with other people, etc. got a new side project idea (this one is the one, trust me!). enjoy some fresh air and some rain. makes you hungry.]]></summary></entry><entry><title type="html">Working on my communication</title><link href="https://jeremydagorn.com/2020/09/04/working-on-my-communication.html" rel="alternate" type="text/html" title="Working on my communication" /><published>2020-09-04T00:00:00+00:00</published><updated>2020-09-04T00:00:00+00:00</updated><id>https://jeremydagorn.com/2020/09/04/working-on-my-communication</id><content type="html" xml:base="https://jeremydagorn.com/2020/09/04/working-on-my-communication.html"><![CDATA[<h3 id="introduction">Introduction</h3>

<p>I was reading through a few Hacker News threads related to communication and brain hacks. A lot of the mentioned tricks are very interesting. I am working on getting better at some of them and wanted to just put a small list of the most important one / achievables ones in this post.</p>

<p><strong>If I’m getting upset, is it because I might be wrong?.</strong></p>

<p>Another way to say this appears to be : If all you see are problems, you’re not seeing clearly.</p>

<p>You will get upset or annoyed at work, with your teammates, some decisions being made you disagree with, the taste of the coffee, who knows.
In those cases, I need to ask myself I am actually wrong to feel that way. I am a complainer by nature, and I need to get better at asking myself if I shoud legitimately be upset, or if I am just being a cry-baby that is being proven wrong. Taking a step back in those cases matters a lot.</p>

<p><strong>Don’t say ‘I know or I think’ but ‘It appears / It looks like’.</strong></p>

<p>It makes easier to reframe your mind, change your opinion about thing if you don’t attach yourself to an idea.</p>

<p><strong>Say no more often than not.</strong>
Becoming a yes-man at work is going to make you burn out.</p>

<p><strong>I may be wrong. I am often wrong.</strong>
Be super comfortable with being wrong.</p>

<p><strong>Reframe your negative sentences/thoughts to be come positive/facts</strong></p>

<p><strong>Remember that the world is bigger than this piece of code, this job or conversation</strong>
At the end, it doesn’t really matter, does it?</p>

<p>Source: <a href="https://news.ycombinator.com/item?id=18588727">https://news.ycombinator.com/item?id=18588727</a></p>]]></content><author><name></name></author><summary type="html"><![CDATA[Introduction]]></summary></entry><entry><title type="html">How I think I evolved as an engineer and teammate.</title><link href="https://jeremydagorn.com/2020/08/28/evolution-as-a-software-engineer.html" rel="alternate" type="text/html" title="How I think I evolved as an engineer and teammate." /><published>2020-08-28T00:00:00+00:00</published><updated>2020-08-28T00:00:00+00:00</updated><id>https://jeremydagorn.com/2020/08/28/evolution-as-a-software-engineer</id><content type="html" xml:base="https://jeremydagorn.com/2020/08/28/evolution-as-a-software-engineer.html"><![CDATA[<h3 id="introduction">Introduction</h3>

<p>I start working as a software engineer in 2012, so it has been just a bit more than 8 years now. I started as an intern at Prezi in Budapest, and transitioned to full-time at the end of the summer. I am now working at a startup from San Diego, as a senior software engineer. This post is more a self-reflection about what changed and how I changed as a teammate over the years.</p>

<h4 id="perseverance">Perseverance</h4>

<p>Earlier in my career, I didn’t know how to debug, and what to look for when hitting an issue. Bugs in the code you write usually have a good reason, and investigating those are usually fairly straightforward. The ones that were giving me the most issues where usually more complex bugs occuring when multiple systems where involved, or even more annoying, when your local setup is not working.
I would have a tendency to look for a little bit and just give up.
Nowadays, I don’t give up. I usually take it upon myself to find the root cause of an issue, and a logical explanation as to why it broke down.</p>

<p>At my current workplace, I have been writing new services from scratch, and I spend a lot of time trying to get a good local setup working. I am pretty obsessed about being able to run services and test features end-to-end locally. Rightfully so, I am not sure. It just give me a lot of confidence to be able to test features end to end before even deploying them to our development or staging environments.</p>

<p>Perseverance is probably the aspect of my mindset that evolved the most in those 8 years. This, combined with experience and improved technical skills had the biggest impact on my day to day work.</p>

<p>Being able to figure out problems and have solutions before other people have to fight through them is making me feel very valuable, as the time that is saved for my teammates make the time I spent on debugging issues worth it.</p>

<p>If I have to think about how I approach being more perseverant when debugging is to really try to go back to the simplest layer. Verify, and add an extra layer, verify, and repeat. It is easy to feel overwhelmed and start putting debugging statements everywhere, but focusing on one aspect and being able to eliminate it from the equation is what is important.</p>

<h4 id="picking-your-battles">Picking your battles</h4>

<p>Tensions and disagreement will always happen, in any job. There is no perfect job, and it would be pretty boring if everybody was always agreeing and committing. But, not every battle is worth to fight for. Knowing when to let go and disagreeing and committing is a powerful skill.
Earlier in my career, I was pretty shy. Not knowing much, and still dealing with learning a second language, I was often committing without thinking too much, trusting the decision maker, whether on the technical side or product side. It was working well for me.</p>

<p>When I joined my second job, as an early engineer at a startup, I started to be disagreeing with everything if it was related to changing something I worked on, or my role within the team and so on. That… did not work well. It caused be to become impatient and not seeing the overall picture. I was fighting every battle, not thinking if it was worth it or not. This brought my adventure with that company to an end, as I got impatient and just moved to what I thought were greener pastures. This is a decision I still regret today, even if hindsight is 20/20.</p>

<p>Assume that people have good intentions and are not coming from a place of malice. If something hurts you, and rubs you the wrong way, it is most likely not intentional. It could just be a communication issue, someone having a bad day or just someone feeling some pressure. It is not personal.</p>

<p>Today, I always try to take a step back. It is not always easy when it is in the moment, but life is a lot more than work and things will change anyway. It is important to think, or at least try to think about the impact some changes will have on your work, and if it is even worth try to fight for a decision to be changed, or for a decision to go more towards what you believe in. Biting your lip 9 out of 10 times and not say anything works well for me. It also make the times where you decide to speak up much more meaningful, as people will really see it as thoughtful feedback and will in turn take a step back (usually) to see if it made sense.</p>

<p>This is a very hard thing to do. I still struggle to bite my lip 9 out of 10 times but I am getting better.</p>

<h4 id="detach-yourself">Detach yourself</h4>

<p>Detaching myself is something that I need to get a lot better at. I am not good at it. I think I was in a better place years ago as everything was much newer to me. Repeating that “your work is not your life”, “this is just a job” can be tough when you put a lot of pride in the work you produce, and you want people to recognize it. The thing is, people will probably recognize it but wont say anything about it. This is kind of a bad spiral to be in, as you will double down the effort to get that acknowledgement but it might never happen. Just being proud of your own work is enough. Sometimes you might get recognition from other, but don’t expect it. If you go down that path, it will make detaching yourself from your work a lot harder.</p>

<h4 id="saying-i-dont-know">Saying I don’t know</h4>

<p>I do interview candidates at my current job. I did interview candidates at my previous jobs too. One thing that had changed is the connotation in my mind when someone says “I don’t know”. It is refreshing. Knowing what you don’t know is important, and keeps you humble. Software engineering is all about learning more, as it is always changing. New languages come and go, new patterns start trending and are replaced after a few years. It is very hard to keep up. As long as someone can learn, it is fine. Pretending you know when you don’t is easy to spot, and won’t earn you any points in interviews usually. It gets even worse on the job where people will be less likely to trust you if you are just a talker. Doing and learning matters.</p>

<h4 id="you-dont-owe-a-company-anything">You don’t owe a company anything</h4>

<p>That one took a while for me to set in. I met a lot of people, made friends and felt that we all had a common mission while being at a company.
That might be true. A common mission is possible. Where I draw the line is when I hear about the concept of ‘we are a big family’. I used to believe it but could see the actions taken were far from the words spoken at times.
It left a bitter taste in my mouth so I am very cautious about this now.</p>

<p>A company is trying to make money, ultimately. A company has to protect itself. If it means having to let you go, the concept of family disappears quickly. Trying to keep in mind that a company won’t hesitate to let you go is good when trying to push the extra mile, or do extra work for a company. Ask yourself what the incentive is. Ask yourself if it is worth it. Most of the time it isn’t. It doesn’t mean the job is a bad job if you are to question yourself about that. You just need to be realistic.</p>

<h4 id="conclusion">Conclusion</h4>

<p>We are lucky to be able to work in a field that is always changing. It is not a perfect field, but it has some amazing properties when it comes to growing as an engineer. You always have to be on your feet, ready to learn something new. Entire markets are being disrupted by software. You don’t need a degree to enter the field, and if you get lucky enough to convince someone to take a chance on you, you can have a long and interesting career in my opinion. It feels a bit silly to say that as a 30 something years old but I really see myself still doing this in 20 years (even if I have my doubt sometimes). I hope to still be as excited as I am today.</p>]]></content><author><name></name></author><summary type="html"><![CDATA[Introduction]]></summary></entry><entry><title type="html">Are my programming pet peeves justified?</title><link href="https://jeremydagorn.com/2020/03/14/pet-peeves-ramblings.html" rel="alternate" type="text/html" title="Are my programming pet peeves justified?" /><published>2020-03-14T00:00:00+00:00</published><updated>2020-03-14T00:00:00+00:00</updated><id>https://jeremydagorn.com/2020/03/14/pet-peeves-ramblings</id><content type="html" xml:base="https://jeremydagorn.com/2020/03/14/pet-peeves-ramblings.html"><![CDATA[<h2 id="note">Note</h2>
<p>I will keep this list of pet peeves updated as time goes by.</p>

<h3 id="map-followed-by-filter-or-filter-followed-by-map">Map followed by filter or filter followed by map</h3>
<p>Example:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>[1,8,2,6,7,14].map(x =&gt; x * 5).filter(x =&gt; x &gt; 30) or
[1,8,2,6,7,14].map(x =&gt; x * 5).filter(x =&gt; x &gt; 30)
</code></pre></div></div>

<p>vs</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>[1,8,2,6,7,14].reduce((acc, x) =&gt; { 
    if (x * 5 &gt; 30) acc.push(x * 5)
    return acc;
}, [])
</code></pre></div></div>

<p>The reduce iterates over the original array of length N only once and will return an array of at most N elements.
In the first case, we will iterate once over the original array once and then iterate again over the array return by the <code class="language-plaintext highlighter-rouge">map</code> operation.</p>

<h4 id="but-it-feels-more-readable">But it feels more readable!</h4>

<p>If you are comfortable with the for loop equivalent of the reduce, it feels like a cheap excuse.</p>

<p>The difference between the <code class="language-plaintext highlighter-rouge">reduce</code> callback and the for loop implementation is minimal.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>let results = [];
[1,8,2,6,7,14].forEach(x =&gt; { 
    if (x * 5 &gt; 30) results.push(x * 5)
}, [])
</code></pre></div></div>

<p>The only difference is making sure you are returning the accumulator from the callback in the <code class="language-plaintext highlighter-rouge">reduce</code> solution.
The advantage of using <code class="language-plaintext highlighter-rouge">reduce</code> is that it is pure, compared to the forEach/for loop equivalent.</p>

<h3 id="ternary-or-if--else-return-true--false">Ternary or if / else return true : false;</h3>
<p>Example:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>return i &gt; 4 ? true : false

vs

return i &gt; 4;
</code></pre></div></div>

<p>This one usually is a result of not paying attention. Not a big deal on its own, but I am pretty sure IDEs would be telling you the code could be simplified so it should <em>never</em><sup id="fnref:1" role="doc-noteref"><a href="#fn:1" class="footnote" rel="footnote">1</a></sup> be seeng in a PR submitted for code reviews.</p>

<h3 id="commenting-code-for-the-sake-of-commenting">Commenting code for the sake of commenting</h3>
<p>Example:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code># open connection to DB
db.openConnection();

</code></pre></div></div>

<p>I know how to read, thank you.</p>

<h3 id="pure-functions-not-being-unit-tested">Pure functions not being unit-tested</h3>
<p>I believe in unit testing, and testing in general. But I also understand (not necessarily believe) in having to produce features fast. I also believe in not unit testing everything for code flexibility. 
With that being said, I often see functions with a few edge cases, a fairly simple method signature, with fairly simple parameters, not being unit tested.
Why not? The function is pure, it is fast for you to just create a new file,write the scenarios you need this method to run for, and feed it values, and see what happens.
The consequences of that type of approach are only positive.</p>

<ol>
  <li>Easy to figure out what the function does for reviewers/you in 6 months.
    <ul>
      <li>you see the input, you see the output. Easy to point out issues when reviewing by pretty much giving an input for which you don’t think it would work.</li>
    </ul>
  </li>
  <li>Easy to maintain
    <ul>
      <li>you discovered a bug with it or an edge case you didn’t think about originally. Great! Add new code for the edge case, re-run your test to verify it behaves as expected. It gives you a sense of confidence that at least you didn’t introduce a regression.</li>
    </ul>
  </li>
  <li>Gives you confidence in writing tests
    <ul>
      <li>Writing good tests is not easy. It takes a lot of attempts/failures to get to a point where you think your tests makes sense, are not overkill, are useful, are not getting in your way when modifying your code. Starting with the “easy” piece of code is the best way to get into the testing mindset.</li>
    </ul>
  </li>
</ol>

<h3 id="not-being-able-to-run-code-locally-to-verify-changes">Not being able to run code locally to verify changes</h3>
<p>It happens sometimes, and this makes me angry. You need me to fix this bug but there is no way for me to test it locally before pushing my changes?</p>

<p>Do I usually drive blindfolded?</p>

<p><em>We don’t have the data to reproduce the bug</em></p>

<p>Then, you don’t have a bug that I can fix. My first step here would be to add logging before I even attempt to do anything else.</p>

<p><em>It relies on another service returning that data</em></p>

<p>Then, run the other service locally too. We have so many tools nowadays to let you run multiple services locally easily.
For services, docker.
You use AWS: localstack.</p>

<p><em>But now that service relies on another service</em></p>

<p>Same answer as above, docker and docker-compose.</p>

<p><em>It is too many services, I just want to fix that bug</em></p>

<p>Either you were not prepared for a microservice oriented architecture, or you went crazy with it for no reason.
In the worst case you cannot do full end to end, you need to mock the data returned by downstream services. This is non-negotiable.</p>

<div class="footnotes" role="doc-endnotes">
  <ol>
    <li id="fn:1" role="doc-endnote">
      <p>This is sarcastic. Accidents happen, but if it happens multiple times, it probably means you need to go through your changes before committing/pushing as it should be easy to spot on. <a href="#fnref:1" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
  </ol>
</div>]]></content><author><name></name></author><summary type="html"><![CDATA[Note I will keep this list of pet peeves updated as time goes by.]]></summary></entry></feed>