<?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:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Lahiru Prabodha on Medium]]></title>
        <description><![CDATA[Stories by Lahiru Prabodha on Medium]]></description>
        <link>https://medium.com/@lahiruprabodha?source=rss-cd7af1d9b09d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*AdKilhsuNsmTrWhDpe7y2Q.jpeg</url>
            <title>Stories by Lahiru Prabodha on Medium</title>
            <link>https://medium.com/@lahiruprabodha?source=rss-cd7af1d9b09d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 23:54:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@lahiruprabodha/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[ Understanding settle_interval in Payment Gateways: Why You Get Paid After 120 Hours]]></title>
            <link>https://lahiruprabodha.medium.com/understanding-settle-interval-in-payment-gateways-why-you-get-paid-after-120-hours-b9208e1ef071?source=rss-cd7af1d9b09d------2</link>
            <guid isPermaLink="false">https://medium.com/p/b9208e1ef071</guid>
            <dc:creator><![CDATA[Lahiru Prabodha]]></dc:creator>
            <pubDate>Thu, 19 Jun 2025 14:35:32 GMT</pubDate>
            <atom:updated>2025-06-19T14:42:09.762Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FJLarWqoNRi4XNgNS7wj1A.png" /><figcaption>Understanding settle_interval in Payment Gateways</figcaption></figure><p>When running an online business, it’s natural to assume that once a customer pays, the money is yours. But in the world of digital payments, that’s not always the case.</p><p>If you’ve come across the term settle_interval, especially when working with payment gateways like Solidgate, Stripe, or PayPal, you might be wondering:</p><blockquote><strong><em>Why do I have to wait 5 days to receive the money if the customer paid instantly?</em></strong></blockquote><p>Let’s break it down.</p><h4>⚡ What Happens When a Customer Pays?</h4><p>When a customer enters their card details and confirms a payment:</p><ul><li>The <strong>card is charged immediately</strong></li><li>The <strong>customer sees the payment on their statement right away</strong></li><li>You (the merchant) receive a <strong>payment confirmation instantly</strong></li></ul><p>However…</p><p>The money is not transferred to your bank account right away.</p><h4>⏳ What Is settle_interval?</h4><p>The settle_interval is the <strong>amount of time the payment gateway holds the funds</strong> before transferring them to the merchant’s available balance or bank account.</p><blockquote><em>For example, a </em><em>settle_interval = 120 means the funds will be released </em><strong><em>120 hours (5 days)</em></strong><em> after the successful payment.</em></blockquote><h4>✅ So Is This Statement Correct?</h4><blockquote><em>“The customer is charged immediately, and their card is billed right away. However, the funds will be transferred to the merchant’s bank account after 120 hours.”</em></blockquote><p><strong>Yes, it’s absolutely correct.</strong></p><p>This is how many payment processors reduce financial risk for themselves and for you.</p><h4>🔒 Why Delay the Settlement?</h4><p>Here’s why this delay exists — and why it can actually protect your business:</p><h4>1. Fraud Protection</h4><p>A longer window gives the system time to detect and respond to fraud before sending money to your account.</p><h4>2. Refund Handling</h4><p>If a customer quickly requests a refund, the gateway can return funds without needing to reverse a payout.</p><h4>3. Chargeback Buffer</h4><p>Chargebacks can be expensive. If the funds are still “on hold,” handling disputes is easier and safer for the merchant and processor.</p><h4>4. Regulatory Compliance</h4><p>In some regions or high-risk industries, a settlement delay is required by law to protect both customers and merchants.</p><h4>5. Cash Flow Management</h4><p>Some businesses prefer weekly or bi-weekly settlements to match accounting cycles. A settle_interval helps enforce that schedule.</p><h4>📦 Example Scenario: 120-Hour Settlement</h4><p>Let’s say you sell digital products.</p><ol><li>🛒 A customer buys your product on <strong>June 1 at 10:00 AM</strong></li><li>💳 Their card is <strong>charged immediately</strong></li><li>⏱ The payment gateway holds the money for <strong>120 hours</strong></li><li>💰 On <strong>June 6 at 10:00 AM</strong>, the funds are released to you</li></ol><p>You still see the successful payment right away — but the funds <strong>become available 5 days later</strong>.</p><h4>🔄 How It Works Behind the Scenes (Technical View)</h4><pre>{<br>  &quot;transaction_id&quot;: &quot;tx_1001&quot;,<br>  &quot;amount&quot;: 5000,<br>  &quot;status&quot;: &quot;captured&quot;,<br>  &quot;created_at&quot;: &quot;2025-06-19T10:00:00Z&quot;,<br>  &quot;settle_at&quot;: &quot;2025-06-24T10:00:00Z&quot;,<br>  &quot;settle_interval&quot;: 120,<br>  &quot;settled&quot;: false<br>}</pre><p>Your backend or the gateway’s system uses this data to <strong>trigger the payout after the interval</strong>.</p><h4>🏦 When Do You Actually Get Paid?</h4><p>That depends on your gateway and payout settings. Some examples:</p><p>GatewayHow settle_interval is handled<strong>Stripe</strong>Payout delay is set in the account — daily or weekly<strong>Solidgate</strong>Can configure settle_interval during onboarding<strong>PayPal</strong>May hold funds for 7–21 days for new accounts or risk checks</p><h4>🧾 Summary</h4><ul><li>✅ Customer is charged <strong>instantly</strong></li><li>⏳ Funds are held for settle_interval (e.g. 120 hours)</li><li>🏦 Merchant receives funds <strong>after the interval</strong></li></ul><blockquote><em>The </em><em>settle_interval is a powerful tool that protects your business from fraud, helps handle disputes, and keeps your payment flow safe and stable.</em></blockquote><h4>🧠 Final Thoughts</h4><p>Understanding how settlement works gives you more control over your <strong>cash flow</strong>, <strong>refund policy</strong>, and <strong>customer experience</strong>.</p><p>If you’re setting up a payment system for your platform, it’s important to know:</p><ul><li>How your provider handles settle_interval</li><li>Whether you can configure it</li><li>How to handle unsettled funds in your reports and UI</li></ul><p>A delay in settlement doesn’t mean a delay in business. It means your system is working smart to protect you from risk.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b9208e1ef071" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Ultimate Guide to Using Schema.org for SEO & Rich Results]]></title>
            <link>https://lahiruprabodha.medium.com/the-ultimate-guide-to-using-schema-org-for-seo-rich-results-82887af6667f?source=rss-cd7af1d9b09d------2</link>
            <guid isPermaLink="false">https://medium.com/p/82887af6667f</guid>
            <dc:creator><![CDATA[Lahiru Prabodha]]></dc:creator>
            <pubDate>Mon, 10 Feb 2025 16:43:54 GMT</pubDate>
            <atom:updated>2025-02-10T16:43:54.240Z</atom:updated>
            <content:encoded><![CDATA[<p>Imagine you’re running a website and want to make your content stand out in search engines. You’ve heard of <strong>Schema.org</strong>, but you’re not sure how to use it. Don’t worry! This guide will take you from <strong>beginner to pro</strong> in structured data implementation.</p><h3>What is Schema.org?</h3><p>Schema.org is a collaborative project by <strong>Google, Bing, Yahoo, and Yandex</strong> to standardize structured data on the web. It helps search engines <strong>understand your content better</strong> and display rich snippets (stars, prices, images, FAQs) in search results.</p><p>Let’s break it down step by step.</p><h3>Step 1: Choose the Right Schema Type</h3><p>Schema.org offers <strong>hundreds of structured data types</strong>, but here are the most commonly used:</p><ul><li><strong>Article</strong> — For blog posts and news articles</li><li><strong>LocalBusiness</strong> — For businesses with a physical location</li><li><strong>Product</strong> — For eCommerce products with price and availability</li><li><strong>Recipe</strong> — For cooking recipes with ingredients and instructions</li><li><strong>Event</strong> — For concerts, conferences, or meetups</li><li><strong>FAQPage</strong> — For FAQs with collapsible questions</li></ul><p>🔗 <strong>Find the right schema for your website:</strong> Schema.org Full List</p><h3>Step 2: Implement JSON-LD Structured Data</h3><p>There are <strong>three ways</strong> to add Schema.org markup:<br>✅ <strong>JSON-LD (Recommended by Google)</strong><br>✅ Microdata<br>✅ RDFa</p><p>We’ll use <strong>JSON-LD</strong>, the easiest and most flexible method.</p><h3>Example 1: Adding Article Schema to a Blog Post</h3><p>Let’s say you have a blog post. Add this <strong>JSON-LD script</strong> inside the &lt;head&gt; of your page:</p><pre>&lt;script type=&quot;application/ld+json&quot;&gt;<br>{<br>  &quot;@context&quot;: &quot;https://schema.org&quot;,<br>  &quot;@type&quot;: &quot;Article&quot;,<br>  &quot;headline&quot;: &quot;The Ultimate Guide to Using Schema.org&quot;,<br>  &quot;author&quot;: {<br>    &quot;@type&quot;: &quot;Person&quot;,<br>    &quot;name&quot;: &quot;John Doe&quot;<br>  },<br>  &quot;datePublished&quot;: &quot;2025-02-10&quot;,<br>  &quot;publisher&quot;: {<br>    &quot;@type&quot;: &quot;Organization&quot;,<br>    &quot;name&quot;: &quot;My Blog&quot;,<br>    &quot;logo&quot;: {<br>      &quot;@type&quot;: &quot;ImageObject&quot;,<br>      &quot;url&quot;: &quot;https://example.com/logo.png&quot;<br>    }<br>  }<br>}<br>&lt;/script&gt;</pre><h3>Step 3: Validate Your Structured Data</h3><p>Before going live, check if your schema is correct using Google’s <strong>Rich Results Test</strong>.</p><p>🔗 <strong>Test your Schema:</strong> <a href="https://search.google.com/test/rich-results">Rich Results Test</a></p><p>🔗 <strong>Schema Validator:</strong> <a href="https://validator.schema.org/">Schema Markup Validator</a></p><p><strong>If you see green checkmarks ✅, you’re good to go!</strong></p><h3>Step 4: Monitor with Google Search Console</h3><p>Once your structured data is live, track its performance in <strong>Google Search Console</strong>.</p><ol><li>Go to <strong>Search Console</strong> → <strong>Enhancements</strong></li><li>Check if your structured data appears under “Rich Results”</li><li>Fix any warnings or errors</li></ol><p>🔗 <strong>Google Search Console:</strong> <a href="https://search.google.com/">Search Console</a></p><h3>Step 5: Scale Up with Dynamic Schema (For Developers)</h3><p>If you have an <strong>eCommerce store</strong> or a <strong>blog with many posts</strong>, manually adding schema to each page is inefficient. Instead, use <strong>dynamic schema generation</strong> with:</p><p>✅ <strong>PHP / Laravel</strong><br>✅ <strong>JavaScript (Next.js, React, Vue)</strong><br>✅ <strong>WordPress Plugins</strong> (Yoast, RankMath)</p><p>Here’s an <strong>example in Laravel</strong>:</p><pre>&lt;script type=&quot;application/ld+json&quot;&gt;<br>{<br>  &quot;@context&quot;: &quot;https://schema.org&quot;,<br>  &quot;@type&quot;: &quot;Product&quot;,<br>  &quot;name&quot;: &quot;{{ $product-&gt;name }}&quot;,<br>  &quot;image&quot;: &quot;{{ $product-&gt;image }}&quot;,<br>  &quot;description&quot;: &quot;{{ $product-&gt;description }}&quot;,<br>  &quot;brand&quot;: {<br>    &quot;@type&quot;: &quot;Brand&quot;,<br>    &quot;name&quot;: &quot;{{ $product-&gt;brand }}&quot;<br>  },<br>  &quot;offers&quot;: {<br>    &quot;@type&quot;: &quot;Offer&quot;,<br>    &quot;price&quot;: &quot;{{ $product-&gt;price }}&quot;,<br>    &quot;priceCurrency&quot;: &quot;USD&quot;<br>  }<br>}<br>&lt;/script&gt;</pre><h3>Conclusion: Why Schema.org is a Game-Changer</h3><p>By adding structured data to your website, you improve <strong>SEO, click-through rates, and user experience</strong>. It’s <strong>not mandatory</strong>, but it gives you a competitive edge in search rankings.</p><p><strong>🚀 Now it’s your turn!</strong><br>✅ Pick a schema<br>✅ Add JSON-LD to your site<br>✅ Validate with Google<br>✅ Track in Search Console</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=82887af6667f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implementing Brand Indicators for Email Authentication (BIMI): A Step-by-Step Guide]]></title>
            <link>https://lahiruprabodha.medium.com/bimi-brand-indicators-for-message-identification-setup-guide-5fdadff97ca3?source=rss-cd7af1d9b09d------2</link>
            <guid isPermaLink="false">https://medium.com/p/5fdadff97ca3</guid>
            <dc:creator><![CDATA[Lahiru Prabodha]]></dc:creator>
            <pubDate>Mon, 10 Feb 2025 06:11:27 GMT</pubDate>
            <atom:updated>2025-02-10T16:29:17.718Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cX_ILHuKtFLzwF4L3fMmJw.jpeg" /><figcaption>How to Implement Brand Indicators for Email Authentication</figcaption></figure><h3>What is BIMI?</h3><p>BIMI allows brands to display their verified logo in email inboxes alongside their messages, increasing brand recognition and email trust. To implement BIMI, you need:</p><ul><li>A <strong>verified domain with SPF, DKIM, and DMARC configured</strong>.</li><li>A <strong>BIMI-compliant SVG logo</strong>.</li><li>A <strong>BIMI DNS TXT record</strong>.</li><li>A <strong>VMC (Verified Mark Certificate)</strong> (optional, but required by some email providers).</li></ul><h3>Step 1: Ensure SPF, DKIM, and DMARC Are Configured</h3><p>BIMI requires your domain to have SPF, DKIM, and DMARC properly set up.</p><h3>1.1 Configure SPF (Sender Policy Framework)</h3><p>SPF helps prevent email spoofing by specifying which mail servers are allowed to send emails on behalf of your domain.</p><p>Add an SPF record to your <strong>DNS settings</strong>:</p><pre>v=spf1 include:_spf.your-email-provider.com ~all</pre><ul><li>Adjust the SPF record based on your email provider.</li></ul><h3>1.2 Configure DKIM (DomainKeys Identified Mail)</h3><p>DKIM adds a cryptographic signature to your emails, verifying they were sent from an authorized server.</p><ul><li>Generate a DKIM key from your email provider.</li><li>Add the provided DKIM public key as a <strong>TXT record</strong> in your DNS.</li></ul><h3>1.3 Configure DMARC (Domain-based Message Authentication, Reporting, and Conformance)</h3><p>DMARC ensures that SPF and DKIM align to protect your domain.</p><p>Add a DMARC record to your <strong>DNS settings</strong>:</p><pre>v=DMARC1; p=quarantine; rua=dmarc-reports@yourdomain.com; <br>ruf=dmarc-failures@yourdomain.com; pct=100;</pre><ul><li>Modify the policy (p=none, p=quarantine, or p=reject) based on your requirements.</li></ul><h3>Step 2: Create and Host Your BIMI Logo</h3><ul><li>The logo <strong>must be an SVG Tiny 1.2 format</strong>.</li><li>The logo should be <strong>square, have a transparent background, and not contain JavaScript or animations</strong>.</li></ul><p>Use a <strong>BIMI-compliant converter</strong>:</p><ul><li><a href="https://bimigroup.org/bimi-generator/">BIMI Generator</a></li><li><a href="https://easydmarc.com/tools/bimi-logo-converter">EasyDMARC BIMI Logo Converter</a></li></ul><p>Upload the BIMI logo to a publicly accessible <strong>HTTPS URL</strong> (e.g.):</p><pre>https://yourdomain.com/logo.svg</pre><p>Step 3: Create the BIMI DNS Record</p><p>After uploading your logo, create a <strong>TXT record</strong> in your domain’s DNS settings:</p><pre>default._bimi.yourdomain.com TXT <br>&quot;v=BIMI1; l=https://yourdomain.com/logo.svg; a=&quot;</pre><ul><li><strong>Replace</strong> yourdomain.com/logo.svg with the actual URL of your hosted logo.</li><li>The a= tag is for the Verified Mark Certificate (VMC). If you don’t have a VMC, leave it empty.</li></ul><h3>Step 4: Verify Your BIMI Record</h3><p>Use a BIMI checker to verify your setup:</p><ul><li><a href="https://bimigroup.org/bimi-generator/">BIMI Group Checker</a></li><li>EasyDMARC BIMI Checker</li></ul><h3>Step 5: Obtain a Verified Mark Certificate (Optional but Recommended)</h3><p>Some email providers (like Gmail) <strong>require a VMC</strong> for BIMI logos to appear.</p><p>Obtain a <strong>Verified Mark Certificate (VMC)</strong> from an authorized certificate provider like:</p><ul><li><a href="https://www.digicert.com/">DigiCert</a></li><li><a href="https://www.entrust.com/">Entrust</a></li></ul><p>Update your BIMI record to include the VMC:</p><pre>default._bimi.yourdomain.com TXT <br>&quot;v=BIMI1; l=https://yourdomain.com/logo.svg; a=https://your-certificate-url.pem&quot;</pre><h3>Step 6: Monitor and Troubleshoot</h3><p>After implementing BIMI, monitor your email deliverability and check if your logo appears in inboxes.</p><h3>Frequently Asked Questions (FAQ)</h3><h4>1. How long does it take for BIMI to work?</h4><p>BIMI adoption varies by email provider. Some take <strong>a few days to weeks</strong> to recognize and display the logo.</p><h4>2. Which email providers support BIMI?</h4><ul><li><strong>Gmail</strong> (requires a VMC)</li><li><strong>Yahoo</strong></li><li><strong>Fastmail</strong></li><li><strong>Apple Mail</strong></li><li><strong>La Poste</strong></li><li><strong>AOL</strong></li></ul><h4>3. Can I use BIMI without a VMC?</h4><p>Yes, but major providers like Gmail <strong>require a VMC</strong> for your logo to appear.</p><h4>4. How do I check if my BIMI setup is working?</h4><p>Use tools like:</p><ul><li><a href="https://bimigroup.org/bimi-generator/">BIMI Inspector</a></li><li>EasyDMARC BIMI Lookup</li></ul><h3>Conclusion</h3><p>Setting up BIMI enhances email security and brand trust. Ensure that SPF, DKIM, and DMARC are correctly configured before adding your BIMI record.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5fdadff97ca3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To Create Custom Helper Function In Laravel 9]]></title>
            <link>https://lahiruprabodha.medium.com/how-to-create-custom-helper-function-in-laravel-9-c2d97198e790?source=rss-cd7af1d9b09d------2</link>
            <guid isPermaLink="false">https://medium.com/p/c2d97198e790</guid>
            <category><![CDATA[laravel]]></category>
            <dc:creator><![CDATA[Lahiru Prabodha]]></dc:creator>
            <pubDate>Sat, 31 Dec 2022 02:45:40 GMT</pubDate>
            <atom:updated>2022-12-31T02:45:40.961Z</atom:updated>
            <content:encoded><![CDATA[<p>To create a custom helper function in Laravel 9, you can follow these steps:</p><figure><img alt="How To Create Custom Helper Function In Laravel 9" src="https://cdn-images-1.medium.com/max/1024/1*qq3zMI42ZCXMSNg-T3GsdA.jpeg" /></figure><ol><li>Create a new file in the app/Helpers directory. You can name the file something like helpers.php.</li><li>In the helpers.php file, define your custom helper function. Here&#39;s an example of a helper function that capitalizes the first letter of a string:</li></ol><pre>&lt;?php<br><br>if (!function_exists(&#39;capitalize&#39;)) {<br>    function capitalize($string) {<br>        return ucfirst($string);<br>    }<br>}</pre><p>3. To make your custom helper function available to your entire application, you need to load it in the global namespace. You can do this by adding the following line at the top of your app/Helpers/helpers.php file:</p><pre>&lt;?php<br><br>namespace App\Helpers;</pre><p>4. Next, you need to autoload the helpers.php file. You can do this by adding the following line to the files array in your composer.json file:</p><pre>&quot;app/Helpers/helpers.php&quot;,</pre><p>5. Finally, run the following command to regenerate the autoloader:</p><pre>composer dump-autoload</pre><p>Now, you should be able to use your custom helper function anywhere in your application by calling it like any other PHP function.</p><p>For example:</p><pre>echo capitalize(&#39;laravel&#39;); // Outputs &quot;Laravel&quot;</pre><p>Thank you for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c2d97198e790" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automatically Backup Database Laravel 9]]></title>
            <link>https://lahiruprabodha.medium.com/automatically-backup-database-laravel-9-94fa4b3ce253?source=rss-cd7af1d9b09d------2</link>
            <guid isPermaLink="false">https://medium.com/p/94fa4b3ce253</guid>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[laravel9]]></category>
            <category><![CDATA[database-backup]]></category>
            <dc:creator><![CDATA[Lahiru Prabodha]]></dc:creator>
            <pubDate>Tue, 27 Dec 2022 23:26:32 GMT</pubDate>
            <atom:updated>2022-12-27T23:26:32.184Z</atom:updated>
            <content:encoded><![CDATA[<p>In this tutorial, we are going to learn <strong>how to Automatically Backup Database Daily Weekly Monthly Laravel 9</strong>.</p><figure><img alt="Automatically Backup Database Laravel 9" src="https://cdn-images-1.medium.com/max/640/1*XBwk6c3WG0cqtu5wfh_5sA.png" /></figure><p>To automatically backup a database in Laravel 9, you can use the Laravel Backup package. This package provides a variety of options for scheduling and performing database backups.</p><p>To install the Laravel Backup package, you can use Composer:</p><pre>composer require spatie/laravel-backup</pre><p>Once the package is installed, you will need to configure it. You can publish the package’s configuration file using the following command:</p><pre>php artisan vendor:publish --provider=&quot;Spatie\Backup\BackupServiceProvider&quot;</pre><p>This will create a backup.php configuration file in your config directory. In this file, you can specify the database connections that you want to backup, as well as any other options such as the storage location and the frequency of the backups.</p><p>To schedule the backups to run automatically, you can use the schedule method in the App\Console\Kernel class. For example, to run a backup every day at midnight, you can use the following code:</p><pre>protected function schedule(Schedule $schedule)<br>{<br>    $schedule-&gt;command(&#39;backup:run&#39;)-&gt;daily();<br>}</pre><p>This will schedule the backup:run Artisan command to be run every day at midnight. The backup:run command will perform the backups according to the settings in the backup.php configuration file.</p><p>You can also use the schedule method to specify more complex schedules, such as running backups every hour on weekdays or every Monday at 3 AM. For more information about scheduling backups with the Laravel Backup package, you can refer to the documentation at <a href="https://docs.spatie.be/laravel-backup/v9/getting-started/installation">https://docs.spatie.be/laravel-backup/v9/getting-started/installation</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=94fa4b3ce253" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Convert HTML to PDF in Python?]]></title>
            <link>https://lahiruprabodha.medium.com/how-to-convert-html-to-pdf-in-python-69474804fb8a?source=rss-cd7af1d9b09d------2</link>
            <guid isPermaLink="false">https://medium.com/p/69474804fb8a</guid>
            <category><![CDATA[html-to-pdf-converter]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Lahiru Prabodha]]></dc:creator>
            <pubDate>Sat, 24 Dec 2022 13:02:18 GMT</pubDate>
            <atom:updated>2026-07-21T08:04:13.772Z</atom:updated>
            <content:encoded><![CDATA[<p>There are several ways to convert HTML to PDF in Python. Here are a few options:</p><figure><img alt="How to Convert HTML to PDF in Python?" src="https://cdn-images-1.medium.com/max/1024/1*vKyv531p-JxzMm3Z1UyH_A.jpeg" /></figure><ol><li>Use a library such as pdfkit:</li></ol><pre>import pdfkit<br><br># Convert an HTML file to a PDF<br>pdfkit.from_file(&#39;input.html&#39;, &#39;output.pdf&#39;)<br><br># Convert an HTML string to a PDF<br>html = &#39;&lt;html&gt;&lt;body&gt;Hello World&lt;/body&gt;&lt;/html&gt;&#39;<br>pdfkit.from_string(html, &#39;output.pdf&#39;)</pre><p>2. Use a library such as weasyprint:</p><pre>import weasyprint<br><br># Convert an HTML file to a PDF<br>weasyprint.HTML(&#39;input.html&#39;).write_pdf(&#39;output.pdf&#39;)<br><br># Convert an HTML string to a PDF<br>html = &#39;&lt;html&gt;&lt;body&gt;Hello World&lt;/body&gt;&lt;/html&gt;&#39;<br>weasyprint.HTML(string=html).write_pdf(&#39;output.pdf&#39;)</pre><p>3. Use a library such as xhtml2pdf:</p><pre>import xhtml2pdf.pisa as pisa<br><br># Convert an HTML file to a PDF<br>with open(&#39;input.html&#39;, &#39;rb&#39;) as f:<br>    pisa.CreatePDF(f, &#39;output.pdf&#39;)<br><br># Convert an HTML string to a PDF<br>html = &#39;&lt;html&gt;&lt;body&gt;Hello World&lt;/body&gt;&lt;/html&gt;&#39;<br>pisa.CreatePDF(html, &#39;output.pdf&#39;)</pre><p>4. Use a library such as PyPDF2:</p><pre>import io<br>import PyPDF2<br>from PyPDF2 import PdfFileReader, PdfFileWriter<br>from reportlab.pdfgen import canvas<br>from reportlab.lib.pagesizes import letter<br><br># Convert an HTML file to a PDF<br>packet = io.BytesIO()<br>can = canvas.Canvas(packet, pagesize=letter)<br>can.drawString(10, 100, open(&#39;input.html&#39;, &#39;r&#39;).read())<br>can.save()<br><br># move to the beginning of the StringIO buffer<br>packet.seek(0)<br>new_pdf = PdfFileReader(packet)<br><br># read your existing PDF<br>existing_pdf = PdfFileReader(open(&quot;output.pdf&quot;, &quot;rb&quot;))<br>output = PdfFileWriter()<br><br># add the &quot;watermark&quot; (which is the new pdf) on the existing page<br>page = existing_pdf.getPage(0)<br>page.mergePage(new_pdf.getPage(0))<br>output.addPage(page)<br><br># finally, write &quot;output&quot; to a real file<br>outputStream = open(&quot;output.pdf&quot;, &quot;wb&quot;)<br>output.write(outputStream)<br>outputStream.close()</pre><p>5. Use IronPDF (Chrome engine — renders like a browser)</p><p>Worth adding a fifth option, since each of the four above has a rendering caveat the two-liners don’t show: pdfkit needs the external <strong>wkhtmltopdf</strong> binary installed; weasyprint uses its own CSS renderer with <strong>no JavaScript</strong>; xhtml2pdf supports only a <strong>limited CSS subset</strong>; and option 4 doesn’t really render HTML — canvas.drawString writes the raw HTML <em>source</em> onto the page as literal text.</p><p><strong>IronPDF</strong> renders with a real <strong>Chrome</strong> engine, so modern CSS, web fonts, and JavaScript come out as they’d look in a browser — and there’s no separate binary to install (the engine ships with the pip package):</p><pre>pip install ironpdf</pre><pre>from ironpdf import ChromePdfRenderer<br><br>renderer = ChromePdfRenderer()<br><br># Convert an HTML file to a PDF<br>renderer.RenderHtmlFileAsPdf(&#39;input.html&#39;).SaveAs(&#39;output.pdf&#39;)<br><br># Convert an HTML string to a PDF<br>html = &#39;&lt;html&gt;&lt;body&gt;Hello World&lt;/body&gt;&lt;/html&gt;&#39;<br>renderer.RenderHtmlAsPdf(html).SaveAs(&#39;output.pdf&#39;)<br><br># Convert a live URL to a PDF<br>renderer.RenderUrlAsPdf(&#39;https://example.com&#39;).SaveAs(&#39;output.pdf&#39;)</pre><p>Same two-line file-and-string pattern as the other options, plus URL-to-PDF. Because it’s Chrome under the hood, JavaScript-driven pages (charts, dynamic content) render correctly — the case weasyprint and xhtml2pdf can’t cover.</p><p><strong>Honest note:</strong> the four libraries above are free and open-source — for simple, static HTML they do the job at zero cost. IronPDF is commercial (from $749; free trial; runs on the .NET runtime beneath the Python API). It’s worth reaching for when the HTML relies on modern CSS or JavaScript, or when you’d rather not install and manage the wkhtmltopdf binary that pdfkit depends on.</p><p><a href="https://ironpdf.com/python/">IronPDF for Python</a> ·<a href="https://ironpdf.com/python/tutorials/html-to-pdf/"> HTML to PDF tutorial</a> ·<a href="https://ironpdf.com/python/"> free trial</a></p><p>Thanks for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=69474804fb8a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Laravel Global Scopes with Parameters for Global Usage]]></title>
            <link>https://lahiruprabodha.medium.com/laravel-global-scopes-with-parameters-for-global-usage-c0a0aac22cdc?source=rss-cd7af1d9b09d------2</link>
            <guid isPermaLink="false">https://medium.com/p/c0a0aac22cdc</guid>
            <category><![CDATA[laravel]]></category>
            <dc:creator><![CDATA[Lahiru Prabodha]]></dc:creator>
            <pubDate>Sat, 24 Dec 2022 05:02:51 GMT</pubDate>
            <atom:updated>2022-12-24T15:25:56.565Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Laravel Global Scopes with Parameters for Global Usage" src="https://cdn-images-1.medium.com/max/1024/1*3t4RKCGhdZZ9gjndItckzQ.png" /></figure><p>In Laravel, a global scope is a class that defines a constraint that should be applied to all queries on a given model. Global scopes allow you to define constraints that should always be applied when retrieving models from the database, regardless of how the models are accessed.</p><p>To define a global scope, you can use the Illuminate\Database\Eloquent\Builder class&#39;s addGlobalScope method. This method takes two arguments: the scope class and a closure that receives the builder instance as an argument and defines the constraint that should be applied.</p><p>For example, suppose you have a posts table with a published column that indicates whether a post is published or not. You could define a global scope that only retrieves published posts like this:</p><pre>use Illuminate\Database\Eloquent\Builder;<br>use Illuminate\Database\Eloquent\Model;<br>use Illuminate\Database\Eloquent\Scope;<br><br>class PublishedScope implements Scope<br>{<br>    public function apply(Builder $builder, Model $model)<br>    {<br>        $builder-&gt;where(&#39;published&#39;, true);<br>    }<br>}<br><br>class Post extends Model<br>{<br>    protected static function boot()<br>    {<br>        parent::boot();<br><br>        static::addGlobalScope(new PublishedScope);<br>    }<br>}</pre><p>Now, whenever you retrieve posts from the database, the published constraint will be applied automatically.</p><p>To pass parameters to a global scope, you can define a constructor in the scope class and pass the parameters as arguments to the constructor. You can then store the parameters as properties on the scope class and use them in the apply method to define the constraint.</p><p>For example, suppose you want to allow users to filter posts by their author. You could define a global scope like this:</p><pre>use Illuminate\Database\Eloquent\Builder;<br>use Illuminate\Database\Eloquent\Model;<br>use Illuminate\Database\Eloquent\Scope;<br><br>class AuthorScope implements Scope<br>{<br>    protected $authorId;<br><br>    public function __construct($authorId)<br>    {<br>        $this-&gt;authorId = $authorId;<br>    }<br><br>    public function apply(Builder $builder, Model $model)<br>    {<br>        $builder-&gt;where(&#39;author_id&#39;, $this-&gt;authorId);<br>    }<br>}<br><br>class Post extends Model<br>{<br>    protected static function boot()<br>    {<br>        parent::boot();<br><br>        static::addGlobalScope(&#39;author&#39;, function (Builder $builder) {<br>            $builder-&gt;withGlobalScope(&#39;author&#39;, new AuthorScope(request(&#39;author_id&#39;)));<br>        });<br>    }<br>}</pre><p>Now, you can use the author_id parameter to filter posts by their author. For example, you can retrieve all posts written by a particular author by calling Post::where(&#39;author_id&#39;, $authorId)-&gt;get().</p><p>It’s important to note that global scopes are applied to all queries on a model, so you should be careful to use them only for constraints that should be applied consistently across your application. If you need to apply a constraint only for a specific query, it’s usually better to use a local scope or a closure instead.</p><p>Thanks for reading. I hope this helps!</p><figure><a href="http://buymeacoffee.com/lprabodha1W"><img alt="" src="https://cdn-images-1.medium.com/max/399/1*rsViqCjTco6ldqTDMFDQnA.png" /></a></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c0a0aac22cdc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to build a BMI Calculator in Python]]></title>
            <link>https://lahiruprabodha.medium.com/how-to-build-a-bmi-calculator-in-python-120183044c2d?source=rss-cd7af1d9b09d------2</link>
            <guid isPermaLink="false">https://medium.com/p/120183044c2d</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[bmi-calculator]]></category>
            <dc:creator><![CDATA[Lahiru Prabodha]]></dc:creator>
            <pubDate>Sat, 24 Dec 2022 01:48:48 GMT</pubDate>
            <atom:updated>2022-12-24T15:28:40.985Z</atom:updated>
            <content:encoded><![CDATA[<p>To build a BMI (Body Mass Index) calculator in Python, you will need to follow these steps:</p><figure><img alt="How to build a BMI Calculator in Python" src="https://cdn-images-1.medium.com/max/777/1*0hJDrY7Wt_d39HJGHN8u7w.jpeg" /></figure><ol><li>Define the main function that will take in the weight and height of a person as input and return their BMI as output.</li><li>Within the main function, convert the weight from pounds to kilograms and the height from inches to meters. You can do this using the following conversions:</li></ol><ul><li>1 pound = 0.45359237 kilograms</li><li>1 inch = 0.0254 meters</li></ul><p>3. Calculate the BMI using the following formula:</p><p>BMI = weight (kg) / height² (m²)</p><p>4. Return the BMI as the output of the function.</p><p>Here is an example of how the main function could look:</p><pre>def calculate_bmi(weight, height):<br>    weight_kg = weight * 0.45359237<br>    height_m = height * 0.0254<br>    bmi = weight_kg / (height_m ** 2)<br>    return bmi</pre><p>You can then call this function with the weight and height of a person, and it will return their BMI. For example:</p><pre>bmi = calculate_bmi(180, 72)<br>print(bmi)</pre><p>This would print the BMI for a person who weighs 180 pounds and is 72 inches tall.</p><p>It’s also a good idea to add some additional functionality to your BMI calculator, such as the ability to interpret the BMI value and provide some information about what it means. For example, you could use the following categories to interpret the BMI:</p><ul><li>Underweight: less than 18.5</li><li>Normal weight: 18.5 to 24.9</li><li>Overweight: 25 to 29.9</li><li>Obese: 30 or greater</li></ul><p>You could add this functionality to your BMI calculator by adding an additional function that takes the BMI as input and returns a string indicating the category. Here is an example of how this function could look:</p><pre>def interpret_bmi(bmi):<br>    if bmi &lt; 18.5:<br>        return &quot;Underweight&quot;<br>    elif bmi &lt; 25:<br>        return &quot;Normal weight&quot;<br>    elif bmi &lt; 30:<br>        return &quot;Overweight&quot;<br>    else:<br>        return &quot;Obese&quot;</pre><p>You can then call this function with the BMI calculated by your main function to get a string indicating the category. For example:</p><pre>bmi = calculate_bmi(180, 72)<br>category = interpret_bmi(bmi)<br>print(category)</pre><p>This would print the category for a person who weighs 180 pounds and is 72 inches tall.</p><p>Thanks for reading. I hope this helps!</p><figure><a href="http://buymeacoffee.com/lprabodha1W"><img alt="" src="https://cdn-images-1.medium.com/max/399/1*rsViqCjTco6ldqTDMFDQnA.png" /></a></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=120183044c2d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Use break, continue and pass in Python Programming]]></title>
            <link>https://lahiruprabodha.medium.com/how-to-use-break-continue-and-pass-in-python-programming-5d270ac60fe4?source=rss-cd7af1d9b09d------2</link>
            <guid isPermaLink="false">https://medium.com/p/5d270ac60fe4</guid>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Lahiru Prabodha]]></dc:creator>
            <pubDate>Fri, 23 Dec 2022 18:19:37 GMT</pubDate>
            <atom:updated>2022-12-24T15:29:51.064Z</atom:updated>
            <content:encoded><![CDATA[<p>In Python, break, continue, and pass are control statements that allow you to control the flow of your program.</p><figure><img alt="How to Use break, continue and pass in Python Programming" src="https://cdn-images-1.medium.com/max/1024/1*PjS28UR8wkPhJLh7Kyy-7w.jpeg" /></figure><p>Here is an overview of how to use each of these statements:</p><p>break: The break the statement is used to exit a loop early, before the loop&#39;s natural ending. For example:</p><pre># using the break statement<br>for i in range(10):<br>    if i == 5:<br>        break<br>    print(i)<br><br># Output: 0 1 2 3 4</pre><p>In this code, the for loop will iterate over the range of numbers from 0 to 9. However, when i is equal to 5, the break statement is executed and the loop will exit. The output of this code will be the numbers 0 through 4.</p><p>continue: The continue statement is used to skip the rest of the current iteration of a loop and move on to the next iteration. For example:</p><pre># using the continue statement<br>for i in range(10):<br>    if i % 2 == 0:<br>        continue<br>    print(i)<br><br># Output: 1 3 5 7 9</pre><p>In this code, the for loop will iterate over the range of numbers from 0 to 9. If i is even (i.e., if i is divisible by 2 with no remainder), the continue statement will be executed and the loop will move on to the next iteration without printing the value of i. The output of this code will be the odd numbers 1 through 9.</p><p>pass: The pass statement is a placeholder that does nothing. It is often used as a placeholder in code that is not yet implemented, or as a way to temporarily disable a piece of code while you are working on it. For example:</p><pre># using the pass statement<br>for i in range(10):<br>    if i % 2 == 0:<br>        pass<br>    print(i)<br><br># Output: 0 1 2 3 4 5 6 7 8 9</pre><p>In this code, the for loop will iterate over the range of numbers from 0 to 9. If i is even, the pass statement will be executed and the loop will continue to the next iteration. If i is odd, the else clause will be executed and the value of i will be printed. The output of this code will be the odd numbers 1 through 9.</p><p>It’s important to note that break, continue, and pass are only used within looping statements, such as for and while loops. Using these statements outside of a loop will result in a syntax error.</p><p>Thanks for reading. I hope this helps!</p><figure><a href="http://buymeacoffee.com/lprabodha1W"><img alt="" src="https://cdn-images-1.medium.com/max/399/1*rsViqCjTco6ldqTDMFDQnA.png" /></a></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5d270ac60fe4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Web Scraping with Scrapy and Django]]></title>
            <link>https://lahiruprabodha.medium.com/web-scraping-with-scrapy-and-django-9c1ba540352f?source=rss-cd7af1d9b09d------2</link>
            <guid isPermaLink="false">https://medium.com/p/9c1ba540352f</guid>
            <category><![CDATA[scraping]]></category>
            <category><![CDATA[scrapy]]></category>
            <category><![CDATA[django]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Lahiru Prabodha]]></dc:creator>
            <pubDate>Fri, 23 Dec 2022 17:44:53 GMT</pubDate>
            <atom:updated>2022-12-24T15:36:06.019Z</atom:updated>
            <content:encoded><![CDATA[<p>Scrapy is a powerful web scraping framework for Python that is commonly used to extract data from websites. It is designed to be fast, simple, and extensible, and it can be used to build a wide variety of web scraping projects.</p><figure><img alt="Web Scraping with Scrapy and Django" src="https://cdn-images-1.medium.com/max/1024/1*GhscgCiKKWwnTnkRCXfFJg.png" /></figure><p>If you are using Django as the backend for your web application, you can integrate Scrapy into your Django project to perform web scraping tasks and store the data in your Django models.</p><p>Here is an outline of how you might go about integrating Scrapy into a Django project:</p><ol><li>Install Scrapy: You can install Scrapy using pip, the Python package manager. Run the following command to install Scrapy:</li></ol><pre>pip install scrapy</pre><p>2. Create a Scrapy project: Scrapy projects are organized using a directory structure that includes a scrapy.cfg file and several subdirectories. To create a Scrapy project, you can use the scrapy startproject command. For example:</p><pre>scrapy startproject myproject</pre><p>This will create a directory called myproject with the basic Scrapy project structure.</p><p>3. Define your Scrapy spider: A Scrapy spider is a Python class that defines how a particular website should be scraped. You can define your own spiders by subclassing the scrapy.Spider class and defining the parse method, which specifies how the spider should process the response from the website. For example:</p><pre>import scrapy<br><br>class MySpider(scrapy.Spider):<br>    name = &quot;myspider&quot;<br>    start_urls = [<br>        &quot;http://www.example.com/&quot;,<br>    ]<br><br>    def parse(self, response):<br>        # Extract data from the website and return it as a dict<br>        data = {}<br>        data[&quot;title&quot;] = response.css(&quot;title::text&quot;).get()<br>        data[&quot;url&quot;] = response.url<br>        return data</pre><p>4. Run your spider: You can run your spider using the scrapy crawl command. For example:</p><pre>scrapy crawl myspider</pre><p>This will start the spider and scrape the website specified in the start_urls list.</p><p>5. Store the scraped data in your Django models: To store the scraped data in your Django models, you will need to import your Django models into your Scrapy spider and use them to create Django objects. For example:</p><pre>import scrapy<br>from myapp.models import MyModel<br><br>class MySpider(scrapy.Spider):<br>    name = &quot;myspider&quot;<br>    start_urls = [<br>        &quot;http://www.example.com/&quot;,<br>    ]<br><br>    def parse(self, response):<br>        data = {}<br>        data[&quot;title&quot;] = response.css(&quot;title::text&quot;).get()<br>        data[&quot;url&quot;] = response.url<br>        MyModel.objects.create(**data)</pre><p>This is just a basic overview of how you can integrate Scrapy and Django. There are many other ways you can customize and extend your web scraping projects, such as defining custom pipelines to process the scraped data, or using Scrapy’s built-in support for following links and scraping multiple pages. For more information, you can refer to the Scrapy documentation.</p><p>Thanks for reading.</p><p>References. I used <a href="https://docs.scrapy.org/en/latest/">https://docs.scrapy.org/en/latest/</a></p><figure><a href="http://buymeacoffee.com/lprabodha1W"><img alt="" src="https://cdn-images-1.medium.com/max/399/1*rsViqCjTco6ldqTDMFDQnA.png" /></a></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9c1ba540352f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>