teleren/devto huggingface dataset:
Clean Code: Multiple exports, single import!
Tags: developer, react, learning, cleancode
Published: 2023-04-21 14:47:14

I always wondered whether there is a cool way to import many components in one line in React JS once they are in the same folder.And turns out there is a way that you can make your component more cleaner and will save you a lot of frustation.

So let's say you have 5 Components in your app and they are stored in a folder called **components**. Like this folder structure below:

![folder structure for components in a ReactJS project](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k81z0nrsu9ljlr7qk03h.png)

**The problem(issue)**

The issue here is that if you want to import all the components on a single page like home page you'll need to write this:
{% embed https://gist.github.com/Hallcoder/7ae90c67a16f303c183ad38e265193f8 %}

You can see that if we need to import many files like 20 components our file is cluttered with import rather than the real logic it need to implement.

**Quick Solution**

Create a file named **_index.js_** inside the components folder.

![Index file created](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qa1u4ygd25wgwrztaj2x.png)

And then paste in the above codes from home to that newly created **index.js** file:

{% embed https://gist.github.com/Hallcoder/78a82175e93601194751d59700a87e48 %}

Then what you have to do is export the files as named exports from the __index.js__ file:

{% embed https://gist.github.com/Hallcoder/7e2dc358c531ac8587546b7e44a870a5 %}

So, you see that was very easy and now you have a clean home page file like so: 

{% embed https://gist.github.com/Hallcoder/eea3522cfd1fe68c28eabb57b50cea83 %}

Thanks and don't forget to live a ❤️ !
Devart Has Released a Major Update of dbForge Tools for MySQL
Tags: mysql, database, mariadb, dbforge
Published: 2023-04-21 14:45:51

_Devart has rolled out an update of dbForge tools for MySQL. The enhancements focus on extended code completion and support for sequence tables in MariaDB databases, updated compatibility, as well as newly added support for MySQL functional indexes, new statements, and optimizer hints. _

Devart, one of the leading developers of database management software, ALM solutions and data providers for the most popular database servers, has released a new update of [dbForge Studio for MySQL](https://www.devart.com/dbforge/mysql/studio/utm_source=dev.to&utm_medium=referral&utm_campaign=pr_dbforgestudioformysql_19.04.2023) (version 9.2) and other tools from the dbForge product line for MySQL databases. 

The functionality of dbForge tools for MySQL has been enhanced with the following features: 

- Code completion for MariaDB application-period temporal tables 

- Support for MySQL functional indexes 

- Support for the TABLE, EXCEPT, and INTERSECT statements 

- A number of newly supported optimizer hints 

- Support for MariaDB sequence tables in Query Builder 

- Updated compatibility options, including support for MariaDB 11.3, Aiven Data Cloud, and SHA-256/512 

To learn more about the release, visit    
https://blog.devart.com/watch-out-for-a-big-new-update-of-dbforge-tools-for-mysql.html 

Simultaneously, Devart has released a new multidatabase solution called [dbForge Edge](https://www.devart.com/dbforge/edge), which includes dbForge Studio for MySQL and covers other database systems such as MariaDB, Microsoft SQL Server, Oracle Database, and PostgreSQL. 

 
About Devart 

Devart is one of the leading developers of database development and administration software, ALM solutions, data providers for various database servers, data integration and backup solutions. The company also implements Web and Mobile development projects. 

For additional information about Devart, please visit https://www.devart.com/.
Learning of Week : CSS Specificity
Published: 2023-04-19 11:40:32

As a new web developer who is just beginning to learn HTML and CSS, I recently came across the concept of CSS specificity, and I have to say it's been an eye-opener for me.

CSS specificity is a way of determining which CSS rule takes precedence over another when there are conflicting styles applied to the same element. This is important to understand because it can save you a lot of time and frustration when trying to style your web pages.

Specificity is calculated by assigning points to different selectors in your CSS code.
 For example, an ID selector (#example) is worth more points than a class selector (.example), and a class selector is worth more points than an element selector (div, p, etc.). Inline styles have the highest specificity and will always override any other styles applied to an element.

So, if you have conflicting styles applied to the same element, the style with the highest specificity will take precedence. This means that if you want to make sure a particular style is applied to an element, you need to make sure that its selector has a higher specificity than any other selectors that might be applied to the same element.

Understanding CSS specificity is essential for creating maintainable and predictable CSS code. It can help you avoid unexpected results and make sure that your styles are applied consistently across your web pages.

In conclusion, CSS specificity may seem like a small concept, but it's incredibly powerful and important to understand as a web developer. By grasping this concept early on, you'll be able to create cleaner, more organized, and more efficient CSS code.
RIP Blue Check 🪦
Tags: meta, socialmedia, twitter
Published: 2023-04-21 14:27:08

It's a sad occasion on this 21st of April: due to our decision not to purchase a Twitter Blue subscription for our main Twitter account, we've lost our blue check. 😭

### The Story of DEV's Blue Check

{% embed https://twitter.com/ThePracticalDev/status/1224431845812473858 %}

We earned our verification badge in 2020. This was a huge honor, as DEV started as a humble Twitter profile way back in 2014 before becoming the platform and company that it is today. The growth we experienced on Twitter in those first six years was crucial—we never could have established the community we now have without the engagement, visibility, and connection that Twitter provided in our early days. 💙

Our blue check remained undisturbed for two incredible years until late 2022, when it endured a few rapid-fire design changes and eventually became a "legacy check" indicating that we may or may not be notable.


![Our blue check with the text "Verified Account: This is a legacy verified account. It may or may not be notable."](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xg7kziui7jmb13pzxygm.png)
_We think we're notable!!_ 🥲

And today...it's gone for good. Thankfully, our community on Twitter is **more than 300k strong**, so we're not easily imitated. 😉

### How do I know I'm connecting with the *real* dev.to?

Our main Twitter account is **DEV Community [@ThePracticalDev](www.twitter.com/thepracticaldev)**, and that's not going to change.

We also maintain a [Twittersphere of satellite accounts](https://twitter.com/i/lists/1139559932091650051) based on specific languages, frameworks, and interests. They're a little more specific than our main account, so we recommend following the accounts related to your interests!

And if you're done with the Bird App entirely, you can find us in the Fediverse [@thepracticaldev@fosstodon.org](https://fosstodon.org/@thepracticaldev), where we have a fancy green check verifying our identity.

{% embed https://fosstodon.org/@thepracticaldev %}

### Why not keep the blue check by paying for Twitter Blue?

Here at [Forem](www.forem.com), the company behind DEV, we're on a mission to build safe, modern, and independent communities on open source software. We understand as well as anyone that the social media landscape is always evolving, changing, and growing—and that we need to do the same. 

We made the decision not to reinvest in the past/current social media landscape in order to focus on **building the future.** 

Won't you join us? 😁
How To Deploy a Django Application with Apache2 on Ubuntu in AWS EC2 instance?
Published: 2023-04-21 14:11:31

**In this tutorial, you’ll deploy a Django application on Ubuntu EC2 instance running Apache2 step by step.**

##### Prerequisites
* Install apache2

```
~ sudo apt update

~ sudo apt install apache2

~ sudo service apache2 start

```
* Apache Error watch 

```
~ watch tail -n 15 /var/log/apache2/error.log 

```
* Check python version 

```
~ python3 –version
```

* Install pip

```
~ sudo apt install python3-pip

~ sudo apt install python3-venv
```

* Create project directory

`~ mkdir demo`


* Change the ownership to ubuntu. Example: 

```
~ sudo chown -R ubuntu:ubuntu demo

~ sudo chmod 777 demo

~ sudo chmod 755 /home/<user>

```
* Add GitHub Repository. If you need generate SSH key for GitHub, you can visit this [link](https://dev.to/aanis434/how-to-set-up-ssh-keys-for-github-on-ubuntu-ec2-instance-d2p).

```
~ git init

~ git remote add origin repository_link

~ git pull origin main

```

* Change the ownership of the media directory. Example: 

```
~ sudo chown -R www-data:www-data demo/media
```

*  Create virtual env at demo

```
~ cd demo

~ python3 -m venv env

~ source env/bin/activate #Activate virtual env

```

* Install packages

`~ pip3 install -r requirements.txt`

---

##### Apache Server Configurations

* Make a demo.conf file on /etc/apache2/sites-available and configure following way

```
<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /home/ubuntu/demo
    <Directory /home/ubuntu/demo>
        AllowOverride all
        Require all granted
        Options FollowSymlinks
        Allow from all
    </Directory>

    Alias /media /home/ubuntu/demo/media
    Alias /static /home/ubuntu/demo/static

    <Directory /home/ubuntu/demo/static>
        Require all granted
    </Directory>

    <Directory /home/ubuntu/demo/media>
 	Require all granted
    </Directory>

    <Directory /home/ubuntu/demo/demo>
        <Files wsgi.py>
            Require all granted
        </Files>
    </Directory>


    WSGIDaemonProcess demo python-path=/home/ubuntu/demo python-home=/home/ubuntu/demo/env
    WSGIProcessGroup demo
    WSGIScriptAlias / /home/ubuntu/demo/demo/wsgi.py

</VirtualHost>

```

* Make migrate and collect static

```
~ source env/bin/activate

~ python3 manage.py makemigrations

~ python3 manage.py migrate

~ python3 manage.py collectstatic
```

* Change permission and ownership

```
~ sudo chmod 664 db.sqlite3

~ sudo chown :www-data db.sqlite3

~ sudo chown :www-data demo

~ sudo chown :www-data demo/demo

```

* Enable apache site configuration file 

```
~ sudo a2ensite demo.conf

~ sudo a2dissite default.conf

```
* Install wsgi mod in apache

```
~ sudo apt-get install libapache2-mod-wsgi-py3

~ sudo a2enmod wsgi

~ sudo service apache2 restart

```
* Apache Server log

```
~ watch tail -n 15 /var/log/apache2/error.log 
```


---

_Done! Now you can browse your application with the domain name._
🚀 Secure Your Android App: Best Practices for App Security and Privacy 🔒
Tags: android, security
Published: 2023-04-21 13:55:49

Hey there, fellow developers! 🌟 In today's tech-savvy world, app security and privacy are more important than ever. If you're an Android developer, it's crucial to ensure that your app is a safe haven for users. So, let's dive into the best practices for app security and privacy! 🔐

## 1️⃣ Use Proguard and R8 🛡️

Proguard and R8 are fantastic tools for code obfuscation, which makes it harder for potential attackers to reverse-engineer your app. This step is essential in protecting your app's valuable intellectual property and sensitive user data. Keep those bad guys away! 😎

## 2️⃣ Encrypt Sensitive Data 🔑

When storing sensitive data like user credentials, API keys, or personal information, always make sure it's encrypted. Android's Jetpack Security library provides easy-to-use encryption tools to help you safeguard your data like a pro. Don't let your user's data fall into the wrong hands! 🚫

## 3️⃣ Use HTTPS and Certificate Pinning 🌐

For secure communication between your app and server, always use HTTPS. To level up your app's security, implement certificate pinning, ensuring that your app communicates only with the intended server. This way, you can keep your user's data safe from man-in-the-middle attacks. Stay vigilant! 💪

## 4️⃣ Implement Strong Authentication 💡

Use strong authentication methods like biometrics or two-factor authentication (2FA) to make it harder for unauthorized users to access your app. This extra layer of security will give your users peace of mind and keep their data safe. Go the extra mile for your users! 🎉

## 5️⃣ Limit App Permissions 🚧

Request only the necessary permissions for your app to function. This will help build trust with your users and reduce the risk of exposing sensitive data. Remember, less is more when it comes to app permissions! 📝

## 6️⃣ Regularly Update Dependencies 📦

Keep your app's dependencies up-to-date, as outdated libraries may contain vulnerabilities that can be exploited. Stay on top of security patches and updates to ensure your app remains safe and sound. It's all about staying proactive! 💼

## 7️⃣ Perform Security Tests 🔍

Regularly test your app for security vulnerabilities and fix any issues that arise. Using tools like Firebase Test Lab, Android Studio, or third-party security testing services will help you identify and address any weaknesses. Keep your app bulletproof! 🛡️

---

By following these best practices, you'll be well on your way to creating a secure and privacy-focused Android app that users can trust. Remember, security is a journey, not a destination. Keep learning and evolving, and your app will shine! 💎

If you found this helpful, be sure to share, like, and follow for more awesome Android development tips and tricks! Let's grow together! 🌱🚀
What was your win this week?
Tags: discuss, weeklyretro
Published: 2023-04-21 13:38:21

---
title: What was your win this week?
published: true
description: Looking back on this past week, what was something you were proud of accomplishing?
tags: discuss, weeklyretro
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2023-04-06 19:13 +0000
---

Hey folks 👋

Hope y'all all have wonderful weekends!

Looking back on this past week, what was something you were proud of accomplishing?

All wins count — big or small 🎉

Examples of 'wins' include:

- Starting a new project
- Fixing a tricky bug
- Going hiking! 🥾

---

![The video starts with a close-up shot of a desk-sized wacky waving inflatable tube man doing its thing... the camera zooms out and we see a man flailing his arms and bending his torso in a similar fashion. The two dance together violently as the word "FRI-YAY" jumps up and down on the bottom of the screen.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rx78yqgwlsh9t720kl4g.gif)
Survey: BloombergGPT: A Large Language Model for Finance
Tags: chatgpt, nlp, deeplearning, machinelearning
Published: 2023-04-21 13:36:56

## 選定理由

chatGPTのリリース直後に出たドメイン特化型LLM。今後はこのようなドメイン特化LLMが数多く作られていくと思われる。[Bloomberg Terminal](https://www.bloomberg.com/professional/solution/bloomberg-terminal/)に統合されており、利用可能。

Paper: https://arxiv.org/pdf/2303.17564.pdf
Code: N/A
Articles: https://www.itmedia.co.jp/news/articles/2304/07/news064.html

## 概要

[社会課題] 金融業界では、膨大な量の自然言語データを扱う必要がある。特に、財務報告書やプレスリリースなどの文書データは、ステークホルダーにとって重要な情報源であり、それらを適切に解釈することが必要となる。
[技術課題] 金融分野のテキストデータに適したLLMはまだ提案されていなかった。
[提案内容] アナリストが40年以上にわたって金融の文書を収集・管理し、3630億トークンデータセット "FinPile" を作成した。これに3450億トークンの一般的な公開データセットを加え、7000億トークンを超える大規模な学習用コーパスを作成した。この学習コーパスの一部を用い、500億パラメータのデコーダーのみの言語モデルをトレーニングした。
[効果] 金融分野のテキストデータに対する自然言語処理技術が大幅に向上した。具体的には、質問応答、文章要約、情報抽出、感情分析、投資ポートフォリオの構築など、金融分野の様々なタスクに対して高い精度での予測が可能で、情報収集や分析の効率化、投資判断の支援などに活用できる。

## モデル

GPT系そのままでなく、特有のカスタマイズがある。

![eq1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7sqbd48rfycns27nmis9.png)

上記のようなSA(self-attension)層とLN(Layer Normalization)層とFFN（feed-forward network）のブロックを70層重ねたものである。

## 実験

実験では、BloombergGPTが多くの金融タスクにおいて、SOTAの結果を達成したことが示された。さらに、BloombergGPTの性能を向上させるために、金融に特化したトレーニングデータを用いることの重要性も示された。

学習環境は Amazon SageMaker にてp4d.24xlarge　インスタンスを64個使用した。これは 40GB A100 GPUが512枚分に相当する。

![table8](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c5dbkl06zdkbnod2q1w8.png)
![table9](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pqc50bbi1milzorrtbjf.png)

ファイナンス特化モデルであるため、金融ドメインのデータにはもちろん強い。

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

学習時にファイナンス以外のデータも一緒に学習しているため、破滅的忘却を起こさない。
Standardize Not Caring About Standards
Tags: programming, webdev, productivity
Published: 2023-04-21 13:07:37

I remember my first time encountering a curly brace on a new line. The world seemed to stop spinning for a second. “This must be a mistake” I thought to myself as I moved the curly brace back to where it belonged, on the same line as the function declaration. I committed this change along with my other work and in good spirits awaited my PR review. To my chagrin, the only issue that was noted in my PR was the fact that I had not put my curly braces on a new line. I had officially had my first experience with formatting standards. Because this was my first job and I deeply respected my peers I quickly applied the fix and ensured that all of my curly braces were on a new line from then on.

From that moment forward I became a standards chameleon, adapting to whatever environment I found myself in. I would put curly braces wherever people wanted them, I would delete semi-colons if I needed to. If the environment I was stepping into had pre-defined ways of doing things, I would adapt to those ways. I should mention that I am specifically talking about formatting standards right now. I didn’t hesitate to suggest changes to more fundamental strategies if I thought it could make an impact.

This was not my last experience with clashing standards. I view most of these interactions now as a bystander. It’s not uncommon to see some of the most talented developers at a company getting in heated debates over the eslint file. I’ve even seen developers build entire separate micro services just so they didn’t have to adhere to the standards of the original codebase (yes that was the real reason). These developers, despite their talent, are missing the most important part of software development: the end product.

My point here is not to say that standards should not exist. It is just that they should not take up a meaningful amount of time and effort. There are tools to make adopting standards easier, such as [Standard](https://github.com/standard/standard) for JavaScript and [Standard](https://github.com/standardrb/standard) for Ruby. Both of these can help avoid painstaking maintenance and fruitless discussions around standards

This idea of adapting to coding standards may seem like a minor revelation, and it is, however, it was the spark that started the shift in my view of software. In the beginning of my career, I cared almost solely about the means of building a product. I was more concerned with using cutting edge technologies and standards than I was with what those technologies and standards amounted to as a product. I believe that as builders we should not lose sight of our primary goal - building great products. Any time wasted arguing about the means is time that could be better spent focusing on the end - ensuring quality and success of the end product. For new developers, dropping your attachment to standards is the first step towards this shift in thinking.

Thanks for reading! If you enjoyed this you may also enjoy my newsletter: https://nicholaswarwick.substack.com
Context Managers: Simplify Resource Management in Python
Tags: python, programming, contextmanagers, backend
Published: 2023-04-21 13:03:36

Context managers in Python are a powerful tool for managing resources, like files or network connections, that need to be acquired and released in a specific way. In Python, context managers are defined using the "with" statement, which provides a clean and simple syntax for acquiring and releasing resources.

The with statement is used in conjunction with a context manager object, which defines how the resource should be acquired and released. The context manager object is responsible for defining two methods: __enter__() and __exit__(). The __enter__() method is called when the with statement is executed, and it returns the resource that will be used in the subsequent block of code. The __exit__() method is called when the block of code is finished, and it is responsible for releasing the resource.

Context managers provide a number of benefits over manually acquiring and releasing resources. First, they ensure that resources are always released, even in the case of an error or exception. Second, they provide a clean and simple syntax for acquiring and releasing resources, which makes code easier to read and understand.

Here's an example of using a context manager to work with a file:

```
with open('example.txt', 'w') as f:
    f.write('Hello, world!')
```
In this example, the open() function returns a file object, which is used to write the string "Hello, world!" to a file named "example.txt". The with statement ensures that the file is automatically closed when the block of code is finished.

Here's another example of using context managers with a custom class:

```
class MyContext:
    def __enter__(self):
        print('Entering context...')
        return self

    def __exit__(self, exc_type, exc_value, traceback):
        print('Exiting context...')
        if exc_type:
            print(f'Exception: {exc_type}, {exc_value}')

with MyContext():
    print('Inside the context...')
```
Output

```
Entering context...
Inside the context...
Exiting context...
```
In this example, we have defined a custom class called MyContext that defines its own __enter__ and __exit__ methods. When the with statement is executed, the __enter__ method is called, which prints 'Entering context...' and returns the context manager object. The code inside the with statement is executed, which prints 'Inside the context...'. Once the code completes execution, the __exit__ method is called, which prints 'Exiting context...'.

Context managers can also be used for managing multiple resources, locking and unlocking threads, and database transactions, among other things.

Context managers are a powerful tool for managing resources in Python, and they are used extensively throughout the standard library. If you are working with resources that need to be acquired and released in a specific way, you should consider using a context manager to simplify your code and ensure that your resources are always released properly.
Simplify Authentication With Django's In Built Authentication Views
Tags: django, python, webdev, beginners
Published: 2023-04-21 13:00:15

This video is a detailed guide on Django's class-based authentication views, specifically covering the LoginView, LogOutView, PasswordChangeView, PasswordChangeDoneView, PasswordResetView, PasswordResetDoneView, PasswordResetConfirmView, and PasswordResetCompleteView.

You'll deal with user authentication and password management a lot as a Django developer. Building safe online apps requires a thorough understanding of various authentication views. In this video, we'll look at the advantages of class-based views for authentication as well as the subtle differences between each view.

{%youtube qwATSBwJj9A%}