teleren/devto huggingface dataset:
How to use argparse with python
Tags: python, argparse
Published: 2022-12-26 00:06:44

---
title: How to use argparse with python
published: true
date: 2023-04-21 13:00:00 UTC
tags: ["python", "argparse"]
canonical_url: https://friendlyuser.github.io/posts/tech/scripting/argparse_with_python/
---

argparse is a Python module that makes it easy to write command-line interfaces. It allows you to specify the arguments that your program should accept in a clean and organized way, and it takes care of handling the input and output for you.

Here's an example of how to use argparse to parse command-line arguments in a Python script:


```python
argparse is a Python module that makes it easy to write command-line interfaces. It allows you to specify the arguments that your program should accept in a clean and organized way, and it takes care of handling the input and output for you.

Here's an example of how to use argparse to parse command-line arguments in a Python script:
```

This script defines a single command-line argument, --sum, which specifies whether the program should sum or find the maximum of the integers. If the --sum argument is not provided, the default action is to find the maximum.

To run this script, you would type something like python script.py 1 2 3 --sum at the command line. This would cause the script to print 6, which is the sum of the integers 1, 2, and 3.

Here's an example of how you might use argparse to write a command-line interface for a program that keeps track of the books that a bear has read:

```python
import argparse

parser = argparse.ArgumentParser(description='Bear book tracker')

# Add a command to add a book to the bear's reading list
parser.add_argument('--add', dest='book', type=str,
                    help='add a book to the reading list')

# Add a command to list the books that the bear has read
parser.add_argument('--list', action='store_true',
                    help='list the books that the bear has read')

# Parse the arguments
args = parser.parse_args()

# Initialize an empty list to store the bear's books
books = []

# If the --add argument was provided, add the book to the list
if args.book:
    books.append(args.book)

# If the --list argument was provided, print the list of books
if args.list:
    print("Bear's books:")
    for book in books:
        print(book)

```

To use this program, you would type something like python book_tracker.py --add "The Giving Tree" to add a book to the bear's reading list, or python book_tracker.py --list to view the list of books.

I hope this helps give you a basic understanding of how argparse works! Let me know if you have any questions.
How to Implement API Client-Side Rate Limiting in C#
Tags: csharp, api, ratelimiting, developertips
Published: 2023-04-21 12:39:37

Learn how to efficiently manage API requests and avoid hitting limits with practical examples. 
[How to Implement API Client-Side Rate Limiting in C#](https://devedium.com/how-to-implement-api-client-side-rate-limiting-in-c-f91202da2112)
How to Clean Up ASP.NET and Visual Studio Cache and Temp Files
Tags: csharp, webdev, tooling
Published: 2023-04-21 12:14:28

ASP.NET and Visual Studio are powerful tools for web application development, but like any software, they can generate temporary files and caches that can accumulate over time and take up valuable disk space. These files can also slow down the performance of your development environment, which can be frustrating when you're trying to get work done quickly. In this blog post, we'll show you how to clean up your ASP.NET and Visual Studio cache and temp files to help keep your development environment running smoothly.

## Why should you clean up your cache and temp files?

Over time, your cache and temp files can accumulate and take up a significant amount of disk space. This can cause your computer to slow down or even crash. By cleaning up these files regularly, you can help improve the performance of Visual Studio and ensure that your development environment is working as intended.

## How to clean up your ASP.NET and Visual Studio cache and temp files

Now that we understand the importance of cleaning up your cache and temp files, let's dive into the process of doing so. Here are the steps you can follow:

**Step 1**: Close Visual Studio and stop any ASP.NET applications that are currently running.

**Step 2**: Navigate to the following folders and delete all files and folders within them:

- %SYSTEMROOT%\Microsoft.NET\Framework[64]\<vernum>\Temporary ASP.NET Files
- %USERPROFILE%\AppData\Local\Microsoft\WebsiteCache
- %USERPROFILE%\AppData\Local\Microsoft\VisualStudio\BackupFiles
- %USERPROFILE%\AppData\Local\Microsoft\VisualStudio\[version number]\ProjectAssemblies

Note: Depending on your version of Visual Studio, the folder names may differ slightly.

**Step 3**: Restart Visual Studio and any ASP.NET applications that you stopped in Step 1.

That's it! By following these steps, you should have successfully cleaned up your ASP.NET and Visual Studio cache and temp files. You may notice that your development environment is running more smoothly, and you may have freed up some valuable disk space as well.

## Conclusion

In conclusion, cleaning up your cache and temp files is an important step in maintaining the health and performance of your computer and development environment. By doing so regularly, you can help ensure that your software tools are working as intended and that you're able to get your work done quickly and efficiently.
Engineering onboarding is not black and white
Tags: engineering, workplace, onboard
Published: 2023-04-21 12:01:46

[Onboarding, by definition, is the process of socializing new employees and enabling them to integrate into the organization](https://en.wikipedia.org/wiki/Onboarding).

Different companies have implemented different mechanisms for this purpose, but in almost all cases, I have observed that companies are trying to onboard different people with the same approach.

Based on different researches we know that _[humans are diverse](https://blackwells.co.uk/bookshop/product/9780815356547?gC=S6Rn6r8CVz&gclid=CjwKCAjw6IiiBhAOEiwALNqncdYh4H5-57LdKMvtqmldVrKUDZOVa2kiY3FRTV1OAJAIP4d3KVDsXxoCpzQQAvD_BwE)_ ,_[they come from different cultures](https://www.amazon.de/-/en/Erin-Meyer/dp/1610392760)_ ,_[are full of emotions](https://www.amazon.de/Descartes-Error-Emotion-Reason-Human/dp/0099501643/ref=asc_df_0099501643/?tag=googshopde-21&linkCode=df0&hvadid=310624385412&hvpos=&hvnetw=g&hvrand=338278338433860474&hvpone=&hvptwo=&hvqmt=&hvdev=c&hvdvcmdl=&hvlocint=&hvlocphy=9061136&hvtargid=pla-452474035666&psc=1&th=1&psc=1&tag=&ref=&adgrpid=64536883649&hvpone=&hvptwo=&hvadid=310624385412&hvpos=&hvnetw=g&hvrand=338278338433860474&hvqmt=&hvdev=c&hvdvcmdl=&hvlocint=&hvlocphy=9061136&hvtargid=pla-452474035666)_ and _[humans exhibit biases in their thinking](https://www.amazon.de/-/en/Mahzarin-R-Banaji/dp/0345528433)_. 

If we take these researches into consideration then this raises the question that, 

> Is there one solution which can onboard everyone ?

In my upcoming blog post, I will endeavor to elucidate the distinction between onboarding processes that are guided by checklists versus those that are centered around a clear purpose or goal.
Show active navigation link in JavaScript
Tags: javascript, beginners, webdev, tutorial
Published: 2023-04-21 11:52:06

Two options to show the active nav link: first with an active class or second with the aria-current="page" attribute. We have a simple navigation consisting of 3 links and 3 seperate HTML pages. Some basic CSS styling with a hover action that changes the color or the link. We will use the same hover styling for the active nav link.

{% youtube bEOwXmd9Mc8 %}
How to Write Security Rules for Firebase FireStore?
Tags: firebase, beginners, programming, tutorial
Published: 2023-04-21 11:41:08

Firebase Firestore is a popular NoSQL document database widely used by developers to build scalable and flexible web and mobile applications.

While Firestore provides powerful features for data management, it is also essential to ensure the security of your data to prevent unauthorized access, data breaches, and other security threats.

We will discuss essential rules for securing your Firestore database.

By implementing these security measures, you can ensure the safety and privacy of your data and protect your application from potential security vulnerabilities.

Here's what you will learn in this blog.
* Auth-based access control
  * Authenticated User access
  * Verified Email access
* Owner-based access control 
  * Single document owner-based access
  * Multi-document owner-based access
* Document-level access control
* Role-based access control
* Field Level validation rules
  * To verify value belongs to a List of values
  * Require All Fields for Request
  * Restrict Update to Specific Fields
  * Restrict Create access with Required and Optional Fields
  * Allow only specific fields to be updated
* Time-based access control
* Data type validation
  * Optional field data type validation
  * Password complexity
  * Email Validation Rule
* Conclusion


Please note that these security rules are not a one-size-fits-all solution and should be adapted to your specific application’s requirements.

Enjoyed the preview? Head over to the [Canopas Blog](https://blog.canopas.com/firebase-firestore-list-of-essential-security-rules-a0e872c724d3) for the complete blog post!
Testing Rails root route
Tags: rails, testing, rspec, routing
Published: 2023-04-21 11:29:44

Now I need to test a root route in a Rails App

### Step 1. Learning the routing file

File: `config/routes.rb`

```ruby
Rails.application.routes.draw do
  root to: 'root#index'
end
```

### Step 2. Adding a test

File: `spec/routing/root_spec.rb`. This time I didn't use `describe`, only `it`.

`root_path` is a Rails routing helper that is equal to `/`.

```ruby
require 'rails_helper'

RSpec.describe 'Root Route', type: :routing do
  it 'leads to a correct controller and action' do
    get(root_path).should route_to("root#index")
  end

  it 'does not exist' do
    expect(post: root_path).not_to be_routable
  end
end
```

### Step 3. Running the spec

```bash
bundle exec rspec spec/routing/root_spec.rb --format documentation
```

That is it!
Happy coding!
[Cont...] System design of chat system-part2
Tags: designsystem, webdev
Published: 2023-04-21 11:28:14

From [part-1](https://dev.to/vijendra/system-design-for-chat-system-1mhm) on we decided to choose a WebSocket network protocol for communication to simulate server-initiated connection. WebSocket connection initiated by Client. It is bidirectional and persistent. Though it is a persistent connection, a server could send updates to a client.WebSocket generally works even if a firewall is in place. This is because of the same port 80 or 443 used by HTTP/HTTPS.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9uph9i1dcg1sewzerj2d.png)

High-Level Design-

As we decided to use websocket for a chat so for other features we can use the traditional request/response method of HTTP(Rest API).

So Now the chat system is divided into three parts:- Stateless service, stateful service and third-party.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kmx5ld20znmonndq5dow.png)
Stateless Service-> Manage user sign-up. login, user profile etc.

Stateful Service->Manage chat communication among users.

Third-party- Push Notification when the user is offline.

DataStore:

To Make a database choice - we have 2 types -SQL and No-SQL DB
RDMS for Stateless service for User Management. It can be scaled by using replication and Sharding technique.

But to maintain chat history data. Need to understand read/write the pattern.

Chat history has enormous data and users mostly check recent chats. But in some cases, users might want to search with a particular keyword and the chat system can navigate to a specific message.

So r/w = 1:1 in one -one chat

Random excess is expensive in RBMS.So we choose key-value stores to store messages. Facebook and Discord choose key-value stores for messages. Facebook is using HBase and Discord was using Cassandra but recently modified the architecture of Discord.

Key-value stores can easily be scaled horizontally and have low latency.

So high-level design with services and data store is

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zaybzjqmj1lrs8pokdwz.png)
Next, we will see the data modal design for the chat system, online status and group messaging design.

Check my [blogs](https://vijendrarana.blog).
SinonJs - to make the stubvalue random
Tags: javascript, typescript, testing
Published: 2023-04-21 11:28:08

```
    sinonSandbox
    .stub(LobService, 'createPostcard')
    .callsFake(() => {
      const postcard = new Postcard({ id: `psc_${faker.random.alphaNumeric(16)}` });
      return Promise.resolve(postcard);
    });
```


Everytime the function `createPostcard` is called, which is mocked btw, the function is called a new postcard is made.
Getting Started with AGE and PostgreSQL: Setting Up and Modifying the Source Code 😊
Tags: apacheage, postgres, database, coding
Published: 2023-04-21 11:23:25

## Introduction

Hello everyone! 😃 I hope you're doing well. I recently had the opportunity to work with the Apache AGE extension for PostgreSQL and wanted to share my experience with setting it up and modifying the source code. 🚀

## Prerequisites: Installing PostgreSQL and AGE 🛠️

Before diving into modifying the source code, ensure that you have PostgreSQL and the AGE extension set up correctly. To help you with the setup process, you can follow these video tutorials:

- [For macOS Users](https://www.youtube.com/watch?v=0-qMwpDh0CA) 💻
- [For Windows Users](https://www.youtube.com/watch?v=ddk8VX8Hm-I) 💻

Once you have PostgreSQL and the AGE extension installed, you can start running Cypher queries to interact with your graph data. 📊

## Modifying the Source Code 📝

If you're interested in contributing to the AGE project or adding new functions to the extension, you'll need to get familiar with modifying the source code. Fortunately, [Mohamed Mokhtar](https://dev.to/rrrokhtar) has written an excellent blog post that can help you get started:

[Guide to AGE Contribution and Modifying the Source Code to Add New Functions 🌟
](https://dev.to/rrrokhtar/guide-to-age-contribution-and-modifying-the-source-code-to-add-new-functions-l7m)
By following this guide, you'll learn the basics of working with the AGE source code and understand how to add new features and functions to the extension. 🧩

## Conclusion 🎉

Getting started with the AGE extension for PostgreSQL can seem daunting at first, but with the right resources and guidance, you'll be able to set up the environment and modify the source code with ease. The video tutorials and @rrrokhtar's blog post mentioned above should help you get up and running quickly. Happy coding! 👩‍💻👨‍💻

## References
- [Github](http://github.com/apache/age)
- [Documentation](http://age.apache.org)
SQL query check Azure Data Sync processing status
Published: 2023-04-21 11:17:23

As you aware that Azure data sync service syncs database changes to one database to another(source to destination).First time when this sync process is established successfully, system creates one extra database somewhere called as metadata db in destination server. If user was to check using SQL query that if last process is completed successfully or there is any failure than it can execute following query.

`SELECT top 1 sg.[name] as GroupName,
	   ud.[database] as DatabaseName,
	   uh.completionTime,
	   uh.detailEnumId as SyncStatus,
	   taskType.Name taskType--,
	  -- uh.recordType
FROM [dss].[syncgroupmember] sgm 
join [dss].[syncgroup] sg on sg.Id = sgm.syncgroupid 
join [dss].[userdatabase] ud on ud.id = sgm.databaseid
join [dss].[UIHistory] uh on uh.databaseid = ud.id and sg.id= uh.syncgroupid
join [dss].[EnumType] taskType on taskType.EnumId = uh.taskType and taskType.type ='TaskType'
WHERE sg.name = 'groupname' and cast(uh.completionTime as date) = Cast(DATE() as date)
order by uh.completionTime desc`

I wish this could help someone.
From Semi-Pro Cyclist to Tech Innovator: Insights from MapMyFitness Founder and Outside CEO Robin Thurston
Tags: entrepreneurship, mapmyfitness, outside, techinsights
Published: 2023-04-21 11:03:27



Robin Thurston, the founder of MapMyFitness and current CEO of Outside, has had a remarkable journey from being a semi-professional cyclist to a successful tech entrepreneur. In a candid discussion, Robin shares valuable insights and experiences from his entrepreneurial journey.

## A Passion for Cycling

Robin's love for cycling began in his childhood in Colorado, where he had the opportunity to go skiing in the winters and cycling in the summers. His competitive nature and social drive led him to a "semi-professional" cycling career, where he participated in elite events like the Zinger Mini Classic. Although he describes himself as more of a "bottle carrier and breakaway chaser" than a race winner, Robin's cycling career allowed him to travel across Europe, learn languages, and make lifelong friends.

## The Birth of MapMyFitness

The idea for MapMyFitness came to Robin during a cycling trip to Switzerland in 2005. A fellow cyclist expressed the desire to ride the same roads Robin knew, even without Robin being there. This sparked the idea for a platform that would allow users to create maps of their rides and share them with others. MapMyFitness was built on top of the Google Maps API, and the timing was perfect. MapMyRun and MapMyRide became two of the first iPhone apps, gaining massive popularity and millions of downloads.

## Entrepreneurial Lessons

Robin shares several key lessons for aspiring entrepreneurs:

- **Seize Opportunities**: Robin capitalized on the opportunity to create a product that didn't exist at the time, leading to the success of MapMyFitness.
- **Focus on Customer Needs**: MapMyFitness had a technology-driven culture that prioritized customer needs and used an agile approach to iterate based on customer feedback.
- **Understand Exit Options**: Entrepreneurs who take capital have three potential exit options: go bust, sell to a strategic buyer, or go public. Understanding these options is essential for decision-making.
- **Content vs. Hardware**: Robin believed in building a subscription business with content rather than hardware. He saw content as a way to bring people back to the platform more often and create a stable business.

## A Mission to Promote Outdoor Activities

With Outside, Robin aims to promote outdoor activities and improve global health. He believes that people are spending less time outdoors, leading to a health crisis. Robin is driven by a mission to create technology with strong reward mechanisms to encourage outdoor time and improve people's well-being.

Robin's journey exemplifies the importance of seizing opportunities, understanding exit options, staying resilient, and having a mission-driven approach to entrepreneurship.

For more insights and the full podcast with Robin Thurston, check out the [Terra Blog article](https://blog.tryterra.co/podcast-with-robin-thurston-ceo-of-outside-d8e5a900edb0) and the [YouTube podcast](https://www.youtube.com/watch?v=kU4GTCwFBgM&t).
Flutter MaterialPageRoute with id of mysql to nextpage
Published: 2023-04-21 10:57:48

I have develop a page SLIDESHOW use LISTVIEW that call a file json and php, it is work but I have a difficult..

On LISTVIEW, every photo is a code

`onTap: () {
    Navigator.push(
      context,
      MaterialPageRoute(builder: (context) => DetailEvento(id_evento: idPath),
      ),
    );
    print(idPath);
  },`

idPath is a call number of ID MYSQL, on terminal is showed "I/flutter (4733): 435", debug iOS, I click on slideshow, go to page DetailEvento but don't showed ID...

On DetailEvento is code

`const DetailEvento({Key? key, required id_evento}) : super(key: key);

get id_evento => null;

print(id_evento.toString());`

or

`print(id_evento);`

debug, is showed "I/flutter ( 4733): null"

Why? What did I do wrong?

I did a lot of research, nothing.
Is zero-knowledge proof used in blockchain?
Tags: zeroknowledgeproofblockchain, blockchain, zeroknowledge, web3
Published: 2023-04-21 10:48:30

Zero-Knowledge Proofs (ZKP) is a powerful cryptographic tool that has emerged in recent years, offering a way to verify transactions or identities without revealing sensitive data. ZKP has the potential to revolutionize blockchain technology, which has long been plagued by challenges around privacy and security.

Blockchain technology offers a decentralized and immutable way to store and verify data, but it comes with its own set of challenges. One of the main challenges is how to protect sensitive data while maintaining the integrity of the distributed ledger. ZKP provides a way to address this challenge by enabling transactions or identities to be verified without revealing the underlying data.

One example of [**Zero-Knowledge Proofs Blockchain**](https://www.codezeros.com/blog/how-zero-knowledge-proofs-are-revolutionizing-blockchain-technology) technology is the privacy-focused cryptocurrency Zcash. Zcash uses a ZKP called zk-SNARKs (Zero-Knowledge Succinct Non-Interactive Argument of Knowledge) to allow users to prove that their transactions are valid without revealing the transaction amount or the parties involved. This enhances privacy and security compared to other cryptocurrencies like Bitcoin, where transactions are publicly visible on the blockchain.

Another example of ZKP in the blockchain is the authentication protocol called "zk-Proofs for Anonymous Credentials," which allows users to prove their identity without revealing any identifying information. This can be useful for access control systems or other scenarios where privacy is important.

ZKP has many potential use cases in blockchain, including:

- Enhancing privacy in transactions: ZKP can be used to enable privacy-enhanced transactions, allowing parties to transact without revealing sensitive information.

- Verifying identities without revealing personal information: ZKP can be used to verify identities without revealing any personal information. This can be useful in scenarios like voting systems or access control systems.

- Auditing without revealing data: ZKP can be used to prove that certain transactions or data have occurred without revealing any additional information about those transactions or data.

In conclusion, ZKP is a powerful cryptographic tool that has the potential to revolutionize blockchain technology. By enabling transactions or identities to be verified without revealing sensitive data, ZKP can enhance privacy and security in blockchain-based systems. As blockchain technology continues to evolve, we can expect to see more use cases for ZKP and other cryptographic tools that enable greater privacy and security on the distributed ledger.