<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:media="http://search.yahoo.com/mrss/"><channel><title><![CDATA[Software Engineer Tips And Tricks]]></title><description><![CDATA[Thoughts, stories and ideas.]]></description><link>https://webtips.fly.dev/</link><image><url>https://webtips.fly.dev/favicon.png</url><title>Software Engineer Tips And Tricks</title><link>https://webtips.fly.dev/</link></image><generator>Ghost 5.38</generator><lastBuildDate>Fri, 01 May 2026 11:48:02 GMT</lastBuildDate><atom:link href="https://webtips.fly.dev/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[What are P, D, Q parameters in ARIMA model]]></title><description><![CDATA[<p>The <strong>ARIMA</strong> model is a statistical model used for time series analysis and forecasting. It stands for <strong>Autoregressive</strong> <strong>Integrated</strong> <strong>Moving</strong> <strong>Average</strong>, and it requires three parameters to be specified:</p><ol><li><strong>p </strong>(the autoregressive order): This parameter specifies the number of lagged values of the dependent variable that will be used to</li></ol>]]></description><link>https://webtips.fly.dev/what-are-p-q-d/</link><guid isPermaLink="false">6438cf7feeb36e0210ebd6c6</guid><dc:creator><![CDATA[Pedi]]></dc:creator><pubDate>Fri, 14 Apr 2023 03:59:35 GMT</pubDate><content:encoded><![CDATA[<p>The <strong>ARIMA</strong> model is a statistical model used for time series analysis and forecasting. It stands for <strong>Autoregressive</strong> <strong>Integrated</strong> <strong>Moving</strong> <strong>Average</strong>, and it requires three parameters to be specified:</p><ol><li><strong>p </strong>(the autoregressive order): This parameter specifies the number of lagged values of the dependent variable that will be used to predict the current value. For example, if p=2, the current value will be predicted based on the two previous values.</li><li><strong>d</strong> (the differencing order): This parameter specifies the number of times the data needs to be differenced to make it stationary. Stationary data has a constant mean and variance over time, and is easier to model. If d=0, the data is already stationary.</li><li><strong>q</strong> (the moving average order): This parameter specifies the number of lagged errors (residuals) that will be used to predict the current value. A moving average model predicts the current value based on the average of the past errors.</li></ol><p>In summary, the parameters of the <strong>ARIMA</strong> model are used to determine the number of <strong>autoregressive</strong>, <strong>differencing</strong>, and moving average terms needed to create a model that can accurately predict future values of a time series.</p>]]></content:encoded></item><item><title><![CDATA[How to disable Go Proxy]]></title><description><![CDATA[<p>To disable Go module proxy, you can use the following steps:</p><ol><li>Set the GOPROXY environment variable to &quot;direct&quot;:</li></ol><pre><code class="language-bash">$ export GOPROXY=direct
</code></pre><p>This will instruct Go to use the modules directly from their source repositories, without going through any proxy.</p><p>2. Optionally, you can unset any other related environment</p>]]></description><link>https://webtips.fly.dev/how-to-disable-go-proxy/</link><guid isPermaLink="false">640d91ca81e9570211d5f0c1</guid><category><![CDATA[GO]]></category><category><![CDATA[bash]]></category><category><![CDATA[shell]]></category><dc:creator><![CDATA[Pedi]]></dc:creator><pubDate>Sun, 12 Mar 2023 08:49:48 GMT</pubDate><content:encoded><![CDATA[<p>To disable Go module proxy, you can use the following steps:</p><ol><li>Set the GOPROXY environment variable to &quot;direct&quot;:</li></ol><pre><code class="language-bash">$ export GOPROXY=direct
</code></pre><p>This will instruct Go to use the modules directly from their source repositories, without going through any proxy.</p><p>2. Optionally, you can unset any other related environment variables that might interfere with the direct mode:</p><pre><code class="language-bash">$ unset GOSUMDB
$ unset GONOSUMDB
</code></pre><p>3. If you want to make this change permanent, you can add the export statement to your shell profile file (e.g. ~/.bashrc for bash users, ~/.zshrc for zsh users).</p><p>After these steps, Go will not use any module proxy, and will fetch modules directly from their source repositories.</p>]]></content:encoded></item><item><title><![CDATA[Shell script which force updates a git tag]]></title><description><![CDATA[<p>Here&apos;s a shell script that will force update an existing Git tag:</p><pre><code class="language-bash">#!/bin/sh

# Get the tag name from user input
echo &quot;Enter the tag name you want to update:&quot;
read tag_name

# Verify that the tag exists
tag_exists=$(git tag -l &quot;$tag_name&</code></pre>]]></description><link>https://webtips.fly.dev/shell-script-which-force-updates-a-git-tag/</link><guid isPermaLink="false">640d913b81e9570211d5f09b</guid><category><![CDATA[git]]></category><category><![CDATA[shell]]></category><dc:creator><![CDATA[Pedi]]></dc:creator><pubDate>Sun, 12 Mar 2023 08:46:11 GMT</pubDate><content:encoded><![CDATA[<p>Here&apos;s a shell script that will force update an existing Git tag:</p><pre><code class="language-bash">#!/bin/sh

# Get the tag name from user input
echo &quot;Enter the tag name you want to update:&quot;
read tag_name

# Verify that the tag exists
tag_exists=$(git tag -l &quot;$tag_name&quot;)

if [ -z &quot;$tag_exists&quot; ]; then
  echo &quot;Tag $tag_name does not exist!&quot;
  exit 1
fi

# Force update the tag
git tag -f &quot;$tag_name&quot;

# Push the tag to the remote repository
git push -f origin &quot;$tag_name&quot;

echo &quot;Tag $tag_name has been force updated!&quot;
</code></pre><p>Here&apos;s how it works:</p><ol><li>The script prompts the user to enter the name of the tag they want to update.</li><li>The script checks if the tag exists using the <code>git tag -l</code> command. If the tag does not exist, the script prints an error message and exits with a status of 1.</li><li>If the tag exists, the script force updates the tag using the <code>git tag -f</code> command.</li><li>The script pushes the updated tag to the remote repository using the <code>git push -f</code> command.</li><li>The script prints a message indicating that the tag has been force updated.</li></ol>]]></content:encoded></item><item><title><![CDATA[Example .npmrc file for private NPM Registry organization]]></title><description><![CDATA[<p>To publish a private scoped package to the npm registry, you&apos;ll need to create an <code>.npmrc</code> file in the root directory of your package with the following content:</p><pre><code class="language-bash">//registry.npmjs.org/:_authToken=YOUR_AUTH_TOKEN
@your-scope:registry=https://registry.npmjs.org/
</code></pre><p>Replace <code>YOUR_AUTH_TOKEN</code> with your npm</p>]]></description><link>https://webtips.fly.dev/example-npmrc-file-for-private-npm-registry-organization/</link><guid isPermaLink="false">640d90e781e9570211d5f083</guid><category><![CDATA[npm]]></category><category><![CDATA[javascript]]></category><dc:creator><![CDATA[Pedi]]></dc:creator><pubDate>Sun, 12 Mar 2023 08:45:20 GMT</pubDate><content:encoded><![CDATA[<p>To publish a private scoped package to the npm registry, you&apos;ll need to create an <code>.npmrc</code> file in the root directory of your package with the following content:</p><pre><code class="language-bash">//registry.npmjs.org/:_authToken=YOUR_AUTH_TOKEN
@your-scope:registry=https://registry.npmjs.org/
</code></pre><p>Replace <code>YOUR_AUTH_TOKEN</code> with your npm authentication token, which you can generate from the npm website or using the <code>npm token create</code> command.</p><p>Replace <code>your-scope</code> with your package&apos;s scope name.</p><p>This <code>.npmrc</code> file will ensure that your scoped package is published to the correct registry with the appropriate authentication token.</p>]]></content:encoded></item><item><title><![CDATA[How to change or update Docker image tags]]></title><description><![CDATA[<p>To change the tag of an image in Docker, you can use the <code>docker tag</code> command followed by the image ID and the new tag name. Here are the steps to follow:</p><ol><li>List the images on your system using the command <code>docker images</code>.</li></ol><!--kg-card-begin: markdown--><pre><code class="language-bash">$ docker images
</code></pre>
<!--kg-card-end: markdown--><p>2. Identify the image you</p>]]></description><link>https://webtips.fly.dev/how-to-change-or-update-docker-image-tags/</link><guid isPermaLink="false">640d8fbc81e9570211d5f05c</guid><category><![CDATA[docker]]></category><dc:creator><![CDATA[Pedi]]></dc:creator><pubDate>Sun, 12 Mar 2023 08:43:10 GMT</pubDate><content:encoded><![CDATA[<p>To change the tag of an image in Docker, you can use the <code>docker tag</code> command followed by the image ID and the new tag name. Here are the steps to follow:</p><ol><li>List the images on your system using the command <code>docker images</code>.</li></ol><!--kg-card-begin: markdown--><pre><code class="language-bash">$ docker images
</code></pre>
<!--kg-card-end: markdown--><p>2. Identify the image you want to retag, and take note of its IMAGE ID.</p><!--kg-card-begin: markdown--><pre><code>REPOSITORY            TAG       IMAGE ID       CREATED       SIZE
my-image              latest    0d120b6ccaae   3 weeks ago   122MB
</code></pre>
<!--kg-card-end: markdown--><p>3. Use the <code>docker tag</code> command to retag the image. Replace <code>IMAGE_ID</code> with the ID of the image you want to retag and <code>NEW_TAG_NAME</code> with the new tag name you want to assign to the image.</p><!--kg-card-begin: markdown--><pre><code class="language-bash">$ docker tag IMAGE_ID NEW_TAG_NAME
</code></pre>
<!--kg-card-end: markdown--><p>4. For example, to retag the image <code>my-image</code> with ID <code>0d120b6ccaae</code> to <code>my-image:v2</code>, you would run the following command:</p><!--kg-card-begin: markdown--><pre><code>$ docker tag 0d120b6ccaae my-image:v2
</code></pre>
<!--kg-card-end: markdown--><p>5. Verify that the tag has been changed by listing the images again.</p><pre><code class="language-bash">$ docker images</code></pre><p>You should see the image with its new tag listed.</p>]]></content:encoded></item><item><title><![CDATA[How to do health check for MongoJS in NodeJS]]></title><description><![CDATA[<p>Here&apos;s an example of an event-based solution in Node.js to handle MongoDB connection health checks:</p><!--kg-card-begin: markdown--><pre><code>const EventEmitter = require(&apos;events&apos;);
const MongoClient = require(&apos;mongodb&apos;).MongoClient;

const MONGO_URI = &apos;mongodb://localhost:27017/mydb&apos;;

class MongoDBHealthCheck extends EventEmitter {
  constructor() {
    super();
    this.mongoClient = new MongoClient(</code></pre>]]></description><link>https://webtips.fly.dev/how-to-do-health-check-for-mongojs-in-nodejs/</link><guid isPermaLink="false">640d8f4881e9570211d5f04d</guid><dc:creator><![CDATA[Pedi]]></dc:creator><pubDate>Sun, 12 Mar 2023 08:38:05 GMT</pubDate><content:encoded><![CDATA[<p>Here&apos;s an example of an event-based solution in Node.js to handle MongoDB connection health checks:</p><!--kg-card-begin: markdown--><pre><code>const EventEmitter = require(&apos;events&apos;);
const MongoClient = require(&apos;mongodb&apos;).MongoClient;

const MONGO_URI = &apos;mongodb://localhost:27017/mydb&apos;;

class MongoDBHealthCheck extends EventEmitter {
  constructor() {
    super();
    this.mongoClient = new MongoClient(MONGO_URI, { useNewUrlParser: true });
    this.isHealthy = false;
  }

  start() {
    this.mongoClient.connect((err) =&gt; {
      if (err) {
        console.error(&apos;Failed to connect to MongoDB:&apos;, err);
        this.isHealthy = false;
        this.emit(&apos;healthCheckFailed&apos;);
      } else {
        console.log(&apos;Connected to MongoDB.&apos;);
        this.isHealthy = true;
        this.emit(&apos;healthCheckSucceeded&apos;);
      }
    });
  }

  stop() {
    this.mongoClient.close();
  }

  getStatus() {
    return this.isHealthy;
  }
}

const mongoDBHealthCheck = new MongoDBHealthCheck();

// Event listener
mongoDBHealthCheck.on(&apos;healthCheckSucceeded&apos;, () =&gt; {
  console.log(&apos;MongoDB connection is healthy.&apos;);
});

mongoDBHealthCheck.on(&apos;healthCheckFailed&apos;, () =&gt; {
  console.error(&apos;MongoDB connection is unhealthy.&apos;);
});

// Start the health check
mongoDBHealthCheck.start();

</code></pre>
<!--kg-card-end: markdown--><p>In this example, we&apos;re creating a <code>MongoDBHealthCheck</code> class that extends the <code>EventEmitter</code> class. The <code>MongoDBHealthCheck</code> class encapsulates the logic for checking the health of the MongoDB connection.</p><p>The <code>start()</code> method connects to the MongoDB server and emits either the <code>healthCheckSucceeded</code> or <code>healthCheckFailed</code> event depending on whether the connection was successful.</p><p>The <code>getStatus()</code> method returns the current status of the connection (either <code>true</code> for healthy or <code>false</code> for unhealthy).</p><p>We&apos;re also setting up event listeners to handle the <code>healthCheckSucceeded</code> and <code>healthCheckFailed</code> events. When the <code>healthCheckSucceeded</code> event is emitted, we log a message saying that the MongoDB connection is healthy. When the <code>healthCheckFailed</code> event is emitted, we log an error message saying that the MongoDB connection is unhealthy.</p><p>Finally, we create an instance of the <code>MongoDBHealthCheck</code> class and start the health check by calling the <code>start()</code> method.</p>]]></content:encoded></item><item><title><![CDATA[Validate User IP and User Session in ExpressJS]]></title><description><![CDATA[<p>Here&apos;s an example of an express middleware that retrieves the IP address and user agent from a Mongoose collection called &quot;Session&quot; and compares it with the incoming request&apos;s user IP and user agent:</p><!--kg-card-begin: markdown--><pre><code class="language-javascript">const mongoose = require(&apos;mongoose&apos;);
const Session = mongoose.model(&apos;</code></pre>]]></description><link>https://webtips.fly.dev/validate-user-ip-and-user-session-in-express-js/</link><guid isPermaLink="false">640d8eea81e9570211d5f03f</guid><dc:creator><![CDATA[Pedi]]></dc:creator><pubDate>Sun, 12 Mar 2023 08:36:39 GMT</pubDate><content:encoded><![CDATA[<p>Here&apos;s an example of an express middleware that retrieves the IP address and user agent from a Mongoose collection called &quot;Session&quot; and compares it with the incoming request&apos;s user IP and user agent:</p><!--kg-card-begin: markdown--><pre><code class="language-javascript">const mongoose = require(&apos;mongoose&apos;);
const Session = mongoose.model(&apos;Session&apos;);

const verifySession = async (req, res, next) =&gt; {
  try {
    const session = await Session.findOne({ _id: req.sessionID });
    if (!session) {
      return res.status(401).send(&apos;Session not found&apos;);
    }
    const ipAddress = req.headers[&apos;x-forwarded-for&apos;] || req.socket.remoteAddress;
    const userAgent = req.headers[&apos;user-agent&apos;];
    if (session.ipAddress !== ipAddress || session.userAgent !== userAgent) {
      return res.status(401).send(&apos;Unauthorized access&apos;);
    }
    next();
  } catch (err) {
    console.error(err);
    res.status(500).send(&apos;Server Error&apos;);
  }
};

module.exports = verifySession;

</code></pre>
<!--kg-card-end: markdown--><p>Explanation:</p><ol><li>First, we import the Mongoose model for &quot;Session&quot;.</li><li>Then we define a middleware function called &quot;verifySession&quot; that takes in the &quot;req&quot;, &quot;res&quot;, and &quot;next&quot; parameters.</li><li>Inside the &quot;verifySession&quot; function, we use the &quot;findOne&quot; method of the &quot;Session&quot; model to find the session corresponding to the &quot;req.sessionID&quot; value.</li><li>If the session is not found, we return a 401 Unauthorized status code with the message &quot;Session not found&quot;.</li><li>We then retrieve the IP address and user agent from the request headers using the &quot;x-forwarded-for&quot; and &quot;user-agent&quot; properties, respectively.</li><li>Next, we compare the retrieved IP address and user agent with the corresponding values in the session document.</li><li>If they don&apos;t match, we return a 401 Unauthorized status code with the message &quot;Unauthorized access&quot;.</li><li>If everything checks out, we call the &quot;next&quot; function to pass control to the next middleware in the chain.</li><li>If there&apos;s an error while retrieving the session, we catch it and return a 500 Internal Server Error status code with the message &quot;Server Error&quot;.</li><li>Finally, we export the middleware function for use in our application.</li></ol>]]></content:encoded></item><item><title><![CDATA[How to use XPath to select items in Javascript]]></title><description><![CDATA[<p>XPath (XML Path Language) is a query language used to navigate and select elements in an XML or HTML document. In JavaScript, you can use the <code>document.evaluate()</code> method to execute an XPath query and select elements in an HTML document.</p><p>Here&apos;s an example of how to use</p>]]></description><link>https://webtips.fly.dev/how-to-use-xpath-to-select-items-in-javascript/</link><guid isPermaLink="false">640d8e1481e9570211d5f029</guid><dc:creator><![CDATA[Pedi]]></dc:creator><pubDate>Sun, 12 Mar 2023 08:34:01 GMT</pubDate><content:encoded><![CDATA[<p>XPath (XML Path Language) is a query language used to navigate and select elements in an XML or HTML document. In JavaScript, you can use the <code>document.evaluate()</code> method to execute an XPath query and select elements in an HTML document.</p><p>Here&apos;s an example of how to use XPath to select an element by its ID in JavaScript:</p><!--kg-card-begin: markdown--><pre><code class="language-javascript">// Get the element with ID &quot;myElement&quot;
var element = document.evaluate(&apos;//*[@id=&quot;myElement&quot;]&apos;, document, null, 
                                XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;

// Check if the element was found and do something with it
if (element !== null) {
    // Do something with the element
}
</code></pre>
<!--kg-card-end: markdown--><p>In the example above, we use the <code>document.evaluate()</code> method to execute an XPath query that selects the element with ID &quot;myElement&quot;. The <code>XPathResult.FIRST_ORDERED_NODE_TYPE</code> parameter tells the method to return the first matching element, and the <code>singleNodeValue</code> property retrieves the value of the selected node.</p><p>You can also use other XPath expressions to select elements based on other attributes or conditions. Here are a few examples:</p><!--kg-card-begin: markdown--><pre><code class="language-javascript">// Select all elements with class &quot;myClass&quot;
var elements = document.evaluate(&apos;//*[@class=&quot;myClass&quot;]&apos;, document, null, 
                                 XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);

// Select all links that contain the text &quot;Click here&quot;
var links = document.evaluate(&apos;//a[contains(text(), &quot;Click here&quot;)]&apos;, document, null, 
                              XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);

// Select all input fields of type &quot;text&quot;
var inputs = document.evaluate(&apos;//input[@type=&quot;text&quot;]&apos;, document, null, 
                               XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
</code></pre>
<!--kg-card-end: markdown--><p>In each of these examples, we use a different XPath expression to select elements based on different criteria. The <code>XPathResult.ORDERED_NODE_SNAPSHOT_TYPE</code> parameter tells the <code>document.evaluate()</code> method to return a snapshot of all matching nodes, and we can then loop through the <code>snapshotLength</code> property to access each individual node.</p>]]></content:encoded></item><item><title><![CDATA[How to delete large file Linux]]></title><description><![CDATA[<p>To delete a large file in Ubuntu, you can use the <code>rm</code> (remove) command in the terminal. Here&apos;s how to do it:</p><ol><li>Open a terminal window.</li><li>Navigate to the directory containing the file you want to delete using the <code>cd</code> command. For example, if the file is located</li></ol>]]></description><link>https://webtips.fly.dev/how-to-delete-large-file-linux/</link><guid isPermaLink="false">640d8de881e9570211d5f01c</guid><dc:creator><![CDATA[Pedi]]></dc:creator><pubDate>Sun, 12 Mar 2023 08:32:00 GMT</pubDate><content:encoded><![CDATA[<p>To delete a large file in Ubuntu, you can use the <code>rm</code> (remove) command in the terminal. Here&apos;s how to do it:</p><ol><li>Open a terminal window.</li><li>Navigate to the directory containing the file you want to delete using the <code>cd</code> command. For example, if the file is located in the &quot;Downloads&quot; folder, you can type <code>cd ~/Downloads</code>.</li><li>Once you&apos;re in the directory, type the following command and press Enter:</li></ol><p><code>sudo rm filename</code></p><p>Replace &quot;filename&quot; with the actual name of the file you want to delete. The <code>sudo</code> command is used to give you superuser privileges, which are necessary to delete certain files. 4. If the file is very large and the command seems to be taking a long time, you can add the <code>-v</code> (verbose) option to the command to see the progress of the deletion. For example:</p><p><code>sudo rm -v filename</code></p><p>Note: Be very careful when using the <code>rm</code> command, as it permanently deletes files and there is no way to recover them once they are gone. Make sure you are deleting the correct file and that you have a backup copy if necessary.</p>]]></content:encoded></item><item><title><![CDATA[Check how much free space is available in Linux]]></title><description><![CDATA[<p>To see how much free space is available in Linux, you can use the <code>df</code> (disk free) command.</p><p>Here&apos;s how:</p><ol><li>Open a terminal window.</li><li>Type the following command and press Enter:</li></ol><p><code>df -h</code></p><p>The <code>-h</code> option will display the sizes in a human-readable format (e.g. &quot;1.</p>]]></description><link>https://webtips.fly.dev/check-how-much-free-space-is-available-in-linux/</link><guid isPermaLink="false">640d8db181e9570211d5f00f</guid><dc:creator><![CDATA[Pedi]]></dc:creator><pubDate>Sun, 12 Mar 2023 08:31:10 GMT</pubDate><content:encoded><![CDATA[<p>To see how much free space is available in Linux, you can use the <code>df</code> (disk free) command.</p><p>Here&apos;s how:</p><ol><li>Open a terminal window.</li><li>Type the following command and press Enter:</li></ol><p><code>df -h</code></p><p>The <code>-h</code> option will display the sizes in a human-readable format (e.g. &quot;1.2G&quot; instead of &quot;1234567&quot;).</p><p>You should see a list of all mounted filesystems along with their disk usage information. The &quot;Available&quot; column will show you how much free space is available on each filesystem.</p><p>Note: If you want to check the free space of a specific directory or partition, you can use the <code>du</code> (disk usage) command instead. For example:</p><p><code>du -sh /path/to/directory</code></p><p>This will show you the size of the specified directory in a human-readable format.</p>]]></content:encoded></item><item><title><![CDATA[Coming soon]]></title><description><![CDATA[<p>This is Software Engineer Tips And Tricks, a brand new site by Pedi that&apos;s just getting started. Things will be up and running here shortly, but you can <a href="#/portal/">subscribe</a> in the meantime if you&apos;d like to stay up to date and receive emails when new content</p>]]></description><link>https://webtips.fly.dev/coming-soon/</link><guid isPermaLink="false">640d6de881e9570211d5ee68</guid><category><![CDATA[News]]></category><dc:creator><![CDATA[Pedi]]></dc:creator><pubDate>Sun, 12 Mar 2023 06:15:04 GMT</pubDate><media:content url="https://static.ghost.org/v4.0.0/images/feature-image.jpg" medium="image"/><content:encoded><![CDATA[<img src="https://static.ghost.org/v4.0.0/images/feature-image.jpg" alt="Coming soon"><p>This is Software Engineer Tips And Tricks, a brand new site by Pedi that&apos;s just getting started. Things will be up and running here shortly, but you can <a href="#/portal/">subscribe</a> in the meantime if you&apos;d like to stay up to date and receive emails when new content is published!</p>]]></content:encoded></item></channel></rss>