Create an account


Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 12,782
» Latest member: Donnarhise
» Forum threads: 19,349
» Forum posts: 19,905

Full Statistics

Online Users
There are currently 580 online users.
» 0 Member(s) | 579 Guest(s)
Bing

 
  [Oracle Blog] GraalVM Enterprise 21.2—Productivity and Performance
Posted by: xSicKxBot - 01-16-2023, 04:46 PM - Forum: Java Language, JVM, and the JRE - No Replies

GraalVM Enterprise 21.2—Productivity and Performance

The latest GraalVM Enterprise 21.2 release delivers both new performance features, and improved developer experience—including enhancements to GraalVM Native Image to make it easier than ever to compile applications into native executables. Let’s take a look at some of the highlights of the GraalVM ...


https://blogs.oracle.com/java/post/graal...erformance

Print this item

  [Tut] How I Generate Invoices For My Clients Using Python
Posted by: xSicKxBot - 01-16-2023, 04:46 PM - Forum: Python - No Replies

How I Generate Invoices For My Clients Using Python

<div>
<div class="kk-star-ratings kksr-auto kksr-align-left kksr-valign-top" data-payload='{&quot;align&quot;:&quot;left&quot;,&quot;id&quot;:&quot;1058500&quot;,&quot;slug&quot;:&quot;default&quot;,&quot;valign&quot;:&quot;top&quot;,&quot;ignore&quot;:&quot;&quot;,&quot;reference&quot;:&quot;auto&quot;,&quot;class&quot;:&quot;&quot;,&quot;count&quot;:&quot;0&quot;,&quot;legendonly&quot;:&quot;&quot;,&quot;readonly&quot;:&quot;&quot;,&quot;score&quot;:&quot;0&quot;,&quot;starsonly&quot;:&quot;&quot;,&quot;best&quot;:&quot;5&quot;,&quot;gap&quot;:&quot;5&quot;,&quot;greet&quot;:&quot;Rate this post&quot;,&quot;legend&quot;:&quot;0\/5 - (0 votes)&quot;,&quot;size&quot;:&quot;24&quot;,&quot;width&quot;:&quot;0&quot;,&quot;_legend&quot;:&quot;{score}\/{best} - ({count} {votes})&quot;,&quot;font_factor&quot;:&quot;1.25&quot;}'>
<div class="kksr-stars">
<div class="kksr-stars-inactive">
<div class="kksr-star" data-star="1" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
<div class="kksr-star" data-star="2" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
<div class="kksr-star" data-star="3" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
<div class="kksr-star" data-star="4" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
<div class="kksr-star" data-star="5" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
</p></div>
<div class="kksr-stars-active" style="width: 0px;">
<div class="kksr-star" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
<div class="kksr-star" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
<div class="kksr-star" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
<div class="kksr-star" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
<div class="kksr-star" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
</p></div>
</div>
<div class="kksr-legend" style="font-size: 19.2px;"> <span class="kksr-muted">Rate this post</span> </div>
</p></div>
<figure class="wp-block-image size-full is-resized is-style-default"><img loading="lazy" decoding="async" src="https://blog.finxter.com/wp-content/uploads/2023/01/invoice.jpeg" alt="" class="wp-image-1058553" width="623" height="467" srcset="https://blog.finxter.com/wp-content/uploads/2023/01/invoice.jpeg 1000w, https://blog.finxter.com/wp-content/uplo...0x225.jpeg 300w, https://blog.finxter.com/wp-content/uplo...8x576.jpeg 768w" sizes="(max-width: 623px) 100vw, 623px" /></figure>
<h2>Project Description</h2>
<p>Being self-employed personnel means I regularly need to generate Invoices for my clients to receive the payments. Now, this is a manual task that I have to perform using excel sheets and then convert them into PDFs. That is why I came up with a script that would automate the entire task for me. </p>
<p>Thus, in this mini project, I will demonstrate how I generate PDF invoices that I send to my clients using a simple Python script that uses the <strong>InvoiceGenerator API</strong>. </p>
<h2>Step 1: Installing and Importing the <a rel="noreferrer noopener" href="https://pypi.org/project/InvoiceGenerator/" target="_blank">InvoiceGenerator</a> Library</h2>
<p><code>InvoiceGenerator</code> is a Python library that is specifically designed to generate simple invoices. Presently, it supports invoice generation in PDF and XML formats. The PDF invoice generation is based on ReportLab. </p>
<p><strong><span style="text-decoration: underline">Installation</span></strong></p>
<p>To install the InvoiceGenerator library, open your terminal and run the following command – </p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">pip install InvoiceGenerator</pre>
<p>In case you want to upgrade to a new version, then use the <code>--upgrade</code> flag. </p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">pip install InvoiceGenerator – upgrade</pre>
<p>Read more about this library and how to use the API <strong><a href="https://pypi.org/project/InvoiceGenerator/" target="_blank" rel="noreferrer noopener">here</a></strong>.</p>
<p>Once you have installed the library, go ahead and import it into your script. You also need to import the <code>os</code> module along with the necessary modules within the <code>InvoiceGenerator</code> library. Here’s a quick look at the necessary modules that we will need in our code – </p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">import os
from InvoiceGenerator.api import Invoice, Item, Client, Provider, Creator
from InvoiceGenerator.pdf import SimpleInvoice</pre>
<ul>
<li>Import <code>Invoice</code>, <code>Item</code>, <code>Client</code>, <code>Provider</code> and <code>Creator</code> from <code>InvoiceGenerator.API</code>.</li>
<li>Also, import <code>SimpleInvoice</code> from <code>InvoiceGenerator.PDF</code>.</li>
<li>Finally, import <code>os</code> for performing OS-related activities.</li>
</ul>
<h2>Step 2: Create the Automated PDF Invoice</h2>
<p>The next step is to create an automated PDF using the <code>InvoiceGenerator</code> API.</p>
<p><strong>Code:</strong></p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">os.environ["INVOICE_LANG"] = "en"
client = Client('Finxter')
provider = Provider('Shubham Sayon Consultancy Services', bank_account='XXX-XXXX-XXXXX', bank_code='2021')
creator = Creator('Shubham Sayon')
invoice = Invoice(client, provider, creator)
number_of_items = int(input("Enter the number of Items: "))
for i in range(number_of_items): units = int(input(f"Enter the number of units for item no.{i+1}: ")) price_per_unit = int(input(f"Enter the price per unit of item no.{i+1}: ")) description = input("Enter the name of item/product: ") invoice.add_item(Item(units, price_per_unit, description=description)) invoice.currency = "$"
invoice.number = "10393069"
document = SimpleInvoice(invoice)
document.gen("invoice.pdf", generate_qr_code=True)</pre>
<p><strong>Explanation:</strong></p>
<ul>
<li>We will first set the document environment language. In my case, I have set it to “English”.</li>
<li>We then need to set the mandatory details like the client, provider and creator. The client details can be set using the <code>Client</code> object. Similarly, to set the provider, use the <code>Provider</code> object. I have set the provider name and the bank details within the Provider object. </li>
<li>Next, create the invoice object that will allow us to generate the numerous features within the bill. </li>
<li>I have then used an <a rel="noreferrer noopener" href="https://blog.finxter.com/python-input-function/" target="_blank">input()</a> function to allow the user to enter the total number of items he/she wants to include in the bill. </li>
<li>Once the user enters the number of items, this can be used a range of create a for loop within which we can ask the user to enter further details like the number of units for each item, the price per unit of each item and the description of each item.</li>
<li>All these details can then be implemented within the invoice PDF using the <code>item.add_item()</code> method. </li>
<li>You can further specify
<ul>
<li>The currency of transaction using <code>invoice.currency</code>, </li>
<li>The invoice number using <code>invoice.number</code></li>
</ul>
</li>
<li> Finally, generate the invoice PDF with the help of the <code>SimpleInvoice</code> objects <code>gen</code> method. To generate a QR code within the PDF use the <code>generate_qr_code</code> object.</li>
</ul>
<h2>Putting it All Together</h2>
<p>Let’s put it all together to visualize how the entire script works –</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">import os
from InvoiceGenerator.api import Invoice, Item, Client, Provider, Creator
from InvoiceGenerator.pdf import SimpleInvoice os.environ["INVOICE_LANG"] = "en"
client = Client('Finxter')
provider = Provider('Shubham Sayon Consultancy Services', bank_account='XXX-XXXX-XXXXX', bank_code='2021')
creator = Creator('Shubham Sayon')
invoice = Invoice(client, provider, creator)
number_of_items = int(input("Enter the number of Items: "))
for i in range(number_of_items): units = int(input(f"Enter the number of units for item no.{i+1}: ")) price_per_unit = int(input(f"Enter the price per unit of item no.{i+1}: ")) description = input("Enter the name of item/product: ") invoice.add_item(Item(units, price_per_unit, description=description)) invoice.currency = "$"
invoice.number = "10393069"
document = SimpleInvoice(invoice)
document.gen("invoice.pdf", generate_qr_code=True)</pre>
<p>That’s it! As simple as that and when you execute the code it will generate the invoice PDF within your project folder conataining all the details mentioned by you.</p>
<h2>Conclusion</h2>
<p>Hurrah! We have successfully created an automation script that allows us to generate our customized PDF that also has a QR code embedded within it. Isn’t this extremely handy and useful!? </p>
<p>With that, we come to the end of this project.  I hope this project added some value and helped you in your coding quest. Stay tuned and <strong><a rel="noreferrer noopener" href="https://blog.finxter.com/subscribe/" target="_blank">subscribe</a></strong> for more interesting projects and tutorials.</p>
<p>Do you love automating tasks with Python? Well! I do. And if you are someone who likes automation, then here’s a list of a few mini projects that will get you going –</p>
<ul>
<li><a href="https://blog.finxter.com/create-your-own-youtube-video-downloader/"><strong>Create Your Own YouTube Video Downloader</strong></a></li>
<li>&nbsp;<strong><a href="https://blog.finxter.com/the-power-of-automation-using-python-segregating-images-based-on-dimensions/" target="_blank" rel="noreferrer noopener">The Power of Automation Using Python – Segregating Images Based on Dimensions</a></strong></li>
<li><strong><a href="https://blog.finxter.com/automate-backup-to-google-drive-with-python/" target="_blank" rel="noreferrer noopener">Automate Backup to Google Drive with Python</a></strong></li>
<li><strong><a href="https://blog.finxter.com/receive-automated-email-notification-on-website-update/" target="_blank" rel="noreferrer noopener">Receive Automated Email Notification on Website Update</a></strong></li>
<li><strong><a href="https://blog.finxter.com/the-art-of-automating-whatsapp-messages-using-python/" target="_blank" rel="noreferrer noopener">The Art of Automating Whatsapp Messages Using Python</a></strong></li>
<li><strong><a rel="noreferrer noopener" href="https://blog.finxter.com/create-your-own-youtube-video-downloader/" target="_blank">Create Your Own YouTube Video Downloader</a></strong></li>
<li><strong><a rel="noreferrer noopener" href="https://blog.finxter.com/how-i-used-python-to-automate-my-daily-routine-with-desktop-notifications/" target="_blank">How I used Python to Automate my Daily Routine with Desktop Notifications</a></strong></li>
</ul>
<hr class="wp-block-separator has-alpha-channel-opacity" />
<div class="wp-block-image">
<figure class="aligncenter size-full"><a href="https://academy.finxter.com/university/article-summarization/" target="_blank" rel="noopener"><img decoding="async" loading="lazy" width="363" height="650" src="https://blog.finxter.com/wp-content/uploads/2022/05/image-309.png" alt="" class="wp-image-387314" srcset="https://blog.finxter.com/wp-content/uploads/2022/05/image-309.png 363w, https://blog.finxter.com/wp-content/uplo...68x300.png 168w" sizes="(max-width: 363px) 100vw, 363px" /></a></figure>
</div>
</div>


https://www.sickgaming.net/blog/2023/01/...ng-python/

Print this item

  (Indie Deal) FREE Alone on Mars & DBZ: KAKAROT Legendary Deal
Posted by: xSicKxBot - 01-16-2023, 04:45 PM - Forum: Deals or Specials - No Replies

FREE Alone on Mars & DBZ: KAKAROT Legendary Deal

<div class="bb_h1">Alone on Mars FREEbie</div><a class="bb_link" href="https://steamcommunity.com/linkfilter/?url=https://freebies.indiegala.com/alone-on-mars" target="_blank" rel=" noopener" ><img src="https://cdn.akamai.steamstatic.com/steamcommunity/public/images/clans/3402923/6d6705b928b6b6fd66d420a856a4dc15dbbd2b86.jpg" /></a><span class="bb_link_host">[freebies.indiegala.com]</span><br><div class="bb_h1"><a class="bb_link" href="https://steamcommunity.com/linkfilter/?url=https://www.indiegala.com/store/game/dragon-ball-z-kakarot-legendary-edition/851850_legendary" target="_blank" rel=" noopener" > DRAGON BALL Z: KAKAROT Legendary Edition Deal</a><span class="bb_link_host">[www.indiegala.com]</span></div><a class="bb_link" href="https://www.youtube.com/watch?v=Bf85wwJuFBE" target="_blank" rel="" >https://www.youtube.com/watch?v=Bf85wwJuFBE</a><br><div class="bb_h1">Plug In Digital Sale, up to 90% OFF </div><a class="bb_link" href="https://steamcommunity.com/linkfilter/?url=https://www.indiegala.com/store/publisher-sale/plug-in" target="_blank" rel=" noopener" ><img src="https://cdn.akamai.steamstatic.com/steamcommunity/public/images/clans/3402923/b32c7b4ccd0840128cb9166d11a494dcd25039a6.jpg" /></a><span class="bb_link_host">[www.indiegala.com]</span><br><div class="bb_h1">Dear Villagers Sale, up to 85% OFF</div> <a class="bb_link" href="https://steamcommunity.com/linkfilter/?url=https://www.indiegala.com/store/publisher-sale/dear-villagers" target="_blank" rel=" noopener" ><img src="https://cdn.akamai.steamstatic.com/steamcommunity/public/images/clans/3402923/1f28ca4a99f957ca2241b39ecea82a2813a2e30c.jpg" /></a><span class="bb_link_host">[www.indiegala.com]</span><br><div class="bb_h1">Solo Deal:<a class="bb_link" href="https://steamcommunity.com/linkfilter/?url=https://www.indiegala.com/store/game/lonesome-village/1418360" target="_blank" rel=" noopener" > Lonesome Village</a><span class="bb_link_host">[www.indiegala.com]</span></div><a class="bb_link" href="https://www.youtube.com/watch?v=HBKVO3gv4AU" target="_blank" rel="" >https://www.youtube.com/watch?v=HBKVO3gv4AU</a>


https://steamcommunity.com/groups/indieg...2053400758

Print this item

  News - Get 10TB Of Cloud Storage For A Bargain Price
Posted by: xSicKxBot - 01-16-2023, 04:45 PM - Forum: Lounge - No Replies

Get 10TB Of Cloud Storage For A Bargain Price

<p><span>Cloud storage lets you store and access your files on any device, which really does make it more desirable than local storage for some people. However, cloud storage can be pricey, especially if you go through the biggest names like Google or Microsoft. If you want to ditch the subscription plan storage options, you can </span><span data-embed-type="buylink" data-size="buylink__embed" data-collection="%7B%22text%22:%22get%2010TB%20of%20Prism%20Drive%20cloud%20storage%20right%20now%20for%20only%20$89.%22,%22monetizedUrl%22:%22%22,%22rawUrl%22:%22https://deals.gamespot.com/sales/prism-drive-secure-cloud-storage-lifetime-subscription-10-tb?utm_source=gamespot.com&amp;utm_medium=referral&amp;utm_campaign=prism-drive-secure-cloud-storage-lifetime-subscription-10-tb_081022&amp;utm_term=scsf-553122&amp;utm_content=a0x1P000004lj50QAA&amp;scsonar=1%22%7D" class="norewrite"> <a href="https://deals.gamespot.com/sales/prism-drive-secure-cloud-storage-lifetime-subscription-10-tb?utm_source=gamespot.com&amp;utm_medium=referral&amp;utm_campaign=prism-drive-secure-cloud-storage-lifetime-subscription-10-tb_081022&amp;utm_term=scsf-553122&amp;utm_content=a0x1P000004lj50QAA&amp;scsonar=1">get 10TB of Prism Drive cloud storage right now for only $89.</a> </span><span> </span></p><p>If 10TB sounds like way too much for you, you can get 5TB for $69 or 2TB for only $49.</p><div title="" data-embed-type="buylink" data-ref-id="undefined" data-template="undefined" data-size="buylink__small" data-title="" data-collection="%7B%22text%22:%22See%20at%20GameSpot%20Deals%22,%22monetizedUrl%22:%22%22,%22rawUrl%22:%22https://deals.gamespot.com/sales/prism-drive-secure-cloud-storage-lifetime-subscription-10-tb?utm_source=gamespot.com&amp;utm_medium=referral&amp;utm_campaign=prism-drive-secure-cloud-storage-lifetime-subscription-10-tb_081022&amp;utm_term=scsf-553122&amp;utm_content=a0x1P000004lj50QAA&amp;scsonar=1%22%7D" class="norewrite"> <a href="https://deals.gamespot.com/sales/prism-drive-secure-cloud-storage-lifetime-subscription-10-tb?utm_source=gamespot.com&amp;utm_medium=referral&amp;utm_campaign=prism-drive-secure-cloud-storage-lifetime-subscription-10-tb_081022&amp;utm_term=scsf-553122&amp;utm_content=a0x1P000004lj50QAA&amp;scsonar=1">See at GameSpot Deals</a> </div><p>Prism Drive works just like any other cloud storage solution. You’ll be able to upload any file from just about any device, then access or share them without any hassle. To keep your data safe, you can set up a password before sharing content with friends or family. And if you happen to accidentally delete something important, a 30-day trash history lets you easily restore the file.</p><a href="https://www.gamespot.com/articles/get-10tb-of-cloud-storage-for-a-bargain-price/1100-6504123/?ftag=CAD-01-10abi2f/">Continue Reading at GameSpot</a>

https://www.gamespot.com/articles/get-10...01-10abi2f

Print this item

  [Oracle Blog] Announcing Java Management Service
Posted by: xSicKxBot - 01-15-2023, 03:14 PM - Forum: Java Language, JVM, and the JRE - No Replies

Announcing Java Management Service

Today we are introducing a new Oracle Cloud Infrastructure (OCI) native service to help manage Java runtimes and applications on-premises or on any cloud. Java Management Service (JMS) is now generally available (GA).


https://blogs.oracle.com/java/post/annou...nt-service

Print this item

  [Tut] How I used Python to Automate my Daily Routine with Desktop Notifications
Posted by: xSicKxBot - 01-15-2023, 03:14 PM - Forum: Python - No Replies

How I used Python to Automate my Daily Routine with Desktop Notifications

<div>
<div class="kk-star-ratings kksr-auto kksr-align-left kksr-valign-top" data-payload='{&quot;align&quot;:&quot;left&quot;,&quot;id&quot;:&quot;1058079&quot;,&quot;slug&quot;:&quot;default&quot;,&quot;valign&quot;:&quot;top&quot;,&quot;ignore&quot;:&quot;&quot;,&quot;reference&quot;:&quot;auto&quot;,&quot;class&quot;:&quot;&quot;,&quot;count&quot;:&quot;0&quot;,&quot;legendonly&quot;:&quot;&quot;,&quot;readonly&quot;:&quot;&quot;,&quot;score&quot;:&quot;0&quot;,&quot;starsonly&quot;:&quot;&quot;,&quot;best&quot;:&quot;5&quot;,&quot;gap&quot;:&quot;5&quot;,&quot;greet&quot;:&quot;Rate this post&quot;,&quot;legend&quot;:&quot;0\/5 - (0 votes)&quot;,&quot;size&quot;:&quot;24&quot;,&quot;width&quot;:&quot;0&quot;,&quot;_legend&quot;:&quot;{score}\/{best} - ({count} {votes})&quot;,&quot;font_factor&quot;:&quot;1.25&quot;}'>
<div class="kksr-stars">
<div class="kksr-stars-inactive">
<div class="kksr-star" data-star="1" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
<div class="kksr-star" data-star="2" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
<div class="kksr-star" data-star="3" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
<div class="kksr-star" data-star="4" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
<div class="kksr-star" data-star="5" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
</p></div>
<div class="kksr-stars-active" style="width: 0px;">
<div class="kksr-star" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
<div class="kksr-star" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
<div class="kksr-star" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
<div class="kksr-star" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
<div class="kksr-star" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
</p></div>
</div>
<div class="kksr-legend" style="font-size: 19.2px;"> <span class="kksr-muted">Rate this post</span> </div>
</p></div>
<figure class="wp-block-image size-large is-resized is-style-default"><img loading="lazy" decoding="async" src="https://blog.finxter.com/wp-content/uploads/2023/01/pexels-meruyert-gonullu-6589149-683x1024.jpg" alt="" class="wp-image-1058264" width="498" height="746" srcset="https://blog.finxter.com/wp-content/uploads/2023/01/pexels-meruyert-gonullu-6589149-683x1024.jpg 683w, https://blog.finxter.com/wp-content/uplo...00x300.jpg 200w, https://blog.finxter.com/wp-content/uplo...8x1152.jpg 768w, https://blog.finxter.com/wp-content/uplo...4x1536.jpg 1024w, https://blog.finxter.com/wp-content/uplo...5x2048.jpg 1365w, https://blog.finxter.com/wp-content/uplo...scaled.jpg 1707w" sizes="(max-width: 498px) 100vw, 498px" /></figure>
<h2><strong>Project Description</strong></h2>
<p>Today while working on my Python code, I suddenly realized that it’s been two hours since I have been trying to solve the bug. I was constantly looking at the screen for two hours without even realizing to take a break or drink a glass drink water. That is when I thought of creating a script that would automate my daily routine with desktop notifications. I thought of creating a script that will generate a notification after certain time intervals for the following:</p>
<ul>
<li>Drink 1 glass of water ( notify after every 1 hr)</li>
<li>Take a break from work (after every 1 hr )</li>
<li>Restart work ( after 10 mins of 2nd notification)</li>
<li>Medicine Notification at 10 PM every day</li>
<li>Take backup and end work ( at 8 PM ) every day</li>
</ul>
<p>Therefore, in this project, we will be learning how to automate the daily routine using desktop popup notifications. So, without further delay, let’s dive into the steps to complete our project.</p>
<h2><strong>Step 1: Install and Import the Necessary Libraries</strong></h2>
<p>The two important libraries we need in this project are <code>win10toast</code> and <code>schedule</code>. The <code>win10toast</code> module is used to create the desktop notifications. It notifies us when any event occurs. Since it is not a built-in Python library, therefore you need to install it using <a rel="noreferrer noopener" href="https://blog.finxter.com/how-to-install-pip-on-windows/" target="_blank">PIP</a>. Open your terminal and type the following command – </p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">pip install win10toast</pre>
<p>Once you have installed the win10toast module, go ahead and install the <code>schedule</code> library as follows:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">pip install schedule</pre>
<p><code>Schedule</code> Library helps us to schedule a task at a particular time every day or even on a particular day. It matches our system’s time to the scheduled time set and then calls the <code>command</code> function. You will also need the help of the <code>time</code> module while scheduling the tasks. So, make sure that you also import the <code>time</code> module in your script.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">import win10toast
import schedule import time </pre>
<h2><strong>Step 2: Creating Notifications</strong></h2>
<p>I used the ToastNotifier class from the <code>win10toast</code> module to create an object and the method <code>show_toast</code> to create a notification. The following code will generate a notification that will stay on the screen for 10 seconds.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">noti = win10toast.ToastNotifier()
noti.show_toast("Demo", "You will get a notification", duration = 10)</pre>
<p><strong>Explanation: </strong>The first argument in the <code>show_toast</code> method is the header of the notification and the second argument is the message that you want to display within the notification window. The duration (mentioned in seconds) specifies how long the notification will remain on the desktop screen before disappearing. </p>
<h2><strong>Step 3: Scheduling the Tasks</strong></h2>
<p><strong>Code:</strong></p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">schedule.every().hour.do(water)
schedule.every().hour.do(take_break)
schedule.every(10).to(15).minutes.do(work)
schedule.every().day.at("22:00").do(medicine)
schedule.every().day.at("20:00").do(backup)
while True: schedule.run_pending() time.sleep(1)</pre>
<p><strong>Explanation:</strong> As we need to generate the notifications after certain time intervals we would use the <code>schedule</code> module that will schedule the tasks as per the given/required intervals. We will also use the <code>sleep</code> method from the <code>time</code> module, to let the next line of code execute after some time specified in seconds.</p>
<h2><strong>Step 4: Creating the Task Functions</strong></h2>
<p>Next, I created different functions that will perform different tasks when called. The function to remind me to:</p>
<ul>
<li><strong>Drink a glass of water every 1 hour is as follows:</strong></li>
</ul>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">def water(): noti.show_toast('Time to drink water!', duration= 10)</pre>
<ul>
<li><strong>Take a break from work (after every 1 hr )</strong></li>
</ul>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">def take_break(): noti.show_toast('You have been working since one hour. Time to take a break', duration= 10)</pre>
<ul>
<li><strong>Restart work ( after 10 mins of 2nd notification)</strong></li>
</ul>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">def work(): noti.show_toast('Restart your work', duration= 10)</pre>
<ul>
<li><strong>Medicine Notification at 10 PM every day</strong></li>
</ul>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">def medicine(): noti.show_toast('Time to take the medicine', duration= 15)</pre>
<ul>
<li><strong>Take backup and end work ( at 8 PM ) every day</strong></li>
</ul>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">def backup(): noti.show_toast('Take backup and end work', duration= 15)</pre>
<h2><strong>Putting it All Together</strong></h2>
<p>Now let’s put it all together to visualize how the entire script works :</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">import win10toast
import schedule import time noti = win10toast.ToastNotifier() def water(): noti.show_toast('Time to drink water!', duration= 10) def take_break(): noti.show_toast('You have been working since one hour. Time to take a break', duration= 10) def work(): noti.show_toast('Restart your work', duration= 10) def medicine(): noti.show_toast('Time to take the medicine', duration= 15) def backup(): noti.show_toast('Take backup and end work', duration= 15) schedule.every().hour.do(water)
schedule.every().hour.do(take_break)
schedule.every(10).to(15).minutes.do(work)
schedule.every().day.at("22:00").do(medicine)
schedule.every().day.at("20:00").do(backup) while True: schedule.run_pending() time.sleep(1)
</pre>
<h2><strong>Conclusion</strong></h2>
<p>There we go! We have successfully created a wonderful automated script that will generate notifications for us, giving us prompts at certain intervals to organize our work and daily routine. I hope this project added some value and helped you in your coding quest. Stay tuned and <strong><a rel="noreferrer noopener" href="https://blog.finxter.com/subscribe/" target="_blank">subscribe</a></strong> for more interesting projects and tutorials.</p>
<p>Do you love automating tasks with Python? Well! I do. And if you are someone who likes automation then here’s a list of few mini projects that will get you going –</p>
<ul>
<li><a href="https://blog.finxter.com/create-your-own-youtube-video-downloader/"><strong>Create Your Own YouTube Video Downloader</strong></a></li>
<li> <strong><a href="https://blog.finxter.com/the-power-of-automation-using-python-segregating-images-based-on-dimensions/" target="_blank" rel="noreferrer noopener">The Power of Automation Using Python – Segregating Images Based on Dimensions</a></strong></li>
<li><strong><a href="https://blog.finxter.com/automate-backup-to-google-drive-with-python/" target="_blank" rel="noreferrer noopener">Automate Backup to Google Drive with Python</a></strong></li>
<li><strong><a href="https://blog.finxter.com/receive-automated-email-notification-on-website-update/" target="_blank" rel="noreferrer noopener">Receive Automated Email Notification on Website Update</a></strong></li>
<li><strong><a href="https://blog.finxter.com/the-art-of-automating-whatsapp-messages-using-python/" target="_blank" rel="noreferrer noopener">The Art of Automating Whatsapp Messages Using Python</a></strong></li>
<li><strong><a href="https://blog.finxter.com/create-your-own-youtube-video-downloader/" target="_blank" rel="noreferrer noopener">Create Your Own YouTube Video Downloader</a></strong></li>
</ul>
<hr class="wp-block-separator has-alpha-channel-opacity" />
</div>


https://www.sickgaming.net/blog/2023/01/...fications/

Print this item

  (Indie Deal) GameMill & Games Operators Sales
Posted by: xSicKxBot - 01-15-2023, 03:13 PM - Forum: Deals or Specials - No Replies

GameMill & Games Operators Sales

<div class="bb_h1">Dear Villagers Giveaways</div><a class="bb_link" href="https://steamcommunity.com/linkfilter/?url=https://www.indiegala.com/giveaways" target="_blank" rel=" noopener" ><img src="https://cdn.akamai.steamstatic.com/steamcommunity/public/images/clans/3402923/19636eb22c22a29f3dfd4f9fefddafa01ffe13ec.jpg" /></a><span class="bb_link_host">[www.indiegala.com]</span><br><br><div class="bb_h1">New Release: <a class="bb_link" href="https://steamcommunity.com/linkfilter/?url=https://www.indiegala.com/store/game/children-of-silentown/1108000" target="_blank" rel=" noopener" >Children of Silentown</a><span class="bb_link_host">[www.indiegala.com]</span></div><a class="bb_link" href="https://www.youtube.com/watch?v=a9Loe-qYGck" target="_blank" rel="" >https://www.youtube.com/watch?v=a9Loe-qYGck</a><br><div class="bb_h1">GameMill Entertainment Sale, up to 90% OFF</div><a class="bb_link" href="https://steamcommunity.com/linkfilter/?url=https://www.indiegala.com/store/publisher-sale/gamemill" target="_blank" rel=" noopener" ><img src="https://cdn.akamai.steamstatic.com/steamcommunity/public/images/clans/3402923/5c9a12e7298dfc6b6e005ddb5adf140ce475b08c.jpg" /></a><span class="bb_link_host">[www.indiegala.com]</span><br><div class="bb_h1">Games Operators Sale, up to 80% OFF Sale, up to 80% OFF</div><a class="bb_link" href="https://steamcommunity.com/linkfilter/?url=https://www.indiegala.com/store/publisher-sale/games-operators" target="_blank" rel=" noopener" ><img src="https://cdn.akamai.steamstatic.com/steamcommunity/public/images/clans/3402923/d3af70eaf6457e1b91d35a0ed5af12217b1ce9f4.jpg" /></a><span class="bb_link_host">[www.indiegala.com]</span><br><div class="bb_h1"><a class="bb_link" href="https://store.steampowered.com/app/1874190/Vorax/" target="_blank" rel="" >New Vorax Video</a></div><a class="bb_link" href="https://youtu.be/Lm0cWNUUrjQ" target="_blank" rel="" >https://youtu.be/Lm0cWNUUrjQ</a>


https://steamcommunity.com/groups/indieg...2050509755

Print this item

  [Oracle Blog] Prepare for the Migration to JDK 9
Posted by: xSicKxBot - 01-14-2023, 10:35 AM - Forum: Java Language, JVM, and the JRE - No Replies

Prepare for the Migration to JDK 9 

The release date is proposed for September 21, 2017 and it’s time to make sure your code will work with JDK 9. As you probably know, you will still be able to use the classpath and code with any official Java SE APIs and supported JDK-specific APIs. You will run into problems if your code uses certa...


https://blogs.oracle.com/java/post/prepa...n-to-jdk-9

Print this item

  [Tut] Project – React dApp for Selling eBooks in a Decentralized Manner (1/4)
Posted by: xSicKxBot - 01-14-2023, 10:35 AM - Forum: Python - No Replies

Project – React dApp for Selling eBooks in a Decentralized Manner (1/4)

<div>
<div class="kk-star-ratings kksr-auto kksr-align-left kksr-valign-top" data-payload='{&quot;align&quot;:&quot;left&quot;,&quot;id&quot;:&quot;1055370&quot;,&quot;slug&quot;:&quot;default&quot;,&quot;valign&quot;:&quot;top&quot;,&quot;ignore&quot;:&quot;&quot;,&quot;reference&quot;:&quot;auto&quot;,&quot;class&quot;:&quot;&quot;,&quot;count&quot;:&quot;2&quot;,&quot;legendonly&quot;:&quot;&quot;,&quot;readonly&quot;:&quot;&quot;,&quot;score&quot;:&quot;5&quot;,&quot;starsonly&quot;:&quot;&quot;,&quot;best&quot;:&quot;5&quot;,&quot;gap&quot;:&quot;5&quot;,&quot;greet&quot;:&quot;Rate this post&quot;,&quot;legend&quot;:&quot;5\/5 - (2 votes)&quot;,&quot;size&quot;:&quot;24&quot;,&quot;width&quot;:&quot;142.5&quot;,&quot;_legend&quot;:&quot;{score}\/{best} - ({count} {votes})&quot;,&quot;font_factor&quot;:&quot;1.25&quot;}'>
<div class="kksr-stars">
<div class="kksr-stars-inactive">
<div class="kksr-star" data-star="1" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
<div class="kksr-star" data-star="2" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
<div class="kksr-star" data-star="3" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
<div class="kksr-star" data-star="4" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
<div class="kksr-star" data-star="5" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
</p></div>
<div class="kksr-stars-active" style="width: 142.5px;">
<div class="kksr-star" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
<div class="kksr-star" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
<div class="kksr-star" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
<div class="kksr-star" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
<div class="kksr-star" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
</p></div>
</div>
<div class="kksr-legend" style="font-size: 19.2px;"> 5/5 – (2 votes) </div>
</p></div>
<p>Welcome to another project of a decentralized dapp with <a href="https://blog.finxter.com/learn-to-build-smart-contracts-in-react-with-web3-js-heres-how-1-2/" data-type="post" data-id="978706" target="_blank" rel="noreferrer noopener">React</a> and <code><a href="https://blog.finxter.com/i-created-a-counter-smart-contract-with-ether-js-heres-how/" data-type="post" data-id="1002304" target="_blank" rel="noreferrer noopener">ether.js</a></code>.</p>
<figure class="wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube"><a href="https://blog.finxter.com/project-react-dapp-for-selling-ebooks-in-a-decentralized-manner-1-4/"><img src="https://blog.finxter.com/wp-content/plugins/wp-youtube-lyte/lyteCache.php?origThumbUrl=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fk9FWq9hTYiA%2Fhqdefault.jpg" alt="YouTube Video"></a><figcaption></figcaption></figure>
<h2>Project Scenario</h2>
<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="1019" height="679" src="https://blog.finxter.com/wp-content/uploads/2023/01/image-122.png" alt="" class="wp-image-1055400" srcset="https://blog.finxter.com/wp-content/uploads/2023/01/image-122.png 1019w, https://blog.finxter.com/wp-content/uplo...00x200.png 300w, https://blog.finxter.com/wp-content/uplo...68x512.png 768w" sizes="(max-width: 1019px) 100vw, 1019px" /></figure>
</div>
<p>We will build an ebook stall from which anyone can buy an ebook on a monthly subscription basis. </p>
<p>The buyer will submit his name, the book’s name, and the writer’s name at the time of buying the subscription. When he pays for the subscription, the subscription fee will be added to the bookstall owner’s account, and at the same time, the system will debit the transaction fee from the buyer’s account. </p>
<p>Apart from this, the details info of the buyer will be displayed on the user interface. The information includes the buyer’s name, wallet address, transaction time, book, and writer’s name.</p>
<h2>Technology</h2>
<p>We will use <code>react.js</code> and tailwind CSS in the frontend, <a href="https://blog.finxter.com/solidity-crash-course/" data-type="post" data-id="445146" target="_blank" rel="noreferrer noopener">Solidity</a> for writing the smart contract, Ether.js for interacting with the smart contract, and the hardhat for smooth development.</p>
<h2>Initiate Hardhat</h2>
<p>Hardhat is arguably the best <a href="https://blog.finxter.com/ethereum-top-10-articles-to-get-started/" data-type="post" data-id="53284" target="_blank" rel="noreferrer noopener">Ethereum</a> development environment to compile your contracts and run them on a development network. To install the hardhat, open the <code>vscode</code> terminal and just type</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">npm install –save-dev hardhat</pre>
<p>Hardhat will be installed on the directory. Now run hardhat.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">npx hardhat</pre>
<p>The command prompt will ask for creating a <a rel="noreferrer noopener" href="https://blog.finxter.com/javascript-developer-income-and-opportunity/" data-type="post" data-id="191233" target="_blank">JavaScript</a> project. Approve it. You need to install some dependencies to run the project. Copy this from the terminal and run. All the extra dependencies will be installed.</p>
<p>Create a new <a href="https://blog.finxter.com/layout-of-a-solidity-source-file-spdx-license-identifier-and-version-pragmas/" data-type="post" data-id="703612" target="_blank" rel="noreferrer noopener">Solidity file</a> inside the contract folder. “<code>bookSell.sol</code>“. We will be writing all the code here.</p>
<h2>Build Solidity Smart Contract</h2>
<div class="wp-block-image">
<figure class="aligncenter size-full"><img decoding="async" loading="lazy" width="1019" height="764" src="https://blog.finxter.com/wp-content/uploads/2023/01/image-123.png" alt="" class="wp-image-1055401" srcset="https://blog.finxter.com/wp-content/uploads/2023/01/image-123.png 1019w, https://blog.finxter.com/wp-content/uplo...00x225.png 300w, https://blog.finxter.com/wp-content/uplo...68x576.png 768w" sizes="(max-width: 1019px) 100vw, 1019px" /></figure>
</div>
<p>I will create a simple and quick smart contract. This smart contract is basically for inputting the name, Book name, writer’s name, buyer address, the timing of issuing the order, etc.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">pragma solidity >= 0.5.0 &lt; 0.9.0;
contract BookSell{ address payable owner; constructor(){ owner = payable(msg.sender); } struct Receipt{ uint256 timestamp ; string name; address buyer; string book; string writer; } Receipt[] receipts; function buyBook(string memory name, string memory book, string memory writer) public payable{ require(msg.value>0,"Payment is not acceptable"); owner.transfer(msg.value); receipts.push(Receipt(block.timestamp, name, msg.sender,book, writer)); } function getReceipts() public view returns(Receipt[] memory) { return receipts; }
}
</pre>
<div class="wp-block-image">
<figure class="aligncenter size-full"><img decoding="async" loading="lazy" width="624" height="336" src="https://blog.finxter.com/wp-content/uploads/2023/01/image-116.png" alt="" class="wp-image-1055383" srcset="https://blog.finxter.com/wp-content/uploads/2023/01/image-116.png 624w, https://blog.finxter.com/wp-content/uplo...00x162.png 300w" sizes="(max-width: 624px) 100vw, 624px" /></figure>
</div>
<p>First, we need to confirm the address of the owner of the bookstall. This address will be <code><a href="https://blog.finxter.com/what-is-payable-in-solidity/" data-type="post" data-id="37282" target="_blank" rel="noreferrer noopener">payable</a></code> cause it will receive the money of the buyers.</p>
<p>Create a constructor for the owner. “<code>msg.sender</code>” will be the owner in this case. <code>msg.sender</code> is normally the address that is used to deploy the contract. The person or the account that deploys the contract is normally the contract owner and will receive the transaction on his account.</p>
<p>Create a <a rel="noreferrer noopener" href="https://blog.finxter.com/solidity-reference-types-array-slices-and-structs/" data-type="post" data-id="829701" target="_blank">struct</a> “<code>Receipt</code>” with three strings, that is,</p>
<ul>
<li>“<code>name</code>” for the buyer’s name, </li>
<li>“<code>book</code>” for the book buyers want to buy, and </li>
<li>“<code>writer</code>” for the writer of the book. </li>
</ul>
<p>The timestamp would be an unsigned integer to note down the time and an address to collect the buyer’s account address.</p>
<p>To store the data of several buyers, I created a “<code>receipts</code>” <a href="https://blog.finxter.com/solidity-array-members-and-manipulation-techniques/" data-type="post" data-id="830098" target="_blank" rel="noreferrer noopener">array</a>. It is a dynamic array, which means whenever a new buyer inputs his information, the receipt will be added dynamically to the receipts array.</p>
<p><a href="https://blog.finxter.com/solidity-function-type-examples-a-simple-illustrated-guide/" data-type="post" data-id="830464" target="_blank" rel="noreferrer noopener">Create a function</a> to buy the book. This <code>buyBook</code> function will take the information of the buyer as the parameters. The information includes the buyer’s name, book, and writer’s name. This function will also be <code>payable</code> cause we will use this to transfer money to the owner’s address.</p>
<p>Buyers must not pay zero eth as an amount. That’s why we added a condition with the “<code>require</code>” method. “<code>msg.value</code>” is the amount the buyer spends to buy the book.</p>
<p>“<code>owner.transfer(msg.value)</code>” is used to transfer the fund to the stall owner’s account.</p>
<p>When the transaction is done, add the transaction receipt to the receipts array with the help of the push method. Since the receipts array is a struct type of array, you can input the required fields as the parameter of receipt.</p>
<p>To get the information from the receipts, we created a <code>getReceipts()</code> function. This returns the receipt of each buyer when we call the function.</p>
<h2>Test the Smart Contract</h2>
<div class="wp-block-image">
<figure class="aligncenter size-full"><img decoding="async" loading="lazy" width="1019" height="679" src="https://blog.finxter.com/wp-content/uploads/2023/01/image-124.png" alt="" class="wp-image-1055403" srcset="https://blog.finxter.com/wp-content/uploads/2023/01/image-124.png 1019w, https://blog.finxter.com/wp-content/uplo...00x200.png 300w, https://blog.finxter.com/wp-content/uplo...68x512.png 768w" sizes="(max-width: 1019px) 100vw, 1019px" /></figure>
</div>
<p>Before deploying the contract, we need to check if all the functionalities of the <a href="https://blog.finxter.com/smart-contracts-discover-how-to-create-them-directly-and-indirectly/" data-type="post" data-id="978963" target="_blank" rel="noreferrer noopener">smart contract</a> are working properly or not. Hardhat has its own node and tools for checking the smart contract. We will first deploy our smart contract on the hardhat node to check its functionality and then deploy it to our testnet.</p>
<p>Move inside the <code>deploy.js</code>. We will create several functions here for different purposes.</p>
<p>We need to generate some accounts for the transaction. Inside the <code>async main()</code> function, generate account addresses with the help of the <code>getSigners()</code> method of <code>ether.js</code>. One account is for the contract owner, and the other three are for different buyers.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">const [owner, buyer1, buyer2, buyer3] = await hre.ethers.getSigners();</pre>
<p>Hardhat will generate four accounts with the help of ether modules. Each account will have 1000 eth by default. We can use that at the time of the transaction for testing purposes.</p>
<p>Create an addresses array to store all the addresses together.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">const addresses = [ owner.address, buyer1.address, buyer2.address, buyer3.address, ];
</pre>
<p>Now to get the balances of those addresses, we will create <code>obtainBalance()</code> function outside the main <code>function()</code></p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">const obtainBalance = async (address) => { const balanceBigInt = await hre.ethers.provider.getBalance(address); return hre.ethers.utils.formatEther(balanceBigInt);
};
</pre>
<p>This <code>obtainBalance()</code> function will take an address from the addresses array, and it will use the <code>getBalance()</code> method of the <code>ethers.provider</code> to get the balance.</p>
<p>We will get the output as a Big Int object, and we need to convert it to get the actual number. The <code>formatEther()</code> method of the <code>utils</code> library converts the big int object into a readable format.</p>
<p><strong>Reference</strong>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt" target="_blank" rel="noreferrer noopener">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt</a></p>
<div class="wp-block-image">
<figure class="aligncenter size-full"><img decoding="async" loading="lazy" width="624" height="345" src="https://blog.finxter.com/wp-content/uploads/2023/01/image-117.png" alt="" class="wp-image-1055385" srcset="https://blog.finxter.com/wp-content/uploads/2023/01/image-117.png 624w, https://blog.finxter.com/wp-content/uplo...00x166.png 300w" sizes="(max-width: 624px) 100vw, 624px" /></figure>
</div>
<p>Now we will create another function to loop through the addresses, and it will also show the balances on the console.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">const printBalances = async (addresses) => { let id = 0; for (const address of addresses) { console.log(`Account ${id} Balance:`, await obtainBalance(address)); id++; }
};
</pre>
<p>The “<code>for</code>” loop is used to loop through all the addresses of the array. While looping, the <code>obtainBalance()</code> function will get the balance from each account. An <code>id</code> variable is used to mark each account with a unique id.</p>
<p>Apart from that, we want to see the receipt for each buyer. Let’s create a <code>printReceipt()</code> function to get the receipt.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">const printReceipts = async (receipts) => { for (const receipt of receipts) { const timestamp = receipt.timestamp; const name = receipt.name; const buyer = receipt.buyer; const book = receipt.book; const writer = receipt.writer; console.log( `Buyer Details: Name:${name},Book:${book},Writer:${writer},Address:${buyer},Time:${timestamp}` ); }
};
</pre>
</p>
<p>The <code>printReceipts()</code> function initiates a for loop that will loop through all the receipts of the receipts array. Then it will show all the buyer’s details from the receipt that will be called.</p>
<p>Now we need to call the receipts array from the smart contract. Otherwise, it won’t be possible to get data from the contract. Create an instance of the smart contract inside the <code>main()</code> function.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""> const bookSell = await hre.ethers.getContractFactory("BookSell"); const contract = await bookSell.deploy(); //instance of the contract
</pre>
<p>With the first line of code, we called smart contract with the <code>getContractFactory()</code> method of the <code>ethers</code> library. Then we created an instance of the smart contract in the second line.</p>
<p>Now we can call the functions of the smart contract from here.</p>
<div class="wp-block-image">
<figure class="aligncenter size-full"><img decoding="async" loading="lazy" width="624" height="309" src="https://blog.finxter.com/wp-content/uploads/2023/01/image-118.png" alt="" class="wp-image-1055386" srcset="https://blog.finxter.com/wp-content/uploads/2023/01/image-118.png 624w, https://blog.finxter.com/wp-content/uplo...00x149.png 300w" sizes="(max-width: 624px) 100vw, 624px" /></figure>
</div>
<p>Let’s say we want to check the accounts’ balances first. Let’s <a href="https://blog.finxter.com/javascript-intro-how-to-see-your-code-output/" data-type="post" data-id="175068" target="_blank" rel="noreferrer noopener">console log</a> the balance on the terminal with the help of <code>printBalance()</code> method that we created earlier.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""> console.log("Initial Balance:"); printBalances(addresses);
</pre>
<p>Assume we want to send some balance to the owner’s address for buying books. Fix the amount we want to transfer</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""> const amount = { value: hre.ethers.utils.parseEther("1") }; await contract .connect(buyer1) .buyBook("Adam", "Miracle Morning", "Hal Elrod", amount); await contract .connect(buyer2) .buyBook("Mike", "The Slight Edge", "Jeff Olson", amount); await contract .connect(buyer3) .buyBook("Peter", "Loving what is", "Byron Katie", amount);
</pre>
<div class="wp-block-image">
<figure class="aligncenter size-full"><img decoding="async" loading="lazy" width="624" height="470" src="https://blog.finxter.com/wp-content/uploads/2023/01/image-119.png" alt="" class="wp-image-1055387" srcset="https://blog.finxter.com/wp-content/uploads/2023/01/image-119.png 624w, https://blog.finxter.com/wp-content/uplo...00x226.png 300w" sizes="(max-width: 624px) 100vw, 624px" /></figure>
</div>
<p>We fixed an amount, one eth, to transfer from all the buyer’s addresses. We used the <code>parseEther()</code> method of the <code>utils</code> library to fix the value.</p>
<p>In the next few lines, we called the contract and established a connection with the buyer’s address. We also called the <code>buyBook</code> method of the smart contract to buy the books.</p>
<p>Inside the <code>buyBook</code> function we passed the buyer address, the book name, the writer name, and the amount as the parameter. For simplicity, we are sending the same amount from all the buyer’s accounts.</p>
<p>To check the balances after buying the book, we will call the <code>printBalance()</code> method again. </p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""> console.log("Last Balance:"); await printBalances(addresses);
</pre>
<p>We forgot to call the receipts array from the smart contract. We will use the <code>getReceipts()</code> methods from the smart contract to get the receipts.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""> const receipts = await contract.getReceipts(); printReceipts(receipts);
}
</pre>
<p>Now. Let’s deploy the contract on the hardhat and check how it works.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""> await contract.deployed(); console.log("Contract Address:", contract.address);
</pre>
<p>I deployed the contract in the first line and then asked for the contract address.</p>
<p>Let’s move to the terminal and run the script.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">npx hardhat run scripts/deploy.js</pre>
<p>Don’t forget to mention the directory of the file on the code.</p>
<div class="wp-block-image">
<figure class="aligncenter size-full"><img decoding="async" loading="lazy" width="624" height="186" src="https://blog.finxter.com/wp-content/uploads/2023/01/image-120.png" alt="" class="wp-image-1055388" srcset="https://blog.finxter.com/wp-content/uploads/2023/01/image-120.png 624w, https://blog.finxter.com/wp-content/uplo...300x89.png 300w" sizes="(max-width: 624px) 100vw, 624px" /></figure>
</div>
<p>I got these results on my terminal after running the scripts. You can see from here that initially, the balances of all the accounts were 10000 eth. But after the transaction, more than one eth was deducted from each of the last three accounts. </p>
<p>It took more than one eth because of the transaction fee. At the same time, we can see the owner’s account (Account 0) is credited with exactly three eth.</p>
<p>In the last part, we also gathered all the info from the buyer’s receipt, including the time of the transaction and the address of the buyer.</p>
<h2>Thanks for Reading <img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2665.png" alt="♥" class="wp-smiley" style="height: 1em; max-height: 1em;" /></h2>
<p>That’s all for today. You have learned how to build and test a smart contract. In the next part, we will deploy the smart contract on a testnet.</p>
<p><strong>GitHub</strong>: <a rel="noreferrer noopener" href="https://github.com/yassesh/bookSell" target="_blank">https://github.com/yassesh/bookSell</a></p>
</div>


https://www.sickgaming.net/blog/2023/01/...anner-1-4/

Print this item

  (Indie Deal) FREE Six Sides of the World, Friday 13 Bundle & more
Posted by: xSicKxBot - 01-14-2023, 10:35 AM - Forum: Deals or Specials - No Replies

FREE Six Sides of the World, Friday 13 Bundle & more

<div class="bb_h1">Friday 13 Bundle | 8 Steam Games | 93% OFF</div><a class="bb_link" href="https://steamcommunity.com/linkfilter/?url=https://www.indiegala.com/bundle/friday13-bundle" target="_blank" rel=" noopener" ><img src="https://cdn.akamai.steamstatic.com/steamcommunity/public/images/clans/3402923/13fe2ce02e5f063feca620a961f9ea9ca83a425a.jpg" /></a><span class="bb_link_host">[www.indiegala.com]</span><br>Even if it may not seem like it, this might be your lucky day. A new bundle full of TDs, crafting &amp; more: Forest Tower Defense, The King's Castle, Let's Park Backyard Edition, Tuk Tuk Extreme Simulator, Save the Girl, Supreme Race on Highway, ConflictCraft 2 &amp; Ambulance Chauffeur Simulator<br><br><div class="bb_h1"><a class="bb_link" href="https://steamcommunity.com/linkfilter/?url=https://www.indiegala.com/store/game/one-piece-odyssey/814000_pre" target="_blank" rel=" noopener" >ONE PIECE ODYSSEY is out!</a><span class="bb_link_host">[www.indiegala.com]</span></div><a class="bb_link" href="https://www.youtube.com/watch?v=GHXtyxULPX0" target="_blank" rel="" >https://www.youtube.com/watch?v=GHXtyxULPX0</a><br><div class="bb_h1">Six Sides of the World FREEbie</div><a class="bb_link" href="https://steamcommunity.com/linkfilter/?url=https://freebies.indiegala.com/six-sides-of-the-world" target="_blank" rel=" noopener" ><img src="https://cdn.akamai.steamstatic.com/steamcommunity/public/images/clans/3402923/a9599b4bbe9f7d06028ff63af7765d20a0ff826b.jpg" /></a><span class="bb_link_host">[freebies.indiegala.com]</span><br><br><div class="bb_h1"><a class="bb_link" href="https://store.steampowered.com/app/1874190/Vorax/" target="_blank" rel="" >Development Update #7</a></div><a class="bb_link" href="https://store.steampowered.com/news/app/1874190/view/6134499240267988681" target="_blank" rel="" ><img src="https://cdn.akamai.steamstatic.com/steamcommunity/public/images/clans/3402923/cfa18121c6729c2a1a0539e34a1c9bbbb57101a3.jpg" /></a><br><br><div class="bb_h1">Blowfish Studios Sale, up to 80% OFF</div><a class="bb_link" href="https://steamcommunity.com/linkfilter/?url=https://www.indiegala.com/store/publisher-sale/blowfish-studios" target="_blank" rel=" noopener" ><img src="https://cdn.akamai.steamstatic.com/steamcommunity/public/images/clans/3402923/c21e8541a40947537350fdaf9a49fbd5d4e6bfcd.jpg" /></a><span class="bb_link_host">[www.indiegala.com]</span><br><a class="bb_link" href="https://steamcommunity.com/linkfilter/?url=https://discord.gg/7makUkMXvP" target="_blank" rel=" noopener" ><img src="https://cdn.cloudflare.steamstatic.com/steamcommunity/public/images/clans/3402923/8657f35d7afa3d480c08a7625f4ea2597a9505be.png" /></a><span class="bb_link_host">[discord.gg]</span>


https://steamcommunity.com/groups/indieg...2046503497

Print this item

 
Latest Threads
(Indie Deal) Blasphemous ...
Last Post: xSicKxBot
4 hours ago
News - Razer Face Mask Di...
Last Post: xSicKxBot
4 hours ago
News - Baldur's Gate 3 Co...
Last Post: xSicKxBot
Yesterday, 01:44 PM
(Indie Deal) Tiny Tina's ...
Last Post: xSicKxBot
05-04-2024, 09:17 PM
News - Razer Face Mask Di...
Last Post: xSicKxBot
05-04-2024, 09:17 PM
(Indie Deal) New Bundle i...
Last Post: xSicKxBot
05-04-2024, 04:07 AM
(Free Game Key) Cat Quest...
Last Post: xSicKxBot
05-04-2024, 04:07 AM
News - ESRB Rating For Ni...
Last Post: xSicKxBot
05-04-2024, 04:07 AM
(Indie Deal) Cherry Kiss ...
Last Post: xSicKxBot
05-03-2024, 11:42 AM
News - Take-Two Reportedl...
Last Post: xSicKxBot
05-03-2024, 11:41 AM

Forum software by © MyBB Theme © iAndrew 2016