<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Saviour Gidi</title>
    <description>The latest articles on DEV Community by Saviour Gidi (@saviour123).</description>
    <link>https://dev.to/saviour123</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%2F31053%2F69cbcbcf-b7df-4fcd-a21e-a567a4903939.jpeg</url>
      <title>DEV Community: Saviour Gidi</title>
      <link>https://dev.to/saviour123</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/saviour123"/>
    <language>en</language>
    <item>
      <title>Automating the Date On Your Footer.</title>
      <dc:creator>Saviour Gidi</dc:creator>
      <pubDate>Tue, 31 Dec 2019 13:52:23 +0000</pubDate>
      <link>https://dev.to/saviour123/automating-the-date-on-your-footer-1g1i</link>
      <guid>https://dev.to/saviour123/automating-the-date-on-your-footer-1g1i</guid>
      <description>&lt;p&gt;In software engineering, it often said that, once the task is repetitive🙄, automate it! So must the &lt;strong&gt;© Copyright Date&lt;/strong&gt; on the footer be automated.&lt;/p&gt;

&lt;p&gt;Footer holds details such as Sitemap, Social Links and Copyright Notice of a site.&lt;br&gt;
Eg.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F9goo1inlr7zacerjt9sy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F9goo1inlr7zacerjt9sy.png" alt="Footer Section"&gt;&lt;/a&gt;src: &lt;a href="https://www.godlife.com/en" rel="noopener noreferrer"&gt;https://www.godlife.com/en&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Approach 1
&lt;/h3&gt;

&lt;p&gt;Introduce a JavaScript tag with internal Date API. You can get the current year from the browser JS API, which means you don't have to change every other year.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add the JS script to your HTML&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
 Date().getFullYear());

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

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;Introduce a script tag in your Footer Section. &lt;/li&gt;
&lt;/ul&gt;

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

&amp;lt;p&amp;gt;
   &amp;amp;copy
   &amp;lt;script&amp;gt;
      document.write(new Date().getFullYear());
   &amp;lt;/script&amp;gt; 
   &amp;lt;a href='https://twiter.com/saviour123&amp;gt;Saviour Gidi&amp;lt;a/&amp;gt;
 &amp;lt;/p&amp;gt;


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

&lt;/div&gt;

&lt;p&gt;Output&lt;/p&gt;

&lt;p&gt;&lt;code&gt;© 2019 Saviour Gidi&lt;/code&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  Approach Two
&lt;/h3&gt;

&lt;p&gt;Introduce a script tag with AJAX and get the current Date from World Clock.&lt;/p&gt;

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

&amp;lt;p&amp;gt;
  &amp;amp;copy
  &amp;lt;p id='copyright'&amp;gt;&amp;lt;/p&amp;gt;
  Saviour Gidi
&amp;lt;/p&amp;gt;

&amp;lt;script&amp;gt;
    fetch('http://worldclockapi.com/api/json/utc/now')
      .then(data =&amp;gt; data.json())
      .then(d =&amp;gt; 
      document.getElementById('copyright').innerHTML = (new Date(d.currentDateTime).getFullYear())
)
&amp;lt;/script&amp;gt;


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

&lt;/div&gt;

&lt;p&gt;NB: This second approach is to a response in the comments.&lt;/p&gt;

&lt;p&gt;Imagine every year you have to manually change the date on the website. It's not safe for your health and your company's and I pity you🤣. To cut long story short, update your code to include the JS tag! &lt;/p&gt;

</description>
      <category>footer</category>
      <category>date</category>
      <category>newyear</category>
      <category>automation</category>
    </item>
    <item>
      <title>Troubleshooting Datadog Log Setup</title>
      <dc:creator>Saviour Gidi</dc:creator>
      <pubDate>Sat, 27 Jul 2019 17:45:08 +0000</pubDate>
      <link>https://dev.to/saviour123/troubleshooting-datadog-log-setup-hbj</link>
      <guid>https://dev.to/saviour123/troubleshooting-datadog-log-setup-hbj</guid>
      <description>&lt;h2&gt;
  
  
  Description
&lt;/h2&gt;

&lt;p&gt;The setup of datadog is so simple for anybody to do. But to get it to ship logs can be messy. This guide would help you in troubleshooting.&lt;/p&gt;

&lt;h2&gt;
  
  
  Known Issues
&lt;/h2&gt;

&lt;p&gt;After installation and having all configurations right, this include &lt;code&gt;logs_enabled: true&lt;/code&gt; set in your &lt;code&gt;datadog.yaml&lt;/code&gt;, your datadog log setup may still not work. &lt;br&gt;
These lessons are from experience and you can refer to this in times of need.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Datadog Log&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The first point of call is datadog logs. note: These logs are not managed by Logrotate so it can get very huge. I advise you &lt;code&gt;tail -n 500 /var/log/datadog/agent.log&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Check this log for TCP(Port) and Permission issues.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo cat /var/log/datadog/agent.log
# or
sudo cat /var/log/datadog/agent.log | grep permission

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



&lt;ol&gt;
&lt;li&gt;Users and Usergroup&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;From experience datadog works well if the &lt;code&gt;/etc/datadog/conf.d/awesome-app.d/conf.yaml&lt;/code&gt; is owned by&lt;br&gt;
dd-agent user and group you created during installation.&lt;br&gt;
If you are not sure, run &lt;code&gt;cd /etc/datadog/conf.d/awesome-app &amp;amp;&amp;amp; ll&lt;/code&gt; and view the usergrp and user. If the directory is owned by root or any other user, you can fix it with the following.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo chown &lt;/span&gt;dd-agent awesome-app.d/conf.yaml
&lt;span class="nb"&gt;sudo chgrp &lt;/span&gt;dd-agent awesome-app.d/conf.yaml

&lt;span class="c"&gt;# and restart datadog&lt;/span&gt;

&lt;span class="nb"&gt;sudo &lt;/span&gt;service datadog-agent restart

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



&lt;p&gt;Verify if you are still unable to ship logs.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Grant Permission to Datadog&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Most of the time, we can get lucky by running some &lt;code&gt;chmod&lt;/code&gt; on the log file we are shipping to datadog. This is not so good since the directory and log is generated by an application with a different user and group.&lt;/p&gt;

&lt;p&gt;So the best approach here is &lt;a href="https://linux.die.net/man/1/setfacl"&gt;setfacl&lt;/a&gt;. It grants permission on a file without the need to compromise its previous users or permission.&lt;/p&gt;

&lt;p&gt;Execute it as below per your path&lt;/p&gt;

&lt;p&gt;&lt;code&gt;setfacl -m u:dd-agent:rwx /var/log/awesome-app/file.log&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;or grant it on a directory&lt;/p&gt;

&lt;p&gt;&lt;code&gt;setfacl -m u:dd-agent:rwx /var/log/awesome-app&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Restart and you would be fine.&lt;/p&gt;

&lt;p&gt;Visit &lt;a href="https://docs.datadoghq.com/"&gt;https://docs.datadoghq.com/&lt;/a&gt; for more!&lt;/p&gt;

</description>
      <category>datadog</category>
      <category>permission</category>
      <category>logs</category>
    </item>
    <item>
      <title>Kong Part 1: Installation and First Setup on Ubuntu 18.04</title>
      <dc:creator>Saviour Gidi</dc:creator>
      <pubDate>Mon, 15 Oct 2018 17:14:14 +0000</pubDate>
      <link>https://dev.to/saviour123/kong-part-1-installation-and-first-setup-on-ubuntu-1804-4o3d</link>
      <guid>https://dev.to/saviour123/kong-part-1-installation-and-first-setup-on-ubuntu-1804-4o3d</guid>
      <description>&lt;p&gt;Kong is one of the open source API gateway managers around. A typical use case is when you want to manage(eg. Secure) your API and but you don't have the time to write all those logic inside your API. API Gateway is probably what you need.&lt;/p&gt;

&lt;p&gt;API  Gateways can do- Rate limiting, securing Your API with Key and tokens, logging and many more.&lt;/p&gt;

&lt;p&gt;We would use kong to protect Simple API I wrote with Flask. Watch out for Part 2.&lt;/p&gt;

&lt;h2&gt;
  
  
  Download and Install
&lt;/h2&gt;

&lt;p&gt;There are several options for installing kong, they include Debian, docker which is very prevalent, kubernates, redhat and even vagrant.&lt;/p&gt;

&lt;p&gt;Head over to &lt;a href="https://konghq.com/install/" rel="noopener noreferrer"&gt;Kong&lt;/a&gt; homepage download kong Debian image from kong website.&lt;/p&gt;

&lt;p&gt;Select the one applicable and download.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdi8uk8cgkj2sd6ck1bgx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdi8uk8cgkj2sd6ck1bgx.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Install Kong&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;$ sudo apt-get install openssl libpcre3 procps perl&lt;/code&gt; #some dependencies&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ sudo dpkg -i kongdeb.deb&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Not yet, Kong is only installed. Lets provision persistent database for it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Provision a database
&lt;/h2&gt;

&lt;p&gt;On your appliance assuming you installed kong on Ubuntu as I did, the default configuration would be available at &lt;code&gt;/etc/kong/kong.cong.default&lt;/code&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Make a copy&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;cp /etc/kong/kong.conf.default /etc/kong/kong.conf&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Configure the Datastore&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Kong support Cassandra and PostgreSQL Database. I am using PostgreSQL over here.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Provision the database&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;CREATE USER kong; CREATE DATABASE kong OWNER kong&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0usjy6cg9azmov6a8qkr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0usjy6cg9azmov6a8qkr.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Update the &lt;code&gt;kong.conf&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Scroll to the database section and add the Postgres details.&lt;br&gt;
&lt;code&gt;$ vim /etc/kong/kong.conf&lt;/code&gt; and change this section &lt;code&gt;dbname: kong, user=kong, pass=kong2018&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Start kong
&lt;/h2&gt;

&lt;p&gt;kong has some commands&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ kong migrations up&lt;/code&gt; #runs the database migrations&lt;br&gt;
&lt;code&gt;$ sudo kong start&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ curl -i http://localhost:8001&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd04cagyr8atcr84d2gl9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd04cagyr8atcr84d2gl9.png" alt="Imgur"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Bonus
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;$ sudo kong stop&lt;/code&gt; #stop kong&lt;br&gt;
&lt;code&gt;$ sudo kong health&lt;/code&gt; #kong status&lt;/p&gt;

&lt;p&gt;--Happy Hacking--&lt;/p&gt;

&lt;p&gt;NB. Watch out for Part 2, where I add the Flask API.&lt;/p&gt;

</description>
      <category>apigateway</category>
      <category>kong</category>
    </item>
  </channel>
</rss>
