teleren/devto huggingface dataset:
Enhancing Data Validation in .NET IOptions Pattern: Utilizing Named and Typed IOptions for Robust Configuration.
Tags: dotnet, codenewbie, programming, coding
Published: 2023-06-07 14:15:00

Continuing the series **All About IOptions Pattern in .NET.** [link](https://dev.to/ahmedshahjr/all-about-ioptions-pattern-in-net-8-16d5)
In this last post we have talked about **Introduction to IOptions Pattern in .NET**. [link](https://dev.to/ahmedshahjr/introduction-to-ioptions-pattern-in-net-8-58l4).

In this post we will learn about 

- **Named and Typed IOptions** 
- **Validation in IOptions Pattern** 

What is **Named and Typed IOptions in .NET**
In our previous post we were using **Typed IOptions** in our project. which is used when we have single configuration for our properties as you can see in this code below we have single company configuration in our appsettings.json.

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

In program.cs we binding this appsettings configuration to our class using **Typed IOptions** since we have only one company settings in our appsettings file.

![Image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4tsr8vr97iaqhh11afvj.png)

What about having multiple companies settings in our appsettings file and binding them to our **CompanyOptions** Class for this purpose we need to used **Named IOptions** in out program file. lets add some more companies in appsettings.

![Image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aux39m6aam8rogoy716z.png)
as you can see we have 2 company types in our appsettings now. **CoOperate and Invidual**. let try to bind them with our **CompanyOPtions** class and modify it.

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

In program.cs we also need to change the bindings from Typed to Named IOptions. 


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



all the changes have been made now lets access them in our controller.


![Image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6js7hzqj6981etzfrq8a.png)

let run the project using **IOptionsSnapshot** and see the results.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5vg7cd0tiycpons0el9s.png)
 we can see each company settings have been matched with their respective class using named **options pattern**. For **IOptions** we need to create two different classes because it binds its settings at compile time.
Code Link of GitHub [link](https://github.com/ahmedshahjr/Articles/tree/main/Options%20Pattern)
In the next series we will learn about Validation in IOptions Pattern.
Storing a function in React state
Published: 2023-11-22 00:29:30

---
title: Storing a function in React state
published: true
date: 2023-06-07 14:11:00 UTC
tags: 
canonical_url: https://iliascreates.com/blog/post/storing-function-in-react-state/
---

I felt very React-dumb today. I simply wanted to store a function in the state of a React component. So, I would initialize the component state:

```
const [myCallback, setMyCallback] = useState<() => void>()
```

and later in the code I would have a button that sets this state:

```
const cb = () => console.log('hi!')
setMyCallback(cb)
```

I’ve been breaking my head on why the hell my callback function gets called even though I never call it anywhere in my code! Notice that we didn’t execute `cb()` or `myCallback()` anywhere.

The problem is that the argument of the `setState` functions can be a function that let’s us update the state based on the previous value. See the [docs of `setState`](https://react.dev/reference/react/Component#setstate) for details. React cannot tell if the function we pass is the aforementioned function, or the value that we want to store in our state. A solution to this is to simply wrap the value we want to store into a function:

```
setMyCallback(() => cb)
```

So funny yet so frustrating at the same time! Hope I save someone’s time!
"Balancing Parenthood and Programming": CodeNewbie Podcast S24E5
Tags: podcast, codenewbie, beginners, career
Published: 2023-06-07 14:06:32

We are back again! In S24E5 of the CodeNewbie Podcast, @saronyitbarek talks about navigating parenthood while pursuing your passion for coding with [Phoebe Voong-Fadel](https://twitter.com/phoebevf), Frontend Developer at the National Foundation for Educational Research.

{% embed https://www.codenewbie.org/podcast/balancing-parenthood-and-programming %}

Before entering the world of web development, Phoebe worked for years at various universities in London, while advocating for the use of technology and software to automate repetitive administrative tasks. Apart from her current career at the National Foundation for Educational Research, Phoebe writes articles for freeCodeCamp and mentors early-career developers.

- [Listen on Apple Podcasts](https://podcasts.apple.com/us/podcast/s24-e5-balancing-parenthood-and-programming-phoebe/id919219256?i=1000615982855)

- [Listen on Spotify](https://open.spotify.com/episode/0BBDtZ0gV30UzE7XSobILQ?si=e89d815c8f9d4cf3)

Or, listen wherever you normally get your podcasts!

***

**Make sure to subscribe to the CodeNewbie podcast if you haven't yet!**

Happy coding! We hope you enjoy this season of the CodeNewbie Podcast 💜
Toxic Lab Mouse 10k Collection
Tags: nft
Published: 2023-06-07 14:03:49

TLM is the first collection created by Toxic Mouse Town. The collection consists of 10,000 unique generated NFTs. TLM NFTs have been generated out of 300 Traits which will give each holder a unique look. TLM is not just a collection it's a project with a great roadmap towards the future, giving holders income returns and giveaways. Each holder will have the option to stake their NFT and claim early sale (TMT Tokens/NFTs) at a discounted price. These are just some of the features that our holders will have with much more to come in the near future.
Drawing images on the terminal
Tags: rust, stablediffusion, programming, tooling
Published: 2023-06-07 13:36:50

Lately, I've been experimenting with stable diffusion, and it has proven to be a captivating experience. However, if you're using a version that lacks a webUI, you're required to repeatedly switch back to a graphical user interface to view the output.

If you have used stable diffusion locally, especially for generating portraits you will know that it produces a lot of images with two heads, or multiple limbs, long necks etc. No matter how good your prompts are if you move away from producing square images of a certain size, it's something you get a lot. So I wanted to be able to quickly inspect the images from the terminal. 

If you've worked with stable diffusion on a local setup, particularly for generating portraits, you're likely familiar with the phenomenon of resulting images featuring multiple heads, limbs, elongated necks, and more. Regardless of the quality of the prompts, if you opt out from generating square images of specific dimensions often results in such artifacts. Therefore, I had to find a way to examine the images directly from the terminal.

So, I wrote a small Rust application that converts images into coloured text. The added benefit is that it functions seamlessly in both Windows PowerShell and Linux terminal environments.

https://github.com/elasticrash/image-peek

The underlying logic of the application is relatively straightforward:

* Get the dimensions of the image
* Get the size of the terminal
* Scale down the image so it can fit in our current terminal
* Calculate the color of the character in relation to the image.
* Print the character

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j0dntbcd6fyhevls5rde.png)
Creating a Webview for Android Using Native Development with Java
Published: 2023-06-07 13:34:20

Last week, at the company where I work, it was necessary to create an application for our platform using React. Initially, the idea was to convert this application to React Native, but I suggested creating a WebView app instead. It worked! Now, I'd like to share how to create a WebView for Android using native development with Java.

First of all, let's go over what you'll need:
Java installed on your machine, Android Studio, and all the required system variables (for Windows). Below, I'm providing all the useful docs:

Java - [docs oracle](https://docs.oracle.com/en/java/javase/11/install/index.html)
Android Studio - [Android Studio docs](https://developer.android.com/studio/install)

Once you have set up the development environment, let's create our app:

Open Android Studio and create an empty activity app. When your app is ready, clear everything in the activity_main.xml file. You might find a tag that displays a "Hello, World!" text on the screen. Remove it. After it, add the following code inside your androidx tag:

```xml
<WebView
    android:id="@+id/webview"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
/>

```

It creates an WebView Element in our app, that is displayed in all screen. Now, with Java, we must catch this element and render our website in it.

put this code insed onCreate method in MainActivity.java:

```java
webView = findViewById(R.id.webview);
webView.clearCache(true);
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
webView.setWebViewClient(new MyWebViewClient());
String url = "your_website_without_/_in_the_end";
webView.loadUrl(url);
```

Create a new private class to handle SSL errors:

```java
private class MyWebViewClient extends WebViewClient {
        @Override
        public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
            handler.proceed();
        }
    }
```
This code overrides the onReceivedSslError method to handle SSL errors and allow the WebView to proceed.

What this code do? Firsr, we catch the webview element `webView = findViewById(R.id.webview);`, and then, we clear the cache, enable JS, and set the client. Before, we just pass the URL and our webview is created.

to generate an APK:

Android Studio > Build > Build bundle(s) / APK(s) > Build APK(s)

Conclusion:
In this article, we learned how to create a WebView in Android using Java and Android Studio. By following these steps, you can easily display a website within your Android app using a WebView.

Note: Make sure to replace "your_website_without_trailing_slash" with the actual URL of the website you want to display in the WebView.

That's it! You now have a WebView app that can render web content in your Android application.
How to Improve your mouse speed Clicking speed.
Tags: devops
Published: 2023-06-07 13:09:42

To improve your mouse click speed, you can try the following techniques:

Hand and Finger Exercises: Perform regular exercises to strengthen your hand and finger muscles. This will increase your dexterity and speed. Squeeze a stress ball, stretch your fingers, and perform finger tapping exercises to improve your [clicking speed](https://macrotester.com/mouse-test-clicker/).

Proper Mouse Grip: Ensure you have a comfortable and efficient grip on your mouse. Use a grip that allows you to click quickly without straining your hand. Experiment with different grips to find the one that works best for you.

Adjust Mouse Settings: Increase the sensitivity of your mouse in the computer settings. This will allow the cursor to move faster across the screen, enabling you to click more quickly. However, be mindful that increasing sensitivity too much may affect accuracy.

Use Shortcuts: Familiarize yourself with keyboard shortcuts to perform tasks more quickly. Instead of relying solely on mouse clicks, you can use shortcuts to navigate menus, switch between applications, and perform various actions without needing to click as often.

Practice Clicking Techniques: Use dedicated clicking exercises or games to practice and improve your clicking speed. There are online clicking speed tests and games available that can help you track your progress and challenge yourself to get faster.

Maintain a Clean and Smooth Surface: Ensure that the surface your mouse moves on is clean and free from dust or debris. A smooth mouse pad or desk surface will reduce friction, allowing you to move the mouse more quickly and click with ease.

Upgrade Your Mouse: Consider investing in a mouse that is designed for gaming or high-speed clicking. These mice often have features like adjustable click resistance and higher click rates, which can help improve your clicking speed.

Relax and Stay Focused: Try to stay relaxed while clicking and maintain focus on the task at hand. Tension or distraction can slow down your clicking speed. Take breaks if needed and keep your mind clear to perform at your best.

Remember that improving your mouse click speed takes practice and time. Be patient with yourself and gradually work on implementing these techniques. Regular practice will help you develop faster and more accurate clicking skills.
DOCKER - Configurando o grafana no docker.
Tags: granfana, prometheus, docker, api
Published: 2023-06-07 13:04:01

O Grafana é uma aplicação web de análise de código aberto multiplataforma e visualização interativa da web. Ele fornece tabelas, gráficos e alertas para a Web quando conectado a fontes de dados suportadas. É expansível através de um sistema de plug-in. Os usuários finais podem criar painéis de monitoramento complexos usando criadores de consultas interativas.

Link: 🌐 https://grafana.com/

<h1>O código está versionado no meu github.</h1>
https://github.com/andreelidio/grafana-docker

<h1>Métricas da API.</h1>
 
 ![image](https://github.com/andreelidio/grafana-docker/assets/97263573/daca1c87-a4ac-4831-9d2a-e5b340967e97)

 <h1>Métricas da BD.</h1>
 
 ![image](https://github.com/andreelidio/grafana-docker/assets/97263573/252c9582-e79d-476c-b435-41ef081cc0e3)

 <h1>Console do Prometheus.</h1>
 
 ![image](https://github.com/andreelidio/grafana-docker/assets/97263573/32d45dde-9f4d-4157-b86f-11fc1bfa177c)

 <h1>Console do Grafana.</h1>
 
 ![image](https://github.com/andreelidio/grafana-docker/assets/97263573/d22c67ef-b6da-424c-904b-9803d8034d6f)


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



Espero que você tenha gostado deste post e tenha aprendido algo novo🆙
Qualquer feedback será bem-vindo, é só deixar nos comentários.😀
Curta, compartilhe, siga-me em:
✅ https://linktr.ee/andreelidio
Grid for disorder, Flexbox for chaos
Tags: webdev, css, beginners
Published: 2023-06-07 12:45:53

Why not complicate life a bit more? In the world of web design, life wouldn't make sense if we didn't complicate it a little. And to make our lives even harder, we have Grid and Flexbox! Both are super modern design tools, but each one has its own quirks that pull our hair out. So here we are to clear your doubts and, by the way, have a little fun!

## Grid vs Flexbox: Clash of titans you didn't know existed
First, let's talk about the difference between the two, so you feel like an expert at the next designers' meeting. Grid is like a chessboard where you can place your pieces however you want, regardless of whether they can actually move that way. Flexbox, on the other hand, is like an elastic band that stretches and shrinks your elements depending on its mood.

## How to choose the lesser evil?
Now, if you're at a crossroads of which technology to use, we'll tell you there's no universal answer. But a general rule is: if you want a web design that looks like an abstract painting, use Grid; if you prefer a jumble of elements where nothing makes sense, choose Flexbox.

## Use cases and examples that will save your life
So that you're not left wondering, here are some examples.

**CSS Grid: A maze with no exit**
Ideal for those moments when you want to create a design with rows and columns, but it appears as if it was made by a conceptual artist.

**CSS Flexbox: When anarchy takes shape**
Perfect for when you have no idea what you're doing, but you still want your elements to look together and, at the same time, apart.

**Mixing the unmixable: Grid and Flexbox**
If they seem boring separately, try mixing them! It will be like combining oil and water, but in your web design. Imagine the endless possibilities of chaos and disorder!

## When everything goes wrong in both worlds
But if you think this can't get worse, here are some examples of when everything goes wrong.

**Using CSS Grid for a header: Who needs structure?**
Why settle for a boring and structured header when you can create one that looks like it was designed by a 5-year-old with CSS Grid?

**Using CSS Grid for tabs: What could go wrong?**
Do you want your tabs to look like an impossible puzzle to solve? Use CSS Grid! Nothing better than seeing your visitors struggle to find the information they're looking for.

**Abusing Grid and Flexbox: The apocalypse in your design**
Who said less is more? Use Grid and Flexbox everywhere! That way, every time someone sees your website, they'll wonder if they're living in a surreal nightmare.

Well, now that you know the secrets of Grid and Flexbox, you're ready to embark on the wonderful world of chaos and despair in your web designs. Don't forget to share your masterpieces on social media so everyone can enjoy your amazing and confusing creations. Good luck!
please help check my code what's is wrong ? in testnet working, but in mainnet not work
Tags: blockchain
Published: 2023-06-07 12:28:51

in testnet working, but in mainnet not work 

 function minterMint(
            address to, 
            uint256 quantity,
            address payee,
            uint256 price
        ) external payable {

        require(maxSupply >= totalSupply() + quantity, "insufficent supply");
        require(!paused, "mint is paused");
        require(msg.value >= unitPrice * quantity, "insufficent balance");
        require(payeeAddress == payee, "invalid payee address");
        payable(payeeAddress).transfer(price);
        _mint(to, quantity);
    }
CodeMagic 🪄 How to Update "build_number" automatically on CodeMagic
Published: 2023-06-07 12:25:02

https://kaedeee.com/flutter-codemagic-build_number/

I resolved the issue that CodeMagic didn't automatically update the `build number` of iOS building after I've deployed my Flutter code to GitHub.

# How to Resolve

1. CodeMagic Setting

go to the tab, 
`build > build arguments`

and type
`--build-number=$(($BUILD_NUMBER))`


![スクリーンショット 2021-11-12 17.49.15.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/1900756/24fd56ef-c082-f3d8-b787-83342dcb7035.png)

2. Xcode Setting

At the `Xcode > Info.plist`,

check here.
`key CFBundleShortVersionString`
`key CFBundleVersion`

these both string to be `$(FLUTTER_BUILD_NAME)`


![スクリーンショット 2021-10-10 0.02.46.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/1900756/8da51e50-c4c3-e8ca-5484-7480801aed29.png)


https://kaedeee.com/flutter-codemagic-build_number/
How to register custom Gutenberg Block Category
Tags: gutenberg, wordpress, blockdevelopment, javascript
Published: 2023-06-07 12:24:43

You might be familiar with Gutenberg, the new block-grounded editor introduced in WordPress 5, If you are a WordPress developer Gutenberg allows you to create custom blocks, which are basically applicable pieces of content that you can use to build pages and posts.

By default, Gutenberg comes with some built-in block categories, such as Text, Media, Design, Widgets, etc. However, if you want to create custom blocks for your clients or someone you can create your own custom **block category**.

Here’s how we can do it, and still maintain the backward compatibility for WordPress lower than 5.8.

```
// Create Block Category.
function mh_custom_block_category( $categories ) {
	return array_merge(
	  $categories,
		array(
			array(
				'slug'  => 'custom-blocks',
				'title' => __( 'Custom Blocks', 'textdomain' ),
			),
		)
	);
}
global $wp_version;
add_filter( 'block_categories' . ( version_compare( $wp_version, '5.8', '>=' ) ? '_all' : '' ), 'mh_custom_block_category', 99 );
```

Change your custom block category to custom-blocks

```
{
  "name": "custom-blocks/tabs",
  "version": "0.1.0",
  "title": "Custom Blocks",
  "category": "custom-blocks",
  "icon": "smiley",
  "description": "Custom Blocks"
}
```

save and you will see your custom category.


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

Thanks for reading! I hope this post will help you. If you have any questions related to this post please feel free to leave them below.

Thanks again!
Lorem Picsum 佔位圖產生器
Published: 2023-06-07 12:19:56

## 佔位符

版面已經規劃好，但是內容還沒的時候，需要一些假字來充版面，這些佔位符都是無意義的文字，但也有分段，也有標點符號，用來模擬真正的版面外觀，這些假字就叫佔位符，英文叫 [lorem ipsum](https://zh.wikipedia.org/wiki/Lorem_ipsum)。

## 佔位圖

和佔位符一樣，用於模擬版面的內容，以往都是很苦工的自己畫一些備用，現在有佔位圖產生器來幫我們生出漂亮的佔位圖。

## Lorem Picsum

[Lorem Picsum](https://picsum.photos/)

Lorem Picsum 利用簡單的網址呼叫就可以傳回隨機圖片，而且它的圖片都還滿好看的。

產生 700 * 700 px 的正方形圖片：

```
https://picsum.photos/700
```

![Lorem Picsum](https://picsum.photos/700)

產生 700 * 350 px 的長方形圖片：

```
https://picsum.photos/700/350
```

![Lorem Picsum](https://picsum.photos/700/350)


## 多圖片產生

像是照片牆、清單頁這種版型，一次需要生出大量同尺寸的佔位圖，如果用上面的做法，因為瀏覽器快取的機制，網址一樣的圖只要被請求一次就會進入快取區，後面同樣網址的圖就只會從快取區取用，如此整篇網頁都會是同一張圖，如果要避免用到快取，需要在 Lorem Picsum 的網址後面再加上 `randoom` 參數：

```
https://picsum.photos/700/350?random=1
```

![Lorem Picsum](https://picsum.photos/700/350?random=1)

`random` 後面的引數只要改變就會回傳不同的圖片：

```
https://picsum.photos/700/350?random=2
```

![Lorem Picsum](https://picsum.photos/700/350?random=2)

雖然範例上是寫 `random`，不過其實問號後面隨便打都是可以的，只要網址不同就不會被瀏覽器視為同一張圖片，就不會用到快取。

## 應用

除了當版型驗證之外，網誌清單頁的配圖難產的時候，或者沒有指定的時候，在前端模板用簡單的 `if` 判斷式在沒有指定的時候使用 Lorem Picsum 的隨機圖片，是個相當偷懶的做法。

## 總結

總結一下 Lorem Picsum 的特點：

- 可自訂長寬。
- 直接以網址取用，不用在自己的後端或前端裝任何套件。
- 支援 HTTPS。
- 提供模糊與灰階濾鏡。

有一些特點在上面的範例中沒提到，可以自己去看 Lorem Picsum 網站範例研究一下。
How ERP systems help businesses
Tags: webdev, erp, softwareengineering
Published: 2023-06-07 12:14:57

With ERP systems, all vital business functions—estimating, production, finance, human resources, marketing, sales, purchasing—share a central source of up-to-the-minute information. Enterprise resource planning systems streamline the collection, storage and use of your organization's data.
Here are some of the main reasons and benefits why organizations use ERP systems:
Finance & Accounting
Provide business leaders with real-time visibility into their operations.
Provide business leaders and teams with instant access to their global supply chains.
Enable business leaders to identify challenges, uncover opportunities, and make faster decisions that impact different areas of their businesses.
Help automate and streamline tedious tasks and redundant processes.
Give employees the tools and data they need to be successful.
Provide a single point of truth for organizations.
Can often be accessed from anywhere (off-site and from mobile devices).
Help increase productivity among your team.
Make it easier for teams to collaborate with each other, and with third-party vendors.
Offer powerful reporting and forecasting tools that you can use to make informed decisions about the future of your business.
Keep data secure, and help you ensure that your business continues to operate in compliance with global regulatory laws and guidelines.