<?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: Christian Paez</title>
    <description>The latest articles on Forem by Christian Paez (@christianpaez).</description>
    <link>https://forem.com/christianpaez</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%2F445678%2Fbc295e1f-3626-403e-bb9d-b476f555155c.png</url>
      <title>Forem: Christian Paez</title>
      <link>https://forem.com/christianpaez</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/christianpaez"/>
    <language>en</language>
    <item>
      <title>The case for boring tools</title>
      <dc:creator>Christian Paez</dc:creator>
      <pubDate>Sun, 08 Mar 2026 22:18:57 +0000</pubDate>
      <link>https://forem.com/christianpaez/the-case-for-boring-tools-16f8</link>
      <guid>https://forem.com/christianpaez/the-case-for-boring-tools-16f8</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ftech.christianpaez.com%2Fassets%2Fimg%2Fthe-case-for-boring-tools.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ftech.christianpaez.com%2Fassets%2Fimg%2Fthe-case-for-boring-tools.jpg" alt="Link text" width="800" height="600"&gt;&lt;/a&gt;&lt;br&gt;
Many of us software developers spend time on personal projects. Mine was/is a simple personal tech blog. When I first built it, I wanted to stick to the tools I was most used to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;React.js&lt;/li&gt;
&lt;li&gt;Some SSR metaframework (Next or Gatsby)&lt;/li&gt;
&lt;li&gt;A JavaScript build system (Webpack back then)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And that is what I did. I took a template for Ghost CMS and built a basic blog for fun.&lt;/p&gt;

&lt;p&gt;After writing for a couple of months and having updated my site over 50 times, I began to get small problems.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Writing became boring
&lt;/h2&gt;

&lt;p&gt;The way the CMS worked was by taking markdown content, adding some metadata to it like canonical links, metatags, etc., storing this info in a database (yes, this needed a server), and then triggering a build on the server-side rendered site. This meant that after the fun part of writing my little blog post, I had to go to an admin panel, log in, figure out all the metatags and attributes for my blog post, and fill out a massive form with a good amount of form validation (description cannot be longer than x, title is too short, etc.), just to trigger a build and wait a couple of minutes to see my blog post. I remember many times spending more time publishing the post than actually writing it.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. This setup is not simple
&lt;/h2&gt;

&lt;p&gt;If I go to Medium, Quora, or Substack, I can just take markdown, an image, and some tags and be ready to post a blog. This was not what my blog had, and I began to notice that my setup was too complex. Since I was probably used to complications at work, I did not see this until a couple of months of writing. Also, running this blog locally was annoying since dependencies were always broken for some reason, as most JavaScript projects are.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. It costs more than needed
&lt;/h2&gt;

&lt;p&gt;At first, this was not a problem because the golden years of free Heroku dynos were still a thing. But when they nuked their free tier, I noticed that I was running a server with a database when I just needed to serve static content.&lt;/p&gt;

&lt;p&gt;So after a while, writing became boring. I lost my admin panel credentials and forgot about the site.&lt;/p&gt;

&lt;h2&gt;
  
  
  Boring just works
&lt;/h2&gt;

&lt;p&gt;One day I was browsing for web templates since I wanted a blog for non-tech content and stumbled upon Jekyll. It is a super basic static site generator that has:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No database&lt;/li&gt;
&lt;li&gt;No admin panel&lt;/li&gt;
&lt;li&gt;No JS pipeline&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It is true that it does not do a lot of the fancy SSR, IWR, SCG, and other permutations of letters I can't understand (I made some of those up, and you probably did not notice). But I could write a .md file and get a blog post in less than a minute. It took me longer to log in to my admin panel and find the "Create Post" button on the page than just having my site updated.&lt;/p&gt;

&lt;p&gt;So now:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To publish a blog post, I spend 90% writing and 10% making the post available online&lt;/li&gt;
&lt;li&gt;I understand how my simple setup works&lt;/li&gt;
&lt;li&gt;I don't have unnecessary costs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I even use Jekyll for some other projects that are non-blog sites, and it's so nice to have something simple that does not break and does not cause friction. I know there has to be a case for a more sophisticated setup but for now I like to keep it simple.&lt;/p&gt;

&lt;p&gt;Boring but works.&lt;/p&gt;

</description>
      <category>webdev</category>
    </item>
    <item>
      <title>The Ultimate SQL JOIN Cheat Sheet</title>
      <dc:creator>Christian Paez</dc:creator>
      <pubDate>Tue, 10 Sep 2024 15:36:45 +0000</pubDate>
      <link>https://forem.com/christianpaez/the-ultimate-sql-join-cheat-sheet-1lf9</link>
      <guid>https://forem.com/christianpaez/the-ultimate-sql-join-cheat-sheet-1lf9</guid>
      <description>&lt;p&gt;If you're working with relational databases, you'll often need to combine data from multiple tables. SQL &lt;code&gt;JOINs&lt;/code&gt; help you achieve this.&lt;/p&gt;

&lt;h3&gt;
  
  
  Understanding INNER JOIN
&lt;/h3&gt;

&lt;p&gt;An &lt;code&gt;INNER JOIN&lt;/code&gt; retrieves rows where there is a match between the tables based on the specified join condition. If no match is found, no rows are returned for that combination.&lt;/p&gt;

&lt;p&gt;The syntax for an &lt;code&gt;INNER JOIN&lt;/code&gt; looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="c1"&gt;-- [Mandatory] SELECT: Specifies the columns you want to retrieve.&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt;
    &lt;span class="c1"&gt;-- [Optional] DISTINCT: Ensures the result set contains only unique rows by removing duplicates.&lt;/span&gt;
    &lt;span class="c1"&gt;-- Place DISTINCT immediately after SELECT if you want only unique rows.&lt;/span&gt;
    &lt;span class="c1"&gt;-- DISTINCT &lt;/span&gt;
    &lt;span class="n"&gt;column1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;-- Specify the first column you want to retrieve&lt;/span&gt;
    &lt;span class="n"&gt;column2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;-- Specify the second column, and so on...&lt;/span&gt;
    &lt;span class="p"&gt;...&lt;/span&gt;

&lt;span class="c1"&gt;-- [Mandatory] FROM: The table from which you're selecting data.&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt;
    &lt;span class="n"&gt;table1&lt;/span&gt;

&lt;span class="c1"&gt;-- [Mandatory] INNER JOIN: Joins two tables and retrieves rows that have matching values in both tables.&lt;/span&gt;
&lt;span class="k"&gt;INNER&lt;/span&gt; &lt;span class="k"&gt;JOIN&lt;/span&gt;
    &lt;span class="n"&gt;table2&lt;/span&gt; &lt;span class="c1"&gt;-- The second table you're joining with the first table&lt;/span&gt;

&lt;span class="c1"&gt;-- [Mandatory] ON: Specifies the condition that defines how the tables are related. &lt;/span&gt;
&lt;span class="c1"&gt;-- Only rows where the columns match will be included in the result set.&lt;/span&gt;
&lt;span class="k"&gt;ON&lt;/span&gt;
    &lt;span class="n"&gt;table1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;column&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;table2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;column&lt;/span&gt;

&lt;span class="c1"&gt;-- [Optional] WHERE: Filters the rows returned by the join based on a specific condition.&lt;/span&gt;
&lt;span class="c1"&gt;-- Only rows that meet this condition will be included in the final result.&lt;/span&gt;
&lt;span class="c1"&gt;-- WHERE condition&lt;/span&gt;

&lt;span class="c1"&gt;-- [Optional] ORDER BY: Sorts the result set by the specified columns.&lt;/span&gt;
&lt;span class="c1"&gt;-- You can choose to sort in ascending (ASC) or descending (DESC) order.&lt;/span&gt;
&lt;span class="c1"&gt;-- ORDER BY column1 [ASC|DESC], column2 [ASC|DESC];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Understanding OUTER JOINs
&lt;/h3&gt;

&lt;p&gt;While &lt;code&gt;INNER JOINs&lt;/code&gt; return only matching rows between two tables, &lt;code&gt;OUTER JOINs&lt;/code&gt; go further by also including rows that do not have a match in one of the tables. There are three types of &lt;code&gt;OUTER JOINs&lt;/code&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;LEFT OUTER JOIN&lt;/strong&gt; (or simply &lt;code&gt;LEFT JOIN&lt;/code&gt;): returns all rows from the left table and the matching rows from the right table. If no match is found, the result will contain &lt;code&gt;NULL&lt;/code&gt; for the columns from the right table.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;RIGHT OUTER JOIN&lt;/strong&gt; (or simply &lt;code&gt;RIGHT JOIN&lt;/code&gt;): works in the opposite way of a &lt;code&gt;LEFT JOIN&lt;/code&gt;. It returns all rows from the right table and the matching rows from the left table. If no match is found, the result will contain &lt;code&gt;NULL&lt;/code&gt; for the columns from the left table.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;FULL OUTER JOIN:&lt;/strong&gt; returns all rows when there is a match in either the left or right table. If there is no match, the result will contain &lt;code&gt;NULL&lt;/code&gt; for the columns from the table without a match.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Each of these joins is useful depending on the specific data retrieval needs.&lt;/p&gt;




&lt;p&gt;The syntax for an &lt;code&gt;OUTER JOIN&lt;/code&gt; looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="c1"&gt;-- [Mandatory] SELECT: Specifies the columns you want to retrieve.&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt;
    &lt;span class="c1"&gt;-- [Optional] DISTINCT: Ensures the result set contains only unique rows by removing duplicates.&lt;/span&gt;
    &lt;span class="c1"&gt;-- Place DISTINCT immediately after SELECT if you want only unique rows.&lt;/span&gt;
    &lt;span class="c1"&gt;-- DISTINCT &lt;/span&gt;
    &lt;span class="n"&gt;column1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;-- Specify the first column you want to retrieve&lt;/span&gt;
    &lt;span class="n"&gt;column2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;-- Specify the second column, and so on...&lt;/span&gt;
    &lt;span class="p"&gt;...&lt;/span&gt;

&lt;span class="c1"&gt;-- [Mandatory] FROM: The table from which you're selecting data.&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt;
    &lt;span class="n"&gt;table1&lt;/span&gt;

&lt;span class="c1"&gt;-- [Mandatory] OUTER JOIN: Includes rows from the specified table even if there is no match in the other table.&lt;/span&gt;
&lt;span class="c1"&gt;-- You can use LEFT OUTER JOIN, RIGHT OUTER JOIN, or FULL OUTER JOIN based on your needs.&lt;/span&gt;
&lt;span class="c1"&gt;-- LEFT OUTER JOIN: Includes all rows from the left table and matched rows from the right table.&lt;/span&gt;
&lt;span class="c1"&gt;-- RIGHT OUTER JOIN: Includes all rows from the right table and matched rows from the left table.&lt;/span&gt;
&lt;span class="c1"&gt;-- FULL OUTER JOIN: Includes all rows from both tables, with NULLs where there is no match.&lt;/span&gt;
&lt;span class="c1"&gt;-- Example: LEFT OUTER JOIN&lt;/span&gt;
    &lt;span class="k"&gt;LEFT&lt;/span&gt; &lt;span class="k"&gt;OUTER&lt;/span&gt; &lt;span class="k"&gt;JOIN&lt;/span&gt;
    &lt;span class="n"&gt;table2&lt;/span&gt; &lt;span class="c1"&gt;-- The table you're joining with the first table&lt;/span&gt;

&lt;span class="c1"&gt;-- [Mandatory] ON: Specifies the condition that defines how the tables are related. &lt;/span&gt;
&lt;span class="c1"&gt;-- Only rows where the columns match will be included in the result set, or all rows from one table depending on the join type.&lt;/span&gt;
&lt;span class="k"&gt;ON&lt;/span&gt;
    &lt;span class="n"&gt;table1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;column&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;table2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;column&lt;/span&gt;

&lt;span class="c1"&gt;-- [Optional] WHERE: Filters the rows returned by the join based on a specific condition.&lt;/span&gt;
&lt;span class="c1"&gt;-- Only rows that meet this condition will be included in the final result.&lt;/span&gt;
&lt;span class="c1"&gt;-- WHERE condition&lt;/span&gt;

&lt;span class="c1"&gt;-- [Optional] ORDER BY: Sorts the result set by the specified columns.&lt;/span&gt;
&lt;span class="c1"&gt;-- You can choose to sort in ascending (ASC) or descending (DESC) order.&lt;/span&gt;
&lt;span class="c1"&gt;-- ORDER BY column1 [ASC|DESC], column2 [ASC|DESC];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Example of INNER JOIN
&lt;/h3&gt;

&lt;p&gt;To retrieve employee names and their associated department names, where there is a matching department for each employee, you can use an &lt;code&gt;INNER JOIN&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt;
    &lt;span class="n"&gt;employees&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;employee_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;departments&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;department_name&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt;
    &lt;span class="n"&gt;employees&lt;/span&gt;
&lt;span class="k"&gt;INNER&lt;/span&gt; &lt;span class="k"&gt;JOIN&lt;/span&gt;
    &lt;span class="n"&gt;departments&lt;/span&gt;
&lt;span class="k"&gt;ON&lt;/span&gt;
    &lt;span class="n"&gt;employees&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;department_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;departments&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;department_id&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This query will return only the rows where there is a match between the &lt;code&gt;department_id&lt;/code&gt; columns in both the &lt;code&gt;employees&lt;/code&gt; and &lt;code&gt;departments&lt;/code&gt; tables. If an employee does not have a corresponding department or a department has no employees, those rows will not appear in the result set.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example of LEFT OUTER JOIN
&lt;/h3&gt;

&lt;p&gt;Let’s say we have an &lt;code&gt;employees&lt;/code&gt; table and a &lt;code&gt;departments&lt;/code&gt; table, and we want to retrieve all employees, even if they are not assigned to a department:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt;
    &lt;span class="n"&gt;employees&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;employee_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;departments&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;department_name&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt;
    &lt;span class="n"&gt;employees&lt;/span&gt;
&lt;span class="k"&gt;LEFT&lt;/span&gt; &lt;span class="k"&gt;OUTER&lt;/span&gt; &lt;span class="k"&gt;JOIN&lt;/span&gt;
    &lt;span class="n"&gt;departments&lt;/span&gt;
&lt;span class="k"&gt;ON&lt;/span&gt;
    &lt;span class="n"&gt;employees&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;department_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;departments&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;department_id&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, the query will return all rows from the &lt;code&gt;employees&lt;/code&gt; table, and if an employee does not belong to a department, the &lt;code&gt;department_name&lt;/code&gt; will show as &lt;code&gt;NULL&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example of RIGHT OUTER JOIN
&lt;/h3&gt;

&lt;p&gt;Let’s modify our previous example to retrieve all departments, even if they don’t have any employees assigned:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt;
    &lt;span class="n"&gt;employees&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;employee_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;departments&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;department_name&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt;
    &lt;span class="n"&gt;employees&lt;/span&gt;
&lt;span class="k"&gt;RIGHT&lt;/span&gt; &lt;span class="k"&gt;OUTER&lt;/span&gt; &lt;span class="k"&gt;JOIN&lt;/span&gt;
    &lt;span class="n"&gt;departments&lt;/span&gt;
&lt;span class="k"&gt;ON&lt;/span&gt;
    &lt;span class="n"&gt;employees&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;department_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;departments&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;department_id&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This query will return all rows from the &lt;code&gt;departments&lt;/code&gt; table, and if a department doesn’t have any employees, the &lt;code&gt;employee_name&lt;/code&gt; will show as &lt;code&gt;NULL&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example of FULL OUTER JOIN
&lt;/h3&gt;

&lt;p&gt;To retrieve all employees and all departments, including those that don’t have a match in the other table, you can use a &lt;code&gt;FULL OUTER JOIN&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt;
    &lt;span class="n"&gt;employees&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;employee_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;departments&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;department_name&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt;
    &lt;span class="n"&gt;employees&lt;/span&gt;
&lt;span class="k"&gt;FULL&lt;/span&gt; &lt;span class="k"&gt;OUTER&lt;/span&gt; &lt;span class="k"&gt;JOIN&lt;/span&gt;
    &lt;span class="n"&gt;departments&lt;/span&gt;
&lt;span class="k"&gt;ON&lt;/span&gt;
    &lt;span class="n"&gt;employees&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;department_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;departments&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;department_id&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This query will return all rows from both tables. If an employee is not assigned to a department, &lt;code&gt;department_name&lt;/code&gt; will be &lt;code&gt;NULL&lt;/code&gt;. If a department has no employees, &lt;code&gt;employee_name&lt;/code&gt; will be &lt;code&gt;NULL&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example: LEFT OUTER JOIN with WHERE and ORDER BY
&lt;/h3&gt;

&lt;p&gt;Here’s a query that retrieves all employees (even those without a department) and filters the results to only include employees from specific departments. The result is sorted in ascending order by employee name.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt;
    &lt;span class="k"&gt;DISTINCT&lt;/span&gt; &lt;span class="n"&gt;employees&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;employee_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;departments&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;department_name&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt;
    &lt;span class="n"&gt;employees&lt;/span&gt;

&lt;span class="k"&gt;LEFT&lt;/span&gt; &lt;span class="k"&gt;OUTER&lt;/span&gt; &lt;span class="k"&gt;JOIN&lt;/span&gt;
    &lt;span class="n"&gt;departments&lt;/span&gt;
&lt;span class="k"&gt;ON&lt;/span&gt;
    &lt;span class="n"&gt;employees&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;department_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;departments&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;department_id&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt;
    &lt;span class="n"&gt;departments&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;department_name&lt;/span&gt; &lt;span class="k"&gt;IN&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Sales'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'HR'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt;
    &lt;span class="n"&gt;employees&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;employee_name&lt;/span&gt; &lt;span class="k"&gt;ASC&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Happy querying!&lt;/p&gt;

</description>
      <category>sql</category>
      <category>cheatsheet</category>
    </item>
    <item>
      <title>HackerRank SQL Preparation: Weather Observation Station 3(MySQL)</title>
      <dc:creator>Christian Paez</dc:creator>
      <pubDate>Tue, 27 Aug 2024 01:41:25 +0000</pubDate>
      <link>https://forem.com/christianpaez/hackerrank-sql-preparation-weather-observation-station-3mysql-2l73</link>
      <guid>https://forem.com/christianpaez/hackerrank-sql-preparation-weather-observation-station-3mysql-2l73</guid>
      <description>&lt;p&gt;&lt;strong&gt;Problem Statement:&lt;/strong&gt;&lt;br&gt;
Query a list of CITY names from &lt;strong&gt;STATION&lt;/strong&gt; for cities that have an even ID number. Print the results in any order, but exclude duplicates from the answer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Link:&lt;/strong&gt; &lt;a href="https://www.hackerrank.com/challenges/weather-observation-station-3/problem?isFullScreen=true" rel="noopener noreferrer"&gt;HackerRank - Weather Observation Station 3&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="k"&gt;DISTINCT&lt;/span&gt; &lt;span class="n"&gt;CITY&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;STATION&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;ID&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;SELECT DISTINCT CITY&lt;/code&gt;: This part of the query specifies that you want to retrieve the &lt;code&gt;CITY&lt;/code&gt; column from the &lt;strong&gt;STATION&lt;/strong&gt; table, and &lt;code&gt;DISTINCT&lt;/code&gt; ensures that each city name is unique, eliminating any duplicates from the result.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;FROM STATION&lt;/code&gt;: Indicates that you are selecting data from the &lt;strong&gt;STATION&lt;/strong&gt; table.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;WHERE ID % 2 = 0&lt;/code&gt;: This condition filters the rows to include only those cities where the &lt;code&gt;ID&lt;/code&gt; is an even number. The modulo operation (&lt;code&gt;% 2 = 0&lt;/code&gt;) checks if the &lt;code&gt;ID&lt;/code&gt; is divisible by 2, meaning it's even.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This query will return a list of unique city names from the &lt;strong&gt;STATION&lt;/strong&gt; table where the city has an even &lt;code&gt;ID&lt;/code&gt; number. The result will exclude any duplicate city names.&lt;/p&gt;

</description>
      <category>sql</category>
      <category>hackerrank</category>
      <category>writeups</category>
      <category>mysql</category>
    </item>
    <item>
      <title>HackerRank SQL Preparation: Weather Observation Station 1(MySQL)</title>
      <dc:creator>Christian Paez</dc:creator>
      <pubDate>Sun, 09 Jun 2024 18:31:33 +0000</pubDate>
      <link>https://forem.com/christianpaez/hackerrank-sql-preparation-weather-observation-station-1mysql-1gke</link>
      <guid>https://forem.com/christianpaez/hackerrank-sql-preparation-weather-observation-station-1mysql-1gke</guid>
      <description>&lt;p&gt;&lt;strong&gt;Problem Statement:&lt;/strong&gt;&lt;br&gt;
Query a list of CITY and STATE from the &lt;strong&gt;STATION&lt;/strong&gt; table.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Link:&lt;/strong&gt; &lt;a href="https://www.hackerrank.com/challenges/weather-observation-station-1/problem"&gt;HackerRank - Weather Observation Station 1&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;CITY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;STATE&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;STATION&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;SELECT CITY, STATE&lt;/code&gt;: This part of the query specifies that you want to retrieve the &lt;code&gt;CITY&lt;/code&gt; and &lt;code&gt;STATE&lt;/code&gt; columns from the &lt;strong&gt;STATION&lt;/strong&gt; table.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;FROM STATION&lt;/code&gt;: Indicates that you are selecting data from the &lt;strong&gt;STATION&lt;/strong&gt; table.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>sql</category>
      <category>writeups</category>
      <category>hackerrank</category>
      <category>mysql</category>
    </item>
    <item>
      <title>HackerRank SQL Preparation: Japanese Cities' Names(MySQL)</title>
      <dc:creator>Christian Paez</dc:creator>
      <pubDate>Sun, 09 Jun 2024 18:24:42 +0000</pubDate>
      <link>https://forem.com/christianpaez/hackerrank-sql-preparation-japanese-cities-namesmysql-5ap1</link>
      <guid>https://forem.com/christianpaez/hackerrank-sql-preparation-japanese-cities-namesmysql-5ap1</guid>
      <description>&lt;p&gt;&lt;strong&gt;Problem Statement:&lt;/strong&gt;&lt;br&gt;
Query the names of all Japanese cities in the &lt;strong&gt;CITY&lt;/strong&gt; table. The &lt;code&gt;COUNTRYCODE&lt;/code&gt; for Japan is &lt;code&gt;JPN&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Link:&lt;/strong&gt; &lt;a href="https://www.hackerrank.com/challenges/japanese-cities-name/problem"&gt;HackerRank - Japanese Cities Name&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;NAME&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;CITY&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;COUNTRYCODE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'JPN'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;SELECT NAME&lt;/code&gt;: This part of the query specifies that you want to retrieve the &lt;code&gt;NAME&lt;/code&gt; column from the &lt;strong&gt;CITY&lt;/strong&gt; table.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;FROM CITY&lt;/code&gt;: Indicates that you are selecting data from the &lt;strong&gt;CITY&lt;/strong&gt; table.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;WHERE COUNTRYCODE = 'JPN'&lt;/code&gt;: This condition filters the rows to include only those cities where the &lt;code&gt;COUNTRYCODE&lt;/code&gt; is 'JPN' (Japan).&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>sql</category>
      <category>mysql</category>
      <category>writeups</category>
      <category>hackerrank</category>
    </item>
    <item>
      <title>HackerRank SQL Preparation: Japanese Cities' Attributes(MySQL)</title>
      <dc:creator>Christian Paez</dc:creator>
      <pubDate>Thu, 06 Jun 2024 14:18:07 +0000</pubDate>
      <link>https://forem.com/christianpaez/hackerrank-sql-preparation-japanese-cities-attributesmysql-12e9</link>
      <guid>https://forem.com/christianpaez/hackerrank-sql-preparation-japanese-cities-attributesmysql-12e9</guid>
      <description>&lt;p&gt;&lt;strong&gt;Problem Statement:&lt;/strong&gt;&lt;br&gt;
Query all attributes of every Japanese city in the &lt;strong&gt;CITY&lt;/strong&gt; table. The &lt;code&gt;COUNTRYCODE&lt;/code&gt; for Japan is &lt;code&gt;JPN&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Link:&lt;/strong&gt; &lt;a href="https://www.hackerrank.com/challenges/japanese-cities-attributes/problem"&gt;HackerRank - Japanese Cities Attributes&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;CITY&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;COUNTRYCODE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'JPN'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;SELECT *&lt;/code&gt;: The asterisk (*) is a wildcard character in SQL that means "all columns." This part of the query specifies that you want to retrieve all columns from the table.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;FROM CITY&lt;/code&gt;: Indicates that you are selecting data from the &lt;strong&gt;CITY&lt;/strong&gt; table.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;WHERE COUNTRYCODE = 'JPN'&lt;/code&gt;: This condition filters the rows to include only the cities where the &lt;code&gt;COUNTRYCODE&lt;/code&gt; is 'JPN' (Japan).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This query will return all the columns for every row in the &lt;strong&gt;CITY&lt;/strong&gt; table where the &lt;code&gt;COUNTRYCODE&lt;/code&gt; is 'JPN'. It's useful when you need to retrieve all details about every city in Japan.&lt;/p&gt;

&lt;p&gt;By running this query, you can see the complete dataset of Japanese cities stored in the &lt;strong&gt;CITY&lt;/strong&gt; table, including information such as city names, populations, districts, and other relevant attributes.&lt;/p&gt;

</description>
      <category>sql</category>
      <category>writeups</category>
      <category>hackerrank</category>
      <category>mysql</category>
    </item>
    <item>
      <title>HackerRank SQL Preparation: Select by ID(MySQL)</title>
      <dc:creator>Christian Paez</dc:creator>
      <pubDate>Thu, 06 Jun 2024 14:07:20 +0000</pubDate>
      <link>https://forem.com/christianpaez/hackerrank-sql-preparation-select-by-idmysql-267j</link>
      <guid>https://forem.com/christianpaez/hackerrank-sql-preparation-select-by-idmysql-267j</guid>
      <description>&lt;p&gt;&lt;strong&gt;Problem Statement:&lt;/strong&gt;&lt;br&gt;
Query all columns for a city in the &lt;strong&gt;CITY&lt;/strong&gt; table with the ID 1661.&lt;/p&gt;



&lt;p&gt;&lt;strong&gt;Link:&lt;/strong&gt; &lt;a href="https://www.hackerrank.com/challenges/select-by-id/problem"&gt;HackerRank - Select by ID&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;CITY&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;ID&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1661&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;SELECT *&lt;/code&gt;: The asterisk (*) is a wildcard character in SQL that means "all columns." This part of the query specifies that you want to retrieve all columns from the table.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;FROM CITY&lt;/code&gt;: Indicates that you are selecting data from the &lt;strong&gt;CITY&lt;/strong&gt; table.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;WHERE ID = 1661&lt;/code&gt;: This condition filters the rows to include only the city with the specific &lt;code&gt;ID&lt;/code&gt; of 1661.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This query will return all the columns for the row in the &lt;strong&gt;CITY&lt;/strong&gt; table where the &lt;code&gt;ID&lt;/code&gt; is 1661. It's useful when you need to retrieve all details about a specific city identified by its unique ID.&lt;/p&gt;

&lt;p&gt;By running this query, you can see all the attributes (such as city name, country code, population, etc.) for the city that has the ID of 1661.&lt;/p&gt;

</description>
      <category>sql</category>
      <category>writeups</category>
      <category>hackerrank</category>
      <category>mysql</category>
    </item>
    <item>
      <title>HackerRank SQL Preparation: Select All(MySQL)</title>
      <dc:creator>Christian Paez</dc:creator>
      <pubDate>Thu, 06 Jun 2024 13:57:03 +0000</pubDate>
      <link>https://forem.com/christianpaez/hackerrank-sql-preparation-select-allmysql-31da</link>
      <guid>https://forem.com/christianpaez/hackerrank-sql-preparation-select-allmysql-31da</guid>
      <description>&lt;p&gt;&lt;strong&gt;Problem Statement:&lt;/strong&gt;&lt;br&gt;
Query all columns (attributes) for every row in the &lt;strong&gt;CITY&lt;/strong&gt; table.&lt;/p&gt;



&lt;p&gt;&lt;strong&gt;Link:&lt;/strong&gt; &lt;a href="https://www.hackerrank.com/challenges/select-all-sql/problem"&gt;HackerRank - Select All SQL&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;CITY&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;SELECT *&lt;/code&gt;: The asterisk (*) is a wildcard character in SQL that means "all columns." This part of the query specifies that you want to retrieve all columns from the table.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;FROM CITY&lt;/code&gt;: Indicates that you are selecting data from the &lt;strong&gt;CITY&lt;/strong&gt; table.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This query will return all the columns for every row in the &lt;strong&gt;CITY&lt;/strong&gt; table. It's useful when you need to inspect or analyze all data available in the table without any specific filtering or conditions.&lt;/p&gt;

</description>
      <category>sql</category>
      <category>writeups</category>
      <category>hackerrank</category>
      <category>mysql</category>
    </item>
    <item>
      <title>Automate binary execution at Startup with BASH</title>
      <dc:creator>Christian Paez</dc:creator>
      <pubDate>Wed, 22 May 2024 20:41:26 +0000</pubDate>
      <link>https://forem.com/christianpaez/automate-binary-execution-at-startup-with-bash-8pe</link>
      <guid>https://forem.com/christianpaez/automate-binary-execution-at-startup-with-bash-8pe</guid>
      <description>&lt;p&gt;Automating the startup of frequently used binaries can save time and streamline your workflow. This blog post introduces a simple Bash script that adds specified binaries to a function that executes them every time you start your computer.&lt;/p&gt;

&lt;h3&gt;
  
  
  Benefits of Automating Program Execution at Startup:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Efficiency&lt;/strong&gt;: Automating the startup of commonly used programs reduces manual steps and ensures your environment is ready with minimal effort.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Consistency&lt;/strong&gt;: Ensures that necessary programs and scripts are always running without the need to remember and manually start them each time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Productivity&lt;/strong&gt;: Frees up mental bandwidth, allowing you to focus on your tasks rather than setting up your environment every time you boot your computer.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Learning&lt;/strong&gt;: Writing and modifying Bash scripts enhances your scripting skills and deepens your understanding of system startup processes.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  The Script:
&lt;/h3&gt;

&lt;p&gt;Our Bash script automates the process of executing binaries when our system starts, we made a function that takes a list of binaries and executes them, this will be added to your &lt;code&gt;.bashrc&lt;/code&gt; file:&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="k"&gt;function &lt;/span&gt;startup&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nv"&gt;BINARIES&lt;/span&gt;&lt;span class="o"&gt;=(&lt;/span&gt;
         &lt;span class="s2"&gt;"/usr/bin/firefox"&lt;/span&gt;
         &lt;span class="s2"&gt;"/usr/bin/code"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;

    check_binary&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nb"&gt;local &lt;/span&gt;&lt;span class="nv"&gt;binary&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="nt"&gt;-x&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$binary&lt;/span&gt;&lt;span class="s2"&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;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Found binary: &lt;/span&gt;&lt;span class="nv"&gt;$binary&lt;/span&gt;&lt;span class="s2"&gt;, executing..."&lt;/span&gt;
            &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$binary&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &amp;amp; &lt;span class="nb"&gt;disown
        &lt;/span&gt;&lt;span class="k"&gt;else
            &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Binary not found or not executable: &lt;/span&gt;&lt;span class="nv"&gt;$binary&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
        &lt;span class="k"&gt;fi&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;for &lt;/span&gt;binary &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;BINARIES&lt;/span&gt;&lt;span class="p"&gt;[@]&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do
        &lt;/span&gt;check_binary &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$binary&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
    &lt;span class="k"&gt;done&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Instructions for Using the Script:
&lt;/h3&gt;

&lt;p&gt;After you boot up your system, just type the function name in a terminal:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;You can also execute a gist that adds the function automatically to your &lt;code&gt;.bashrc&lt;/code&gt; file, you can then modify the &lt;code&gt;BINARIES&lt;/code&gt; and use the function on system boot up:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-L&lt;/span&gt; https://artofcode.tech/add-startup-function | bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>bash</category>
      <category>gists</category>
      <category>linux</category>
    </item>
    <item>
      <title>Simplifying PATH Management with Bash</title>
      <dc:creator>Christian Paez</dc:creator>
      <pubDate>Tue, 07 May 2024 03:39:12 +0000</pubDate>
      <link>https://forem.com/christianpaez/simplifying-path-management-with-bash-4870</link>
      <guid>https://forem.com/christianpaez/simplifying-path-management-with-bash-4870</guid>
      <description>

&lt;p&gt;In the world of command-line, every keystroke counts. One essential aspect of this efficiency is managing your system's PATH variable. A well-managed PATH ensures easy access to frequently used scripts and executables. In this blog post, we introduce a simple Bash script that streamlines the process of adding directories to your PATH, along with instructions on how to use it with &lt;code&gt;curl&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Benefits of Writing Your Own Scripts and Adding Them to PATH:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Efficiency:&lt;/strong&gt; Writing custom scripts allows you to automate repetitive tasks and tailor them to your specific needs. By adding them to your PATH, you can execute them from anywhere in your terminal without specifying their full path.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Consistency:&lt;/strong&gt; Adding scripts to your PATH ensures consistency across your system. You don't have to remember the exact location of each script; they're readily available for execution.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Flexibility:&lt;/strong&gt; With scripts in your PATH, you have the flexibility to create your own command-line utilities tailored to your workflow. Whether it's simplifying complex commands or automating system tasks, the possibilities are endless.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Knowledge Enhancement:&lt;/strong&gt; Writing Bash scripts enhances your understanding of shell scripting and Linux systems. You'll learn about variables, loops, conditionals, and other fundamental concepts, empowering you to create more sophisticated scripts in the future.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Brief Description of the Script:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Our Bash script automates the process of adding directories to your PATH variable in the &lt;code&gt;.bashrc&lt;/code&gt; file. It takes the current directory you are in and adds it to the PATH in your &lt;code&gt;.bashrc&lt;/code&gt; file.&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="c"&gt;#!/bin/bash&lt;/span&gt;

&lt;span class="c"&gt;# Function to add current directory to PATH in .bashrc file&lt;/span&gt;
add_current_dir_to_path&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="c"&gt;# Get the current directory&lt;/span&gt;
    &lt;span class="nb"&gt;local &lt;/span&gt;&lt;span class="nv"&gt;current_dir&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;pwd&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;

    &lt;span class="c"&gt;# Print the current directory&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Current directory: &lt;/span&gt;&lt;span class="nv"&gt;$current_dir&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;

    &lt;span class="nb"&gt;local &lt;/span&gt;&lt;span class="nv"&gt;shell_config&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;".bashrc"&lt;/span&gt;

    &lt;span class="c"&gt;# Check if the directory is already in PATH&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="s2"&gt;":&lt;/span&gt;&lt;span class="nv"&gt;$PATH&lt;/span&gt;&lt;span class="s2"&gt;:"&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="k"&gt;*&lt;/span&gt;&lt;span class="s2"&gt;":&lt;/span&gt;&lt;span class="nv"&gt;$current_dir&lt;/span&gt;&lt;span class="s2"&gt;:"&lt;/span&gt;&lt;span class="k"&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;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Current directory is already in PATH."&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;
        &lt;span class="c"&gt;# Check if PATH variable is empty&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="nt"&gt;-z&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$PATH&lt;/span&gt;&lt;span class="s2"&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;
            &lt;span class="c"&gt;# If PATH is empty, directly append the current directory&lt;/span&gt;
            &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"export PATH=&lt;/span&gt;&lt;span class="nv"&gt;$current_dir&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="s2"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;$shell_config&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;
            &lt;span class="c"&gt;# Append the current directory to the PATH variable&lt;/span&gt;
            &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"export PATH=&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="nv"&gt;$PATH&lt;/span&gt;&lt;span class="s2"&gt;:&lt;/span&gt;&lt;span class="nv"&gt;$current_dir&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="s2"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;$shell_config&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
        &lt;span class="k"&gt;fi
        &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Current directory added to PATH in &lt;/span&gt;&lt;span class="nv"&gt;$shell_config&lt;/span&gt;&lt;span class="s2"&gt;."&lt;/span&gt;
        &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Remember to execute 'source &lt;/span&gt;&lt;span class="nv"&gt;$shell_config&lt;/span&gt;&lt;span class="s2"&gt;' to update the PATH."&lt;/span&gt;
    &lt;span class="k"&gt;fi&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;# Call the function &lt;/span&gt;
add_current_dir_to_path

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Instructions for Using with curl:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To use the script with &lt;code&gt;curl&lt;/code&gt;, simply run the following command in your terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-L&lt;/span&gt; https://artofcode.tech/add-path | bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>bash</category>
      <category>gists</category>
      <category>linux</category>
    </item>
    <item>
      <title>Automating Video editing with programming knowledge</title>
      <dc:creator>Christian Paez</dc:creator>
      <pubDate>Sat, 13 Apr 2024 19:03:16 +0000</pubDate>
      <link>https://forem.com/christianpaez/automating-video-editing-with-programming-knowledge-4gh9</link>
      <guid>https://forem.com/christianpaez/automating-video-editing-with-programming-knowledge-4gh9</guid>
      <description>&lt;p&gt;Many video editing tasks can be repetitive and time-consuming, especially when applied frequently across different videos. While professional software like Adobe After Effects offer scripting tools for automation, developers who prefer a streamlined approach without the need to open heavy software can turn to Python and OpenCV. In this blog post, we'll explore how to enhance videos by adding opacity transitions at the start and end using Python and OpenCV. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Basic Functionalities of OpenCV:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;OpenCV is a popular library used for computer vision and image &lt;br&gt;
processing tasks. It provides a wide range of functionalities. In this blog post, we'll focus on leveraging OpenCV's video editing capabilities to add opacity transitions to a video.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Adding Opacity Transitions with Python and OpenCV:&lt;/strong&gt;&lt;br&gt;
To add opacity transitions to a video, we'll follow these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Setting Up the Project:&lt;/strong&gt;
Import the necessary libraries (&lt;code&gt;cv2&lt;/code&gt;, &lt;code&gt;numpy&lt;/code&gt;, &lt;code&gt;tqdm&lt;/code&gt;) and define the input and output video paths.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reading the Input Video:&lt;/strong&gt;
Use OpenCV to read the input video and retrieve its properties such as frame width, height, frame rate, and total frame count.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Adding Opacity Transitions:&lt;/strong&gt;
Calculate opacity levels for the start and end transitions and apply them to the video frames using OpenCV's image manipulation functions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Writing the Output Video:&lt;/strong&gt;
Create a new video file and write the edited frames with opacity transitions using OpenCV's &lt;code&gt;VideoWriter&lt;/code&gt; class.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Displaying Progress and Messages:&lt;/strong&gt;
Use the &lt;code&gt;tqdm&lt;/code&gt; library to create a progress bar and print informative messages during video processing.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here's the complete Python script for adding opacity transitions to a video using Python and OpenCV:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;cv2&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;numpy&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;np&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="nx"&gt;tqdm&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;tqdm&lt;/span&gt;

&lt;span class="nx"&gt;input_video_path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;input_video.mp4&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="nx"&gt;output_video_path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;output_video.mp4&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="nx"&gt;cap&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;cv2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;VideoCapture&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;input_video_path&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nx"&gt;not&lt;/span&gt; &lt;span class="nx"&gt;cap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isOpened&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Error: Could not open video file.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;exit&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="nx"&gt;frame_width&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;cap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="nx"&gt;frame_height&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;cap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="nx"&gt;fps&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;cap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="nx"&gt;frame_count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;cap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="nx"&gt;fade_frames&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;15&lt;/span&gt;  &lt;span class="err"&gt;#&lt;/span&gt; &lt;span class="nb"&gt;Number&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;frames&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="nx"&gt;the&lt;/span&gt; &lt;span class="nx"&gt;opacity&lt;/span&gt; &lt;span class="nx"&gt;transition&lt;/span&gt;

&lt;span class="nx"&gt;fourcc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;cv2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;VideoWriter_fourcc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;mp4v&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nx"&gt;out&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;cv2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;VideoWriter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;output_video_path&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;fourcc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;fps&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;frame_width&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;frame_height&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="kd"&gt;with&lt;/span&gt; &lt;span class="nf"&gt;tqdm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;total&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nx"&gt;frame_count&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;pbar&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;frame_count&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="nx"&gt;ret&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;frame&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;cap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nx"&gt;not&lt;/span&gt; &lt;span class="nx"&gt;ret&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;break&lt;/span&gt;

        &lt;span class="err"&gt;#&lt;/span&gt; &lt;span class="nx"&gt;Calculate&lt;/span&gt; &lt;span class="nx"&gt;opacity&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="nx"&gt;the&lt;/span&gt; &lt;span class="nx"&gt;start&lt;/span&gt; &lt;span class="nx"&gt;and&lt;/span&gt; &lt;span class="nx"&gt;end&lt;/span&gt; &lt;span class="nx"&gt;transitions&lt;/span&gt;
        &lt;span class="nx"&gt;start_alpha&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nx"&gt;fade_frames&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nx"&gt;end_alpha&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;frame_count&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nx"&gt;fade_frames&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="err"&gt;#&lt;/span&gt; &lt;span class="nx"&gt;Apply&lt;/span&gt; &lt;span class="nx"&gt;opacity&lt;/span&gt; &lt;span class="nx"&gt;transitions&lt;/span&gt;
        &lt;span class="nx"&gt;frame&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;cv2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addWeighted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;start_alpha&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nx"&gt;frame&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;cv2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addWeighted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;end_alpha&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="nx"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nx"&gt;pbar&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nx"&gt;cap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;release&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="nx"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;release&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="nx"&gt;cv2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;destroyAllWindows&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Video processing completed.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The result looks something like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/shorts/Pbb1FYdNdlc"&gt;https://www.youtube.com/shorts/Pbb1FYdNdlc&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Experiment with the provided script, adjust parameters, and explore additional video editing functionalities offered by OpenCV to take your video editing skills to the next level.&lt;/p&gt;

</description>
      <category>software</category>
      <category>automation</category>
      <category>scripting</category>
    </item>
    <item>
      <title>HackerRank SQL preparation; Revising the Select Query II(MySQL)</title>
      <dc:creator>Christian Paez</dc:creator>
      <pubDate>Wed, 03 Apr 2024 21:59:56 +0000</pubDate>
      <link>https://forem.com/christianpaez/hackerrank-sql-preparation-revising-the-select-query-iimysql-3kh4</link>
      <guid>https://forem.com/christianpaez/hackerrank-sql-preparation-revising-the-select-query-iimysql-3kh4</guid>
      <description>&lt;p&gt;&lt;strong&gt;Problem Statement:&lt;/strong&gt;&lt;br&gt;
Query the &lt;code&gt;NAME&lt;/code&gt; field for American cities in the &lt;strong&gt;CITY&lt;/strong&gt; table with populations larger than 120,000. The &lt;code&gt;CountryCode&lt;/code&gt; for America is &lt;code&gt;USA&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Link:&lt;/strong&gt;&lt;a href="https://www.hackerrank.com/challenges/revising-the-select-query-2/problem"&gt;HackerRank - Revising the SELECT Query 2&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;NAME&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;CITY&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;POPULATION&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;120000&lt;/span&gt; &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;COUNTRYCODE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'USA'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;SELECT NAME&lt;/code&gt;: This part of the query specifies that you want to retrieve the &lt;code&gt;NAME&lt;/code&gt; field.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;FROM CITY&lt;/code&gt;: Indicates that you are selecting data from the &lt;strong&gt;CITY&lt;/strong&gt; table.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;WHERE POPULATION &amp;gt; 120000&lt;/code&gt;: This condition filters the rows and includes only those cities where the population is larger than 120,000.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;AND COUNTRYCODE = 'USA'&lt;/code&gt;: This additional condition ensures that only American cities (USA) are included in the result, based on the &lt;code&gt;CountryCode&lt;/code&gt; column.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>sql</category>
      <category>writeups</category>
      <category>hackerrank</category>
    </item>
  </channel>
</rss>
