Abhai Sasidharan - Pass on what you have learned https://abh.ai/ en What's a zombie process in Linux? https://abh.ai/shorts/whats-zombie-process-linux <span>What&#039;s a zombie process in Linux?</span> <span><span>abhai</span></span> <span><time datetime="2023-10-23T19:26:40+00:00" title="Monday, October 23, 2023 - 19:26">Mon, 10/23/2023 - 19:26</time> </span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field-item"><p>In Linux, a zombie process is a state that a child process enters when it has finished executing, but its exit status has not yet been collected by its parent process. Zombie processes are essentially dead processes that are waiting for their parent process to retrieve their exit status.</p> <p>When a process terminates in Linux, it doesn't immediately disappear from the process table. Instead, it becomes a zombie process until the parent process acknowledges the child's termination and retrieves its exit status. Once the parent process collects the exit status, the zombie process is removed from the process table, and its resources are released.</p> <p>Zombie processes are typically harmless and consume very little system resources. However, if a parent process fails to collect the exit status of its child processes, a large number of zombie processes can accumulate and potentially lead to issues. To prevent this, it's important for the parent process to regularly call the wait() system call or one of its variants (e.g., waitpid()) to collect the exit status of its child processes and clean up zombie processes. To test this, in c you can create a child process using fork() and run it for 60 seconds. After running the c program, if you look at your system monitor (or top, htop commands) you'll see your zombie there. It's supposed to be dead, but it isn't, hence zombie. </p> <p>In most cases, well-written programs and system utilities properly handle child processes, preventing zombie processes from becoming a problem.</p></div> <div class="node-taxonomy-container"> <h3 class="term-title"><i class="icon-hashtag theme-color"></i> Tags</h3> <ul class="taxonomy-terms"> <li class="taxonomy-term"><a href="/tags/linux" hreflang="en">Linux</a></li> </ul> </div> <!--/.node-taxonomy-container --> <div class="field field--name-field-comment field--type-disqus-comment field--label-hidden field-item"><drupal-render-placeholder callback="Drupal\disqus\Element\Disqus::displayDisqusComments" arguments="0=What%27s%20a%20zombie%20process%20in%20Linux%3F&amp;1=https%3A//abh.ai/shorts/whats-zombie-process-linux&amp;2=node/100&amp;3=a%3A0%3A%7B%7D" token="7AQzpJd5rxNbbTAAtWt9IIZmxaa684c8Hf0Kx--tCn4"></drupal-render-placeholder></div> Mon, 23 Oct 2023 19:26:40 +0000 abhai 100 at https://abh.ai Funny Drupal modules that help us deal with the insane learning curve! https://abh.ai/blog/funny-drupal-modules-help-us-deal-insane-learning-curve <span>Funny Drupal modules that help us deal with the insane learning curve!</span> <span><span>abhai</span></span> <span><time datetime="2023-10-23T16:16:33+00:00" title="Monday, October 23, 2023 - 16:16">Mon, 10/23/2023 - 16:16</time> </span> Mon, 23 Oct 2023 16:16:33 +0000 abhai 99 at https://abh.ai What is patch level in git and composer? https://abh.ai/shorts/what-patch-level-git-and-composer <span>What is patch level in git and composer?</span> <span><span>abhai</span></span> <span><time datetime="2023-10-20T19:25:11+00:00" title="Friday, October 20, 2023 - 19:25">Fri, 10/20/2023 - 19:25</time> </span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field-item"><p>You might have seen the command "patch -p2" or an entry in composer.json when using <a href="https://github.com/cweagans/composer-patches">cweagans/composer-patches</a> like the following.</p> <pre> <code>"patchLevel": { "drupal/core": "-p2" }</code></pre> <p>In the command "patch -p2," the "-p2" flag specifies the patch level.</p> <p>The "patch" command is used to apply changes, or patches, to source code files. The "-p" flag followed by a number tells the patch command how many directory levels to strip from the file paths mentioned in the patch file.</p> <p>Here's what it means in more detail:</p> <ul><li> <p>"-p0" (or simply "patch" with no "-p" flag) means that the patch file contains file paths starting from the root directory. In other words, the patch file specifies the full path to the files to be patched.</p> </li> <li> <p>"-p1" means that the patch file contains file paths starting from one level above the root directory. This is often used when the patch file was created using the "diff" command with the "-u" or "-p" option.</p> </li> <li> <p>"-p2" means that the patch file contains file paths starting from two levels above the root directory. This is commonly used when the patch file was generated in a directory that is two levels above the directory where the patch should be applied.</p> </li> </ul><p>The choice of the patch level depends on how the patch file was generated and the directory structure of the project you are applying the patch to. Using the correct patch level is important to ensure that the patch is applied to the correct files with the correct paths.</p> <p>So in the above example, the core folder is usually two folders inside the project root (&lt;project_root&gt;/docroot/core) which is why core patch level is mentioned as -p2.</p> <p> </p> <p> </p></div> <div class="node-taxonomy-container"> <h3 class="term-title"><i class="icon-hashtag theme-color"></i> Tags</h3> <ul class="taxonomy-terms"> <li class="taxonomy-term"><a href="/tags/composer" hreflang="en">Composer</a></li> <li class="taxonomy-term"><a href="/tags/drupal" hreflang="en">Drupal</a></li> </ul> </div> <!--/.node-taxonomy-container --> <div class="field field--name-field-comment field--type-disqus-comment field--label-hidden field-item"><drupal-render-placeholder callback="Drupal\disqus\Element\Disqus::displayDisqusComments" arguments="0=What%20is%20patch%20level%20in%20git%20and%20composer%3F&amp;1=https%3A//abh.ai/shorts/what-patch-level-git-and-composer&amp;2=node/98&amp;3=a%3A0%3A%7B%7D" token="iR63h1x5sxWwcn65pJWvyUuryRFSVRCkxSYCy6ad15Q"></drupal-render-placeholder></div> Fri, 20 Oct 2023 19:25:11 +0000 abhai 98 at https://abh.ai Distro-Hopping: A fun way to find the perfect Linux desktop https://abh.ai/blog/distro-hopping-fun-way-find-perfect-linux-desktop <span>Distro-Hopping: A fun way to find the perfect Linux desktop</span> <span><span>abhai</span></span> <span><time datetime="2023-10-19T16:32:22+00:00" title="Thursday, October 19, 2023 - 16:32">Thu, 10/19/2023 - 16:32</time> </span> Thu, 19 Oct 2023 16:32:22 +0000 abhai 97 at https://abh.ai Setting up Drupal on ddev for drupal core contributions https://abh.ai/blog/setting-drupal-ddev-drupal-core-contributions <span>Setting up Drupal on ddev for drupal core contributions</span> <span><span>abhai</span></span> <span><time datetime="2023-09-28T09:12:45+00:00" title="Thursday, September 28, 2023 - 09:12">Thu, 09/28/2023 - 09:12</time> </span> Thu, 28 Sep 2023 09:12:45 +0000 abhai 93 at https://abh.ai How to correctly set Content-Security-Policy headers? https://abh.ai/shorts/how-correctly-set-content-security-policy-headers <span>How to correctly set Content-Security-Policy headers?</span> <span><span>abhai</span></span> <span><time datetime="2023-06-19T03:55:05+00:00" title="Monday, June 19, 2023 - 03:55">Mon, 06/19/2023 - 03:55</time> </span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field-item"><p>Setting the Content-Security-Policy (CSP) header correctly is an essential step in enhancing the security of your web application. The CSP header allows you to define a policy that restricts the types of content that can be loaded by a web page, thereby mitigating risks such as cross-site scripting (XSS) and data injection attacks. Here's a general guide on how to correctly set CSP headers:</p> <ol><li>Understand your application's requirements: Before setting the CSP header, it's important to understand how your application functions and <strong>the resources it needs to load</strong>. This will help you create an effective policy without breaking the functionality of your web pages. If you need to allow a script from <a href="https://abh.ai">abh.ai</a>, make sure that domain is one you trust, then add it into one of the directives mentioned below. An example of your default-src header value would look like this when using seckit module. <pre> <code>default-src: '''self'' ''unsafe-inline'' ''unsafe-eval'' *.sharethis.com:* *.cloudflare.com:* *.google-analytics.com:* *.googletagmanager.com:* *.gstatic.com:* *.googleapis.com:* *.fontawesome.com:* *.addtoany.com:* *.disqus.com:* *.facebook.com:* *.facebook.net:* *.google.com:* *.linkedin.com:* *.twitter.com:* *.abh.ai:* *.youtube.com:* *.vimeo.com:* *.instagram.com *.newrelic.com:* *.nr-data.net:* *.jquery.js:* *.chosen.css:* unpkg.com:* *.openstreetmap.org:* cdn.jsdelivr.net:* data:' </code></pre> </li> <li>Define a policy: Start by deciding what types of content are allowed to be loaded on your web pages. The CSP header consists of various directives that you can use to define your policy. Some commonly used directives include:<br />    - `<strong>default-src</strong>`: Specifies the default sources for content such as scripts, stylesheets, images, fonts, etc.<br />    - `<strong>script-src</strong>`: Determines the sources from which JavaScript can be executed.<br />    - `<strong>style-src</strong>`: Specifies the sources from which stylesheets can be loaded.<br />    - `<strong>img-src</strong>`: Determines the sources from which images can be loaded.<br />    - `<strong>font-src</strong>`: Specifies the sources from which fonts can be loaded.<br />    - `<strong>connect-src</strong>`: Determines the sources to which the web page can make network requests (AJAX, WebSocket, etc.).<br />    - `<strong>frame-src</strong>`: Specifies the sources from which frames or iframes can be loaded.<br />    - `<strong>media-src</strong>`: Determines the sources from which audio or video content can be loaded.<br /> These directives can be further modified with additional options, such as `'self'` (the same origin), `'unsafe-inline'` (allowing inline scripts/styles), `'unsafe-eval'` (allowing eval), or specific domains or sources.</li> <li>Testing and refining: Once you have defined your initial policy, test your web application thoroughly to ensure all required resources are allowed and no unintended content is being loaded. Modern browsers provide console warnings or errors that can help identify any violations.</li> <li>Implementing the CSP header: There are multiple ways to implement the CSP header, depending on your server environment. Here are a few common approaches: <p>- Server-side configuration: If you have control over your server configuration, you can set the CSP header directly. The method may vary depending on your web server (e.g., Apache, Nginx, IIS). Consult the documentation for your specific server software to learn how to configure headers.</p> <p>   - Middleware or framework: Many web frameworks and middleware provide functionality to set HTTP headers, including the CSP header. Consult the documentation for your framework to learn how to set headers programmatically.</p> <p>   - Content Security Policy HTTP header: You can set the CSP header directly in your web application's code. For example, in PHP, you can use the `header()` function to set the header.</p> </li> <li> <p>Monitor and update: Regularly monitor your web application's functionality and logs to ensure the CSP policy is not causing any issues. As your application evolves, you may need to update the policy to accommodate new features or content sources. You can also checkout browser console for any CSP related errors. Usually the browser like Firefox or Chrome will give recommendations on how to fix it as well.</p> </li> </ol><p>Remember that CSP is a powerful security feature, but it should not be the sole defense mechanism. It is crucial to implement other security practices, such as input validation and output encoding, to provide comprehensive protection against web vulnerabilities.</p> <p>It's worth noting that the CSP specification has evolved over time, so it's essential to refer to the latest documentation and browser support information when implementing CSP headers.</p> </div> <div class="node-taxonomy-container"> <h3 class="term-title"><i class="icon-hashtag theme-color"></i> Tags</h3> <ul class="taxonomy-terms"> <li class="taxonomy-term"><a href="/tags/security" hreflang="en">Security</a></li> </ul> </div> <!--/.node-taxonomy-container --> <div class="field field--name-field-comment field--type-disqus-comment field--label-hidden field-item"><drupal-render-placeholder callback="Drupal\disqus\Element\Disqus::displayDisqusComments" arguments="0=How%20to%20correctly%20set%20Content-Security-Policy%20headers%3F&amp;1=https%3A//abh.ai/shorts/how-correctly-set-content-security-policy-headers&amp;2=node/89&amp;3=a%3A0%3A%7B%7D" token="p2o7hbhLL4fNPqcEOuEiFU7jq9bL5evzinuDDsDSMiQ"></drupal-render-placeholder></div> Mon, 19 Jun 2023 03:55:05 +0000 abhai 89 at https://abh.ai What does the final keyword do in PHP? https://abh.ai/shorts/what-does-final-keyword-do-php <span>What does the final keyword do in PHP?</span> <span><span>abhai</span></span> <span><time datetime="2023-06-03T18:30:34+00:00" title="Saturday, June 3, 2023 - 18:30">Sat, 06/03/2023 - 18:30</time> </span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field-item"><p>In PHP, the `final` keyword is used to restrict the inheritance and overriding of methods and classes. Here's what it does in different contexts:</p> <ol><li>Final methods: When you declare a method as `final` within a class, it means that the method cannot be overridden by any subclass that extends that class. It effectively prevents the subclass from redefining the method implementation. <pre> <code class="language-php">&lt;?php class ParentClass {     final public function someMethod() {         // Method implementation     } } class ChildClass extends ParentClass {     // This will cause an error since overriding final method is not allowed     public function someMethod() {         // New method implementation     } }</code></pre> In the above example, the `someMethod()` in the `ParentClass` is declared as `final`, which means that the `ChildClass` cannot override it. If the `ChildClass` tries to override the `someMethod()` method, it will result in an error.</li> <li>Final classes: When you declare a class as `final`, it means that the class cannot be extended by any other class. In other words, it prevents inheritance from that class. <pre> <code class="language-php">&lt;?php final class FinalClass {     // Class implementation } class ChildClass extends FinalClass {     // This will cause an error since extending a final class is not allowed }</code></pre> In the above example, the `FinalClass` is declared as `final`, which means that no other class can extend it. If a class tries to extend the `FinalClass`, it will result in an error. The `final` keyword is useful when you want to ensure that a method or a class should not be modified or extended, providing a level of control over the inheritance and method overriding in your PHP code.</li> </ol><p>The final keyword is also relevant in other OO programming languages like Java, C# and C++. </p> </div> <div class="node-taxonomy-container"> <h3 class="term-title"><i class="icon-hashtag theme-color"></i> Tags</h3> <ul class="taxonomy-terms"> <li class="taxonomy-term"><a href="/tags/php" hreflang="en">PHP</a></li> </ul> </div> <!--/.node-taxonomy-container --> <div class="field field--name-field-comment field--type-disqus-comment field--label-hidden field-item"><drupal-render-placeholder callback="Drupal\disqus\Element\Disqus::displayDisqusComments" arguments="0=What%20does%20the%20final%20keyword%20do%20in%20PHP%3F&amp;1=https%3A//abh.ai/shorts/what-does-final-keyword-do-php&amp;2=node/86&amp;3=a%3A0%3A%7B%7D" token="S4ttTtJSm0Acu3hhPVEyQEesPdkP0EqUmCjb6i-XWHE"></drupal-render-placeholder></div> Sat, 03 Jun 2023 18:30:34 +0000 abhai 86 at https://abh.ai What are the types of inheritance in PHP? https://abh.ai/blog/types-of-inheritance-in-php <span>What are the types of inheritance in PHP?</span> <span><span>abhai</span></span> <span><time datetime="2023-06-03T18:23:06+00:00" title="Saturday, June 3, 2023 - 18:23">Sat, 06/03/2023 - 18:23</time> </span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field-item"><p>In PHP, there are three types of inheritance:</p> <ol><li>Single inheritance: Single inheritance refers to the concept of a class inheriting properties and methods from a single parent class. In PHP, a class can extend only one parent class using the `extends` keyword. The derived class, also known as the child class, inherits all the public and protected properties and methods of the parent class. <pre> <code class="language-php">&lt;?php class ParentClass {     // properties and methods } class ChildClass extends ParentClass {     // properties and methods }</code></pre> </li> <li>Multiple inheritance (achieved through interfaces): Multiple inheritance refers to the concept of a class inheriting properties and methods from multiple parent classes. However, PHP does not support multiple inheritance directly between classes. Instead, PHP supports multiple inheritance through interfaces. An interface defines a contract that a class must adhere to by implementing its methods. <pre> <code class="language-php">&lt;?php interface Interface1 {     // methods } interface Interface2 {     // methods } class ChildClass implements Interface1, Interface2 {     // properties and methods }</code></pre> <p>By implementing multiple interfaces, a class can inherit and implement the methods defined in those interfaces. This allows for achieving a form of multiple inheritance in PHP.<br /> It's important to note that PHP supports only single class inheritance but allows implementing multiple interfaces, providing a way to achieve similar functionality to multiple inheritance.</p> </li> <li>Multi-level inheritance: Multi-level inheritance refers to the concept of a class inheriting properties and methods from a parent class, which itself has inherited from another parent class. In this type of inheritance, a class extends a class that has already extended another class. <pre> <code class="language-php">&lt;?php class GrandParentClass { // properties and methods } class ParentClass extends GrandParentClass { // properties and methods } class ChildClass extends ParentClass { // properties and methods } </code></pre> <p>In the above example, the ChildClass inherits properties and methods from both the ParentClass and the GrandParentClass. It forms a chain where the ChildClass indirectly inherits the properties and methods from the GrandParentClass through the ParentClass.</p> <p>Multi-level inheritance allows classes to inherit and extend the functionality of multiple classes in a hierarchical manner. The child class can access the properties and methods of both its immediate parent class and its ancestor classes.</p> <p>In PHP, a class can directly extend only one parent class. However, through multi-level inheritance, a class can indirectly inherit from multiple classes similar to multiple inheritance through interfaces.</p> </li> </ol></div> <div class="node-taxonomy-container"> <h3 class="term-title"><i class="icon-hashtag theme-color"></i> Tags</h3> <ul class="taxonomy-terms"> <li class="taxonomy-term"><a href="/tags/php" hreflang="en">PHP</a></li> </ul> </div> <!--/.node-taxonomy-container --> <div class="field field--name-field-comment field--type-disqus-comment field--label-hidden field-item"><drupal-render-placeholder callback="Drupal\disqus\Element\Disqus::displayDisqusComments" arguments="0=What%20are%20the%20types%20of%20inheritance%20in%20PHP%3F&amp;1=https%3A//abh.ai/blog/types-of-inheritance-in-php&amp;2=node/85&amp;3=a%3A0%3A%7B%7D" token="_KiVeL-HkLz52G6WO5mFSH1isqXfcPF-fR11fNGfi_8"></drupal-render-placeholder></div> Sat, 03 Jun 2023 18:23:06 +0000 abhai 85 at https://abh.ai Why is Drupal perfect for non-profits and NGOs? https://abh.ai/blog/drupal-for-non-profits-and-ngos <span>Why is Drupal perfect for non-profits and NGOs?</span> <span><span>abhai</span></span> <span><time datetime="2023-05-31T17:54:36+00:00" title="Wednesday, May 31, 2023 - 17:54">Wed, 05/31/2023 - 17:54</time> </span> Wed, 31 May 2023 17:54:36 +0000 abhai 84 at https://abh.ai How proper SEO and the Drupal CMS helped my article be a Google featured snippet https://abh.ai/blog/how-proper-seo-and-drupal-cms-helped-my-article-be-google-featured-snippet <span>How proper SEO and the Drupal CMS helped my article be a Google featured snippet</span> <span><span>abhai</span></span> <span><time datetime="2023-05-30T06:47:26+00:00" title="Tuesday, May 30, 2023 - 06:47">Tue, 05/30/2023 - 06:47</time> </span> Tue, 30 May 2023 06:47:26 +0000 abhai 83 at https://abh.ai