teleren/devto huggingface dataset:
Data Visualization using Matplotlib and Seaborn
Tags: python, ai, visualization
Published: 2023-06-14 16:33:56

Data visualization is the process of representing data visually through charts and graphs to gain insights and communicate information effectively. In Python, we have two popular libraries for data visualization: Matplotlib and Seaborn.

### Matplotlib
Matplotlib is a powerful plotting library that allows you to create various types of visualizations, such as line plots, scatter plots, bar plots, histograms, and more. It provides control over every aspect of a [plot](https://dev.to/ussdlover/common-plots-for-data-visualizations-53ig), such as axes, labels, titles, and colors. Matplotlib is flexible and can be used for both basic and complex visualizations.

### Seaborn
Seaborn is a high-level statistical data visualization library built on top of Matplotlib. It simplifies creating attractive and informative statistical graphics. Seaborn offers predefined themes and color palettes, enhancing the aesthetics of the plots. It also provides specialized plots like violin plots, box plots, swarm plots, and heatmaps, useful for statistical analysis.

To get started:
1. Install Matplotlib and Seaborn using the pip package manager.
2. Import the libraries into your Python script or Jupyter Notebook.

Here's a simple example of a line plot using Matplotlib:

```python
import matplotlib.pyplot as plt

x = [1, 2, 3, 4, 5]
y = [2, 4, 6, 8, 10]

plt.plot(x, y)
plt.xlabel('X-axis')
plt.ylabel('Y-axis')
plt.title('Line Plot')
plt.show()
```

And here's an example of a histogram using Seaborn:

```python
import seaborn as sns

data = [1, 2, 3, 3, 4, 5, 5, 5, 6, 6, 7, 8, 9]

sns.histplot(data, kde=True)
plt.xlabel('Values')
plt.ylabel('Frequency')
plt.title('Histogram')
plt.show()
```

These are simple examples, and both libraries offer more customization options and plot types to suit your needs.

Using Matplotlib and Seaborn, you can create visually appealing and informative plots to explore and present your data effectively.
Set up a Stripe Checkout REST API (+ metadata) using Go and Gin Framework.
Tags: go, tutorial, gin, stripe
Published: 2023-06-14 16:30:23

Implementing payment APIs for a go backend may be a struggle not only for gin framework developers that are just starting out but also the ones that have been using the framework for a while.

This article will show how to simply integrate a stripe checkout REST API that will produce links to a stripe checkout screen for your users to perform payments in your apps.

First install stripe package using this command

```
go get -u github.com/stripe/stripe-go/v74
```
Now add this controller

```
func CreateCheckoutUrl(c *gin.Context) {
	var body struct {
		Amount       int64  `form:"amount"`
		ReceiptEmail string `form:"email"`
                Metadata     string `form:"metadata"`
	}

	if err := c.Bind(&body); err != nil {
		c.JSON(http.StatusBadRequest, gin.H{
			"error": "Failed to read body",
		})

		return
	}

	apiKey := os.Getenv("STRIPE_SECRET_KEY")
	stripe.Key = apiKey

	domain := "https://your.domain.com/"
	params := &stripe.CheckoutSessionParams{
		LineItems: []*stripe.CheckoutSessionLineItemParams{
			{
				PriceData: &stripe.CheckoutSessionLineItemPriceDataParams{
					Currency: stripe.String("usd"),
					ProductData: &stripe.CheckoutSessionLineItemPriceDataProductDataParams{
						Name: stripe. String("Product Name Here"),
					},

					TaxBehavior: stripe.String("exclusive"),
					UnitAmount:  stripe.Int64(body.Amount * 100),
				},
				Quantity: stripe.Int64(1),
			},
		},
		CustomerEmail: &body.ReceiptEmail,
		Mode:          stripe.String(string(stripe.CheckoutSessionModePayment)),
		SuccessURL:    stripe.String(domain + "/"),
		CancelURL:     stripe.String(domain + "/"),
		AutomaticTax:  &stripe.CheckoutSessionAutomaticTaxParams{Enabled: stripe.Bool(true)},
	}

	params.AddMetadata("id", body.Metadata)

	fmt.Println("params - ", params)

	s, err := session.New(params)

	if err != nil {
		log.Printf("Error creating session: %v", err)
		c.JSON(http.StatusInternalServerError, gin.H{
			"error": err.Error(),
		})
		return
	}

	c.JSON(http.StatusOK, gin.H{
		"checkout_url": s.URL,
	})
}
```

In your routes add the following endpoint

```
// stripe api
	r.POST("/create-checkout-url/", controllers.CreateCheckoutUrl)
```

Done, You can now deploy your gin backend and test the API by making a post request to the endpoint we just created.
FASTEST JAVA SOLUTION 🔥🔥🔥
Published: 2023-06-14 16:26:06

# Code
```java
class Solution {
    public int[] shuffle(int[] nums, int n) {
        int[] newNums = new int[nums.length];
        for (int i = 0; i < n; i++) { 
            newNums[i * 2] = nums[i];
        }
        for (int j = 1; j < nums.length; j += 2) {
            newNums[j] = nums[n + (j / 2)];
        }
        return newNums;
    }
}
```
2629. LeetCode's Function Composition - Linear Solution Beats 53%
Published: 2023-06-14 16:02:56

# Code
```
/**
 * @param {Function[]} functions
 * @return {Function}
 */
var compose = function(functions) {
	return function(x) {
        for (var i = functions.length - 1; i >= 0; i--) {
            x = functions[i](x);
        }
        return x;
    }
};

/**
 * const fn = compose([x => x + 1, x => 2 * x])
 * fn(4) // 9
 */
```
Fastest JS Solution - Beats 75% of Solutions with 50 MS Runtime
Published: 2023-06-14 15:58:42

# Intuition
The code snippet is a JavaScript function that takes an array and a function as input and returns a new array with the function applied to each element of the input array.
# Approach
The approach used in the code snippet is to loop through each element of the input array and apply the given function to it. The result of the function is then stored in a new array.
# Complexity
- Time complexity:
The time complexity of the map function is O(n), where n is the length of the input array. This is because the function loops through each element of the input array once and applies the given function to it.
- Space complexity:
The space complexity of the map function is O(n), where n is the length of the input array. This is because the function creates a new array of the same length as the input array to store the results of the function applied to each element of the input array.
# Code
```javascript
/**
 * @param {number[]} arr
 * @param {Function} fn
 * @return {number[]}
 */
var map = function(arr, fn) {
    var newArr = [];
    for (var i = 0; i < arr.length; i++) {
        newArr[i] = fn(arr[i], i);
    }
    return newArr;
};
```
JAVASCRIPT SOLUTION BEATS 83% IN MEMORY USAGE
Published: 2023-06-14 15:50:17

# Intuition
The code snippet is a JavaScript implementation of the reduce() method for arrays. The reduce() method is used to apply a function to each element of an array and reduce the array to a single value.
# Approach
The reduce() method is called on an array and takes two arguments: a callback function and an initial value. The callback function is executed on each element of the array and takes two arguments: an accumulator and the current element. The accumulator is the value returned by the previous invocation of the callback function, or the initial value if it is the first invocation. The current element is the current element being processed in the array. The callback function returns a value that is used as the accumulator for the next invocation of the callback function. The reduce() method returns the final value of the accumulator after all elements of the array have been processed.
# Complexity
- Time complexity:
The time complexity of the reduce() method is O(n), where n is the number of elements in the array. This is because the callback function is executed once for each element in the array.
- Space complexity:
The space complexity of the reduce() method is O(1), because it only uses a constant amount of additional space to store the accumulator and the current element.
# Code
```JAVASCRIPT
/**
 * @param {number[]} nums
 * @param {Function} fn
 * @param {number} init
 * @return {number}
 */
var reduce = function(nums, fn, init) {
    var res = init
    for (var i = 0; i < nums.length; i++) {
        res = fn(res, nums[i])
    }
    return res;
};
```
2396. LeetCode's Strictly Palindromic Number - FASTEST JAVA SOLUTION - 0 MS RUNTIME ⏩⏩
Published: 2023-06-14 15:44:39

# Intuition
The code seems to be checking if a given number is strictly palindromic in all bases from 2 to n-2.
# Approach
The code seems to be checking if a given number is strictly palindromic in all bases from 2 to n-2.
# Complexity
- Time complexity: The time complexity of the convert method is O(log n), since it is converting the number to a different base. The time complexity of the isPalindrome method is O(log n), since it is checking if the number is a palindrome. The time complexity of the isStrictlyPalindromic method is O(n log n), since it is iterating through all bases from 2 to n-2, and for each base it is calling the convert and isPalindrome methods. Therefore, the overall time complexity is O(n log n).
- Space complexity: The space complexity of the convert method is O(log n), since it is creating a string representation of the number in a different base. The space complexity of the isPalindrome method is O(log n), since it is creating a string representation of the number. The space complexity of the isStrictlyPalindromic method is O(1), since it is only using a constant amount of space. Therefore, the overall space complexity is O(log n).

# Code
```
class Solution {
    public boolean isStrictlyPalindromic(int n) {
        int size = n - 2;
        for (int i = 2; i <= size; i++) {
            if (!isPalindrome(convert(n, i))) {
                return false;
            }
        }
        return true;
    }

    public long convert(int number, int base) {
        String binary = Integer.toString(number, base);
        return Long.parseLong(binary);
    }

    public Boolean isPalindrome(long number) {
        String num = Long.toString(number);
        int max = num.length() / 2;
        for (int i = 0; i < max; i++) {
            if (!(num.charAt(i) == num.charAt(num.length() - i - 1))) {
                return false;
            }
        }
        return true;
    }
}
```
GetBlock RPC Node Provider Launches Affiliate Program with Cash Bonuses
Tags: rpc, webdev, devops, node
Published: 2023-06-14 15:34:53

GetBlock’s affiliate program goes live with up to 20% referral bonuses

Starting from May, 2023, owners of accounts on GetBlock, a leading RPC nodes provider, can claim their referral links and become affiliate partners of the service. Up to 20% of the referrals’ payouts will be distributed between the participants of the affiliate program.

GetBlock’s affiliate program goes live with very simple mechanics. After setting up an account on GetBlock (100% free, MetaMask authorization is available), new users should go to the “Affiliate program” tab in the account settings menu.

Then, he or he can claim a unique referral link. This link can be shared in social media, blogs, videos, via personal websites, and so on. One-click sharing is available for Twitter, Telegram, and LinkedIn. 

Participants of GetBlock’s affiliate program can get up to 20% of all payments made by their referrals. There’s no limit for maximum payout: the more referrals pay, the more affiliate partners earn. Rewards can be claimed in cash once the personal balance of the affiliate partner exceeds $50.
Flexible RPC nodes for crypto apps: What is GetBlock?

All statistics regarding the history of payments, withdrawals, number of affiliates, and so on can be tracked online in the Affiliate Program dashboard.

The launch of the Affiliate Program is a notable milestone for GetBlock in 2023. It makes the services of the most flexible RPC node provider more accessible and advances the visibility of GetBlock’s brand.

Also, it creates one more income opportunity for Web3 fans regardless of their background and social media audience size.

Spreading the word about GetBlock is an exciting mission: affiliate partners will help the next  generation of Web3 developers to start working with cutting-edge RPC endpoints. GetBlock connects dApps to blockchain nodes eliminating the need for developers to run infrastructure on their own.

ABOUT GETBLOCK

Launched in Q4, 2019, GetBlock is one of the largest blockchain infrastructure providers. It offers RPC nodes of 50+ blockchains including the likes of Ethereum, Bitcoin, Polygon, Solana and L2 networks Optimism and Arbitrum.

With GetBlock, teams of crypto applications don’t need to run their own blockchain nodes: instead, they can get connected to blockchains via ready-made API endpoints. To meet the requirements of various dApps, GetBlock offers free and paid packages.

For media inquiries please contact: joan@getblock.io (Joan Williams, Head of Marketing) 
For more information please visit: https://getblock.io/ 

For updates, please follow: 

Twitter: https://twitter.com/getblockio 
Reddit: https://www.reddit.com/user/getblockio 
YouTube: https://www.youtube.com/GetBlock
Visual Database Design – with Oracle Database Designer
Tags: database, oracle, dbforge, dbforgestudio
Published: 2023-06-14 15:30:32

This article describes Oracle Database Designer, a data modeling tool that allows to easily create, modify, and manage database models in a visual environment - https://www.unixmen.com/visual-database-design-with-oracle-database-designer/

![oracle-database-designer](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bcavbbn0d4l2u7u7w8ry.png)
You don't need "Auto Rename Tag" extension anymore
Tags: vscode, webdev, html, react
Published: 2023-06-14 15:28:36

"Auto Rename Tag" is a very popular extension for VS Code, having almost 14 million downloads. It is designed to make renaming paired HTML/XML tags easier. The extension is not only useful for HTML but also for JSX, which used in React.

!["Auto Rename Tag" page in VS Code Extensions](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nqqkes6qnss7gsx07a1a.png)

!["Auto Rename Tag" usage example from official extension repository](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pe4vk9vp8o7semawrlpi.gif)

In version 1.79 VS Code introduced new feature ["Linked editing for JSX tags"](https://code.visualstudio.com/updates/v1_79#_linked-editing-for-jsx-tags).

> With linked editing, when you change an opening JSX tag VS Code will automatically update the corresponding closing tag. 

So you don't need to use an extension to rename HTML tags. You can simply enable this feature in the VS Code settings.

> The feature is off by default but can be enabled by setting:
`"editor.linkedEditing": true`
 
----

<center>
<h4>Resources</h4>
<a href="https://code.visualstudio.com/updates/v1_79">VS Code update 1.79</a> <br/>
<a href="https://marketplace.visualstudio.com/items?itemName=formulahendry.auto-rename-tag">"Auto Rename Tag" VS Code Extension</a>
</center>
setup ssh server trên windows
Tags: ssh, windows, server
Published: 2023-06-14 15:27:57

## bước 1: install 

install `openssh` bằng `chocolatey` theo cách bên dưới cho nhanh, hoặc có thể làm theo [guide của microsoft ](https://learn.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse?tabs=gui)

### chocolatey 

cài Chocolatey nếu chưa có, check hướng dẫn chi tiết [ở đây](https://chocolatey.org/install)
hoặc đơn giản 
1. Run `Get-ExecutionPolicy`. If it returns `Restricted`, then run `Set-ExecutionPolicy AllSigned` or `Set-ExecutionPolicy Bypass -Scope Process`.
2. run this command:  
  `Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))`

### openssh 

```
choco install openssh -y 
```

## bước 2: config 

### run install-sshd.ps1 

sau khi cài đặt xong, thì mở folder `C:\Program Files\OpenSSH-Win64` trong 1 cửa sổ `PowerShell Administrator` và chạy file `install-sshd.ps1`

### enable service 

mở `Win-R` / `services.msc`

Start 2 serices này lên, set Startup Type = `Automatic` luôn 

- OpenSSH SSH Server
- OpenSSH Authentication Agent

## test & enjoy 

mở 1 cửa sổ PowerShell bất kì và chạy lệnh `ssh localhost` sau đó nhập username/password để xem đã vào OK hay chưa.
Visualize and digest your GitHub repos
Tags: productivity, opensource, ai, github
Published: 2023-06-14 15:10:08

I've built a project with close friends to visualize the connections in a codebase called Mabbu {% embed https://mabbu.app/ %}. It's hard to obtain context over your codebase when your looking at it for the first time. You want to see the underlying connections in the code and also the flow of information from dependency calls to emulating the right click in vs code. We've also built a chatbot that has context over your entire codebase which is much more accurate than CoPilot X. It has the context of all the edges in the codebase along with their associations to other files at a function level and file level dependency.

Just paste your repo into Mabbu, choose what folder to visualize and get started navigating and chatting with your codebase!
Catch DEV Co-Founder Ben Halpern’s Keynote at RubyConf TH 2023
Tags: meta, ruby, conference, techtalks
Published: 2023-06-14 15:00:00

We are excited to announce an upcoming conference keynote by DEV and Forem Co-Founder Ben Halpern 🤩🎉

@ben will be presenting at [RubyConf TH 2023](https://rubyconfth.com/), a Ruby-focused conference on October 6–7 in Bangkok, Thailand along with [Bernard Banta](https://twitter.com/Bantab) of Ruby Kenya, [Jemma Issroff](https://twitter.com/jemmaissroff) of [wnb.rb](https://www.wnb-rb.dev/), and [Yukihiro "Matz" Matsumoto](https://en.wikipedia.org/wiki/Yukihiro_Matsumoto), the creator of Ruby 💎

> RubyConf TH is South East Asia's only Ruby conference, held in the heart of Bangkok, Thailand.

> We are returning after a third event after two highly successful conferences in 2019 and 2022.

> The conference features 18 tech talks in a single track over two days, so you do not miss a chance to catch your favorite topics and speakers.

We are **so proud** of Ben and so excited for his keynote. We know a lot will happen in tech between now and October, and we can't wait to find out what the topic of Ben's talk will be—check back later for updates! 🙌 

If you're attending RubyConf TH (or happen to be local to Bangkok), definitely check it out.

{% embed https://rubyconfth.com/ %}
✨ Exciting news, Developers! ✨ BuildBear has made Dapp's development faster than ever! 🚀🚀
Tags: blockchain, web3, developers
Published: 2023-06-14 14:57:50

✨ Exciting news, Developers! ✨
BuildBear has made Dapp's development faster than ever! 🚀🚀

Check out how CFPoly overcame challenges during its development process using BuildBear. 👇

💰 Tokens:
Accumulating Testnet tokens for comprehensive testing was time-consuming.
BuildBear's faucet, CFPoly gained instant access to test tokens, saving valuable time.

⏰ Instant Confirmation:
Public Testnets often have lengthy transaction times.
With BuildBear, contract testing is lightning-fast, completing 10 transactions in under 26 seconds compared to over 2 minutes on public Testnets.

⏱️ Manipulate Time:
Testing diverse fundraising campaigns on Public Testnets was challenging due to the inability to manipulate time.
BuildBear's Advance Time feature empowered CFPoly to test time-sensitive features without restrictions.

🙌 Testimony:

"With BuildBear we were able to test the functionality, which, otherwise, would not be able to test for at least two more months. Incredibly accelerated our development process. They swiftly resolved issues with event data, showcasing their hands-on approach and lightning-fast response!" CFPoly Team

Are you a team of developers working on an innovative DApp? What are you waiting for? Utilize BuildBear.io  Labs to accelerate your development process.

Check out the full story here: https://www.buildbear.io/success-stories/cf-poly

#BuildBear #CFPoly #SuccessStory #development #testing
MySQL Date Compare: Techniques and Best Practices
Tags: mysql, database, dbforge, dbforgestudio
Published: 2023-06-14 14:53:59

This article takes a detailed look at the various methods for comparing datetime values in MySQL - https://dbdeveloper.medium.com/optimizing-mysql-date-comparison-techniques-and-best-practices-7195bdd36917

![mysql-date-compare](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/izviz3uxgaz8rzu63oc9.png)
WordPress Flamingo GDPR
Published: 2023-06-14 14:48:00

The Flamingo WordPress plugin allows you to keep track of Contact Form events. It's an excellent tool for logging every sending and creating a "history" of emails sent over time.

The only drawback is that the plugin is not GDPR compliant and lacks a feature for deleting old records. 

To address this issue, I created a plugin that automatically cleans up data on your WordPress site after seven days to ensure GDPR compliance. You can find the plugin [here](https://github.com/Webbame/flamingo_gdpr), it deletes `flamingo_inbound` (contact form) records older than 7 days, and all the `flamingo_contact` (emails). 

I hope this solution proves helpful to you! 
Enjoy
How to remove a folder after pushing it to Github
Tags: softwareengineering, git, beginners, programming
Published: 2023-06-14 14:40:40

Let’s say you push a folder to Github but the files within it were not meant to be shared. What do you do? 

After panic settles in, here are the steps to follow:

First of all, to avoid this altogether, it’s always better to create and add specific files not meant to be shared via the .𝚐𝚒𝚝𝚒𝚐𝚗𝚘𝚛𝚎 file. 

To remove the folder and its contents from Github, use [𝚗𝚊𝚖𝚎 𝚘𝚏 𝚏𝚘𝚕𝚍𝚎𝚛]/

if the damage is already done, you can still proceed with the step above and push it to Github, but then if you check previous commits, you’ll see that the folder and its contents are still there.

How to remove them?

Use these commands:

𝚐𝚒𝚝 𝚏𝚒𝚕𝚝𝚎𝚛-𝚋𝚛𝚊𝚗𝚌𝚑 --𝚒𝚗𝚍𝚎𝚡-𝚏𝚒𝚕𝚝𝚎𝚛 '𝚐𝚒𝚝 𝚛𝚖 --𝚌𝚊𝚌𝚑𝚎𝚍 -𝚛 --𝚒𝚐𝚗𝚘𝚛𝚎-𝚞𝚗𝚖𝚊𝚝𝚌𝚑 𝙰𝙱𝙲' \ --𝚙𝚛𝚞𝚗𝚎-𝚎𝚖𝚙𝚝𝚢 --𝚝𝚊𝚐-𝚗𝚊𝚖𝚎-𝚏𝚒𝚕𝚝𝚎𝚛 𝚌𝚊𝚝 -- --𝚊𝚕𝚕

Assuming you are on the main branch, you should get this result as last line:

𝚁𝚎𝚏 '𝚛𝚎𝚏𝚜/𝚑𝚎𝚊𝚍𝚜/𝚖𝚊𝚒𝚗' 𝚠𝚊𝚜 𝚛𝚎𝚠𝚛𝚒𝚝𝚝𝚎𝚗

Then you can update the interested branch with:

𝚐𝚒𝚝 𝚞𝚙𝚍𝚊𝚝𝚎-𝚛𝚎𝚏 -𝚍 𝚛𝚎𝚏𝚜/𝚘𝚛𝚒𝚐𝚒𝚗𝚊𝚕/𝚛𝚎𝚏𝚜/𝚑𝚎𝚊𝚍𝚜/𝚖𝚊𝚒𝚗

and you can then push the results with 𝚐𝚒𝚝 𝚙𝚞𝚜𝚑 —𝚏𝚘𝚛𝚌𝚎

Use —𝚏𝚘𝚛𝚌𝚎 in case of conflicts between past and present branch.

This will change your git history deleting all references to the previous added folder and maintain the folder within the local structure of your project.