<?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: SpiffyEight77</title>
    <description>The latest articles on Forem by SpiffyEight77 (@spiffyeight77).</description>
    <link>https://forem.com/spiffyeight77</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%2F165840%2F32271cf1-d43d-4dd5-9850-9a89af7d1dbd.png</url>
      <title>Forem: SpiffyEight77</title>
      <link>https://forem.com/spiffyeight77</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/spiffyeight77"/>
    <language>en</language>
    <item>
      <title>Generating a GPG key to your GitHub</title>
      <dc:creator>SpiffyEight77</dc:creator>
      <pubDate>Sun, 11 Jun 2023 10:53:17 +0000</pubDate>
      <link>https://forem.com/spiffyeight77/generating-a-gpg-key-to-your-github-43nn</link>
      <guid>https://forem.com/spiffyeight77/generating-a-gpg-key-to-your-github-43nn</guid>
      <description>&lt;h2&gt;
  
  
  What is GPG
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;GPG (GNU Privacy Guard) is an open-source software used for encrypting and signing data. GPG uses asymmetric encryption technology where the cryptographic keys are divided into two parts: a public key and a private key. The public key is used to encrypt data and only the user holding the private key can decrypt it. The private key is used for digital signature which proves that the data indeed comes from a specified sender and has not been tampered with.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Why recommend to use GPG to protect your git commit
&lt;/h2&gt;

&lt;p&gt;There is a risk of Git commit being impersonated because it does not have default authentication mechanisms. If someone knows your name and email address, they can impersonate your commits in the Git repository, which can damage your reputation or lead to improper behavior in your name.&lt;/p&gt;

&lt;p&gt;To avoid this, you can use GPG signatures to authenticate Git commits.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setup GPG in mac
&lt;/h2&gt;

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



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew install gnupg
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Generate key pair
&lt;/h3&gt;

&lt;p&gt;All step set to default&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gpg --full-generate-key --expert

Please select what kind of key you want:
   (1) RSA and RSA
   (2) DSA and Elgamal
   (3) DSA (sign only)
   (4) RSA (sign only)
   (7) DSA (set your own capabilities)
   (8) RSA (set your own capabilities)
   (9) ECC (sign and encrypt) *default*
  (10) ECC (sign only)
  (11) ECC (set your own capabilities)
  (13) Existing key
  (14) Existing key from card
Your selection?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Export key
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Check the exiting key
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gpg --list-secret-keys --keyid-format LONG

gpg: checking the trustdb
gpg: marginals needed: 3  completes needed: 1  trust model: pgp
gpg: depth: 0  valid:   1  signed:   0  trust: 0-, 0q, 0n, 0m, 0f, 1u
[keyboxd]
---------
sec   ed25519/XXXXXXXXXXXX 2023-05-28 [SC]
      XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
uid                 [ultimate] SpiffyEight77
ssb   cv25519/XXXXXXXXXXXX 2023-05-28 [E]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Export the public key
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gpg --armor --export XXXXXXXXXXXX
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And then past it into GitHub &lt;code&gt;SSH and GPG keys&lt;/code&gt; setting.&lt;/p&gt;

&lt;h3&gt;
  
  
  Setting the environment to the shell
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo 'export GPG_TTY=$(tty)' &amp;gt;&amp;gt; ~/.zshrc &amp;amp;&amp;amp; source ~/.zshrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Allow git to use the GPG key for signing
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git config --global user.signingkey XXXXXXXXXXXXX

git config --global commit.gpgsign true
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Export for backup (optional)
&lt;/h2&gt;

&lt;p&gt;To export the public and secret key for backup and please keep it in a safe place&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gpg --armor --output gpg_sec_key.gpg --export XXXXXXXXXXX
gpg --armor --output gpg_sec_key.gpg --export-secret-keys XXXXXXXXXXX
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>gpg</category>
      <category>git</category>
    </item>
    <item>
      <title>HackerRank SQL Basic Select</title>
      <dc:creator>SpiffyEight77</dc:creator>
      <pubDate>Sun, 12 Mar 2023 05:40:00 +0000</pubDate>
      <link>https://forem.com/spiffyeight77/hackerrank-sql-basic-select-1dj5</link>
      <guid>https://forem.com/spiffyeight77/hackerrank-sql-basic-select-1dj5</guid>
      <description>&lt;h2&gt;
  
  
  Before Starting
&lt;/h2&gt;

&lt;p&gt;I haven't handwritten SQL for a long time, but I have recently started practicing again to regain my skills. This post mainly records interesting problems and solutions in SQL Basic Select.&lt;/p&gt;

&lt;h2&gt;
  
  
  SQL Basic Select
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Weather Observation Station 4
&lt;/h3&gt;

&lt;p&gt;Find the difference between the total number of &lt;strong&gt;CITY&lt;/strong&gt; entries in the table and the number of distinct &lt;strong&gt;CITY&lt;/strong&gt; entries in the table.&lt;br&gt;&lt;br&gt;
The &lt;strong&gt;STATION&lt;/strong&gt; table is described as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;| Field    | Type          | 
|----------|---------------| 
| ID       | NNUMBER       | 
| CITY     | VARCHAR2(21)  | 
| STATE    | VARCHAR2(2)   | 
| LAT_N    | NUMBER        | 
| LONG_W   | NUMBER        |
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The objective of this problem is to determine how to utilize the functions &lt;code&gt;COUNT&lt;/code&gt; and &lt;code&gt;DISTINCT&lt;/code&gt; in order to compute the quantity of answers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT COUNT(CITY) - COUNT(DISTINCT(CITY))
FROM STATION;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Weather Observation Station 5
&lt;/h3&gt;

&lt;p&gt;Query the two cities in &lt;strong&gt;STATION&lt;/strong&gt; with the shortest and longest &lt;em&gt;CITY&lt;/em&gt; names, as well as their respective lengths (i.e.: number of characters in the name). If there is more than one smallest or largest city, choose the one that comes first when ordered alphabetically.&lt;br&gt;&lt;br&gt;
The &lt;strong&gt;STATION&lt;/strong&gt; table is described as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;| Field    | Type          | 
|----------|---------------| 
| ID       | NNUMBER       | 
| CITY     | VARCHAR2(21)  | 
| STATE    | VARCHAR2(2)   | 
| LAT_N    | NUMBER        | 
| LONG_W   | NUMBER        |
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The goal of this problem is to use the &lt;code&gt;UNION&lt;/code&gt; 、&lt;code&gt;LIMIT&lt;/code&gt;  keywords and &lt;code&gt;LENGTH&lt;/code&gt; function effectively for querying answers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(SELECT CITY, LENGTH(CITY)
FROM STATION
ORDER BY LENGTH(CITY) ASC, CITY ASC
LIMIT 1)
UNION
(SELECT CITY, LENGTH(CITY)
FROM STATION
ORDER BY LENGTH(CITY) DESC, CITY ASC
LIMIT 1);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Weather Observation Station 8
&lt;/h3&gt;

&lt;p&gt;Query the list of &lt;em&gt;CITY&lt;/em&gt; names from &lt;strong&gt;STATION&lt;/strong&gt; which have vowels (i.e., &lt;em&gt;a&lt;/em&gt;, &lt;em&gt;e&lt;/em&gt;, &lt;em&gt;i&lt;/em&gt;, &lt;em&gt;o&lt;/em&gt;, and &lt;em&gt;u&lt;/em&gt;) as both their first &lt;em&gt;and&lt;/em&gt; last characters. Your result cannot contain duplicates.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Input Format&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;STATION&lt;/strong&gt; table is described as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;| Field    | Type          | 
|----------|---------------| 
| ID       | NNUMBER       | 
| CITY     | VARCHAR2(21)  | 
| STATE    | VARCHAR2(2)   | 
| LAT_N    | NUMBER        | 
| LONG_W   | NUMBER        |
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The goal of this problem is to use the &lt;code&gt;LIKE&lt;/code&gt; 、&lt;code&gt;LIMIT&lt;/code&gt;  keyword effectively for querying answers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT DISTINCT(CITY)
FROM STATION
WHERE (CITY LIKE 'a%' 
    OR CITY LIKE 'e%' 
    OR CITY LIKE 'i%'
    OR CITY LIKE 'o%'
    OR CITY LIKE 'u%')
AND (CITY LIKE '%a' 
    OR CITY LIKE '%e' 
    OR CITY LIKE '%i'
    OR CITY LIKE '%o'
    OR CITY LIKE '%u');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4.  Weather Observation Station 11
&lt;/h3&gt;

&lt;p&gt;Query the list of &lt;em&gt;CITY&lt;/em&gt; names from &lt;strong&gt;STATION&lt;/strong&gt; that either do not start with vowels or do not end with vowels. Your result cannot contain duplicates.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Input Format&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;STATION&lt;/strong&gt; table is described as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;| Field    | Type          | 
|----------|---------------| 
| ID       | NNUMBER       | 
| CITY     | VARCHAR2(21)  | 
| STATE    | VARCHAR2(2)   | 
| LAT_N    | NUMBER        | 
| LONG_W   | NUMBER        |
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The goal of this problem is to use the &lt;code&gt;LIKE&lt;/code&gt; 、&lt;code&gt;NOT&lt;/code&gt; and &lt;code&gt;OR&lt;/code&gt; keyword effectively for querying answers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT DISTINCT(CITY)
FROM STATION
WHERE NOT (CITY LIKE 'a%' 
    OR CITY LIKE 'e%' 
    OR CITY LIKE 'i%'
    OR CITY LIKE 'o%'
    OR CITY LIKE 'u%')
OR NOT (CITY LIKE '%a' 
    OR CITY LIKE '%e' 
    OR CITY LIKE '%i'
    OR CITY LIKE '%o'
    OR CITY LIKE '%u');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5. Higher Than 75 Marks
&lt;/h3&gt;

&lt;p&gt;Query the &lt;em&gt;Name&lt;/em&gt; of any student in &lt;strong&gt;STUDENTS&lt;/strong&gt; who scored higher than 75  &lt;em&gt;Marks&lt;/em&gt;. Order your output by the &lt;em&gt;last three characters&lt;/em&gt; of each name. If two or more students both have names ending in the same last three characters (i.e.: Bobby, Robby, etc.), secondary sort them by ascending &lt;em&gt;ID&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Input Format&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;STUDENTS&lt;/strong&gt; table is described as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;| Colume    | Type         | 
|----------|---------------| 
| ID       | Integer       | 
| Name     | String        | 
| Marks    | Integer       |
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The goal of this problem is to use the &lt;code&gt;SUBSTR&lt;/code&gt; function for querying answers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT Name
FROM STUDENTS
WHERE Marks &amp;gt; 75
ORDER BY SUBSTR(Name, -3, 3) ASC, ID ASC;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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