teleren/devto huggingface dataset:
Django Test Driven Social Media REST API - Getting Started
Tags: python, django, webdev, tutorial
Published: 2023-02-08 11:57:03

### Basic Project Setup
```bash
mkdir DjangoRESTAPI && cd $_
python3 -m venv .venv
. .venv/bin/activate
pip install django djangorestframework
pip freeze > requirements.txt
git init
curl https://raw.githubusercontent.com/github/gitignore/main/Python.gitignore > .gitignore
django-admin startproject config .
```

This should set up a boilerplate project with project configs and initialized git repository.
The Project Structure should resemble the following.
```bash
$ tree -a --gitignore -I ".git/"
.
├── .gitignore
├── config
│   ├── __init__.py
│   ├── asgi.py
│   ├── settings.py
│   ├── urls.py
│   └── wsgi.py
├── manage.py
└── requirements.txt
```
```bash
$ cat requirements.txt 
asgiref==3.6.0
backports.zoneinfo==0.2.1
Django==4.1.6
djangorestframework==3.14.0
pytz==2022.7.1
sqlparse==0.4.3
```

### Initial Commit: Getting Started

```bash
mkdir -p src/user
touch src/__init__.py
python3 manage.py startapp user src/user
```

The Project Structure should resemble the following:
```bash
$ tree src/
src/
├── __init__.py
└── user
    ├── __init__.py
    ├── admin.py
    ├── apps.py
    ├── migrations
    │   └── __init__.py
    ├── models.py
    ├── tests.py
    └── views.py
```

Now, to add the user app to the project, edit `src/user/apps.py`
```py
from django.apps import AppConfig

class UserConfig(AppConfig):
    default_auto_field = 'django.db.models.BigAutoField'
    name = 'src.user'
```
and then edit `config/settings.py`
```py
# ...

INSTALLED_APPS = [
    'django.contrib.admin',
	# ...
    'src.user'
]
# ...
```

Now we can run migrations and start the development server.
```bash
python3 manage.py makemigrations
python3 manage.py migrate
python3 manage.py runserver
```
This should start the development server on localhost. Now we can open the project in the code editor. Also we can commit our changes to the git repository.
Exploring the benefits and use cases of using CSS Grid vs Flexbox for website layout.
Tags: css, flexbox, grid, webdev
Published: 2023-02-08 11:46:15

When it comes to creating a website layout, there are two main ways to approach the task: using CSS Grid or using Flexbox. Both have their own set of benefits and use cases, and choosing the right one depends on the specific needs of the project.

CSS Grid is a two-dimensional layout system that allows you to create rows and columns in a grid-like structure. It's designed for creating complex and responsive website layouts and is particularly well-suited for larger projects that require a lot of control over the layout. With CSS Grid, you have full control over the size and position of elements, and can easily create responsive and flexible layouts that adapt to different screen sizes.

Flexbox, on the other hand, is a one-dimensional layout system that allows you to align elements in a single row or column. It's designed for creating simple and flexible website layouts, and is particularly well-suited for smaller projects that don't require a lot of control over the layout. With Flexbox, you can easily align elements in a single row or column, and can create responsive and flexible layouts that adapt to different screen sizes.

So, which one should you use? It depends on the specific needs of your project. If you're building a large and complex website that requires a lot of control over the layout, CSS Grid is the way to go. If you're building a smaller and simpler website that doesn't require a lot of control over the layout, Flexbox is the way to go.

In general, it's good to have knowledge of both CSS Grid and Flexbox and to use them according to the specific use case. Both layout systems have their own unique benefits and use cases, and understanding when to use each one will help you create a website layout that is both functional and beautiful.

In conclusion, both CSS Grid and Flexbox are powerful layout tools for web developers, but they have different use cases, CSS Grid is best for complex and responsive website layouts, while Flexbox is best for simple and flexible website layouts. As a developer, it's important to understand the benefits and use cases of both layout systems in order to make informed decisions when building website layouts.

please if you enjoy reading this article, subscribe to my YouTube channel [My channel](https://www.youtube.com/channel/UCJQmbtiMOaWro6ZCstnkhkg)

please if you enjoy reading this article, follow me on [Twitter](https://twitter.com/Clericcoder)
hint: Updates were rejected because the tip of your current branch is behind
Tags: git, troubleshoot, todayilearned
Published: 2023-02-08 11:40:30

## Troubleshooting

I prefer rebasing my feature branch onto Master branch before PR (Pull Request). But, sometimes I got this:  

```
$ git push origin feature/specific-feature
hint: Updates were rejected because the tip of your current branch is behind

hint: its remote counterpart. Integrate the remote changes (e.g.

hint: 'git pull ...') before pushing again.

hint: See the 'Note about fast-forwards' in 'git push --help' for details.
```

This happens when I already pushed Feature branch to Github and thus the sync between my local feature branch and the remote branch in GitHub got broken. To resolve this issue:
```
$ git push -d origin specific-feature
$ git push origin specific-feature
```

[Some developers](https://stackoverflow.com/a/39400690) recommend using force-push. Though, in my preference, deleting the remote branch is more appropriate since force-push has [several caveats](https://git-scm.com/docs/git-push#Documentation/git-push.txt---force) and I or my colleagues in some situations would abuse force-push if we are used to force-push. 

> This flag disables these checks, and can cause the remote repository to lose commits; use it with care.
What is Crypto Wallet?
Tags: web3, blockchain, defi
Published: 2023-02-08 11:09:31

In Defi,  since there are no intermediaries or third parties, you need an interface to interact with the blockchain, to store, receive, and send cryptocurrencies, this is why Crypto wallets are created.


A wallet helps users interface with the blockchain, wallets allow you to receive, store, and send cryptocurrencies.

Imagine how browsers help you interact with the internet, that’s how wallet helps you interact with the blockchain.

**kinds of Wallets**

1)	Custodial
2)	Non-Custodial Wallets.



**Custodial Wallets**:


These are wallets where third parties keep and maintain control over your cryptocurrencies on your behalf.
When using a Custodial wallet, you trust an external party to store your coins safely.
In Custodial Wallets, The user does not think about private keys but trusts a third party, the user is open to losing his/her money.


Some examples of Custodial wallets 
Free Wallet, Binance, BitMex, Bitgo, Blockchain.com


  
 **Non-Custodial  Wallets**: 


 These are wallets where a user takes full control and ownership of his/her cryptocurrencies.

When using a non-custodial wallet, you trust no external party and only yourself to ensure that your cryptocurrencies are safe, but you need to store and protect your private keys, if you lose your private keys, you will lose access to your cryptocurrencies too.

Note: Always protect your keys.
Some examples of non- Custodial wallets 
Metamask,  Trust wallet, Electrum, Exodus, Ledger Nano X, TREZOR One.


**WHAT IS MetaMask?** 

MetaMask is a popular cryptocurrency wallet that supports a broad range of Ethereum-based tokens and non-fungible tokens (NFTs) on supported blockchains.
Its function is to inject a javascript library called web3.js into the namespace of each page your browser loads. Web3.js was written by the Ethereum core team.
MetaMask is mainly used as a plugin in the web browser


My name is Maakai Princewill a DeFi content creator
follow me on Twitter https://twitter.com/cz_binance_HJ4J
AWS Secret Manager
Published: 2023-02-08 10:25:36

[39/100] #100DaysOfCloud Today, I stored a secret in AWS secret Manager and then created a CloudWatch rule to get an alert when the secret is tried to be deleted.

In the past, when you created a custom application to retrieve information from a database, you typically embedded the credentials, the secret, for accessing the database directly in the application. When the time came to rotate the credentials, you had to do more than just create new credentials. You had to invest time to update the application to use the new credentials. Then you distributed the updated application. If you had multiple applications with shared credentials and you missed updating one of them, the application failed. Because of this risk, many customers choose not to regularly rotate credentials, which effectively substitutes one risk for another.

Secrets Manager enables you to replace hardcoded credentials in your code, including passwords, with an API call to Secrets Manager to retrieve the secret programmatically. This helps ensure the secret can't be compromised by someone examining your code, because the secret no longer exists in the code. Also, you can configure Secrets Manager to automatically rotate the secret for you according to a specified schedule. This enables you to replace long-term secrets with short-term ones, significantly reducing the risk of compromise.

You can try do it by yourself by following the steps from the link below: [GitHub](https://github.com/aaditunni/100DaysOfCloud/blob/main/Journey/039/Readme.md)
A new update of the Corteza open-source low-code development platform, has been released: Corteza 2022.9.5
Tags: release, update, lowcode, opensource
Published: 2023-02-08 10:16:21


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

Corteza is a 100% open-source low-code, rapid application development, business process and integration platform, developed and maintained by Planet Crust.

Check out the new features, changes and fixes of Corteza 2022.9.5: https://www.planetcrust.com/planet-crust-releases-corteza-2022-9-5
封装一个hook对table的查询进行处理
Published: 2023-02-08 09:25:13

###table查询条件分析
- page：查询第几页  
- pageSize:每页查询的条数
- 其他查询条件
```javascript
import { TableSchema } from '@/types/api';
import { useRequest } from 'ahooks';
import { useState } from 'react';
import request from '@/packages/request';
import { message } from 'antd';

interface queryParam {
  page: number;

  [key: string]: unknown;
}

export const useTableData = <T>(url: string) => {
  const [dataSource, setDataSource] = useState<T[]>();
  const [total, setTotal] = useState<number>();
  const [isNext, setIsNext] = useState<Boolean>(false);
  const [param, setParam] = useState<queryParam>({ page: 1 });
  const getAsyncDataSource = async () => {
    try {
      const data = await request<TableSchema<T>>(url, {
        method: 'GET',
        params: { ...param, pageSize: 10 },
      });
      return data;
    } catch (error) {
      throw error;
    }
  };
  const { loading } = useRequest(getAsyncDataSource, {
    manual: false,
    onSuccess: ({ data }) => {
      setDataSource(data.results);
      setTotal(data.count);
      setIsNext(new Boolean(data.next));
    },
    onError: (e: Error) => {
      message.error(e.message);
    },
    refreshDeps: [param],
    loadingDelay: 300,
  });
  const queryByParam = (param: queryParam) => {
    setParam(param);
  };
  return {
    loading,
    isNext,
    total,
    dataSource,
    queryByParam,
  };
};

```
使用
```javascript

const Notification = () => {
  const [currentPage, setCurrentPage] = useState<number>(1);
  const { columns } = useNotificationColumns();
  const { dataSource, total, queryByParam } = useTableData<NotificationType>(
    '/notice_message/message/manage',
  );
  useEffect(() => {
    const queryParam = { page: currentPage };
    queryByParam(queryParam);
  }, [currentPage]);

  return (
    <div className={Styles.notification}>

      <Tabs className={Styles.statementTabs}>
        <Tabs.TabPane tab="System notification" key="1">
          <div className="p-6">
            <Table
              columns={columns}
              dataSource={dataSource}
              onChange={(pagination) => {
                setCurrentPage(pagination.current ? pagination.current : 1);
              }}
              pagination={{
                total: total,
                current: currentPage,
                showSizeChanger: true,
                pageSize: 10,
                pageSizeOptions: [10],
              }}
            />
          </div>
        </Tabs.TabPane>
     
      </Tabs>
    </div>
  );
};
```
Wednesday Links - Edition 2023-02-08
Tags: java, jvm, jep, gradle
Published: 2023-02-08 10:01:14

Squashing DB migrations using Testcontainers (7 min)🪗
https://mikemybytes.com/2023/02/01/squashing-db-migrations-using-testcontainers/

What good are Record Patterns in Java? (9 min)🐆
https://gavinray97.github.io/blog/what-good-are-record-patterns

Pattern Matching in Java – 5 Examples for Busy Developers (9 min)🐆
https://blog.jetbrains.com/idea/2023/02/pattern-matching-in-java-5-examples-for-busy-developers/

Nullness markers to enable flattening (6 min)🏁
https://mail.openjdk.org/pipermail/valhalla-spec-experts/2023-February/002223.html

JEP draft: Statements before super() (10 min)⤴️
https://openjdk.org/jeps/8300786

ArrayList preoptimization (30 sec)🛑
https://twitter.com/tagir_valeev/status/1622629666665205765

Hello, PNG! (12 min)👋
https://www.da.vidbuchanan.co.uk/blog/hello-png.html

Consider All Microservices Vulnerable — And Monitor Their Behavior (7 min)🐛
https://kubernetes.io/blog/2023/01/20/security-behavior-analysis/

Java Bytecode Simplified: Journey to the Wonderland (5 min)🚋
https://foojay.io/today/java-bytecode-simplified-journey-to-the-wonderland-part-3/

Gradle’s flexibility in action (10 min)🪧
https://melix.github.io/blog//2023/gradle-synthetic-projects.html

We Are Improving Kotlin Library Authors’ Experience! (1 min)💁
https://blog.jetbrains.com/kotlin/2023/01/library-authors-experience/
Exploring the Depths of Deep Learning: The Future of Artificial Intelligence and Machine Learning
Tags: machinelearning, computerscience
Published: 2023-02-08 10:00:00

Deep learning is a subfield of artificial intelligence and machine learning that uses neural networks with many layers, known as deep neural networks. It has been the driving force behind many recent breakthroughs in areas such as computer vision, natural language processing, and self-driving cars. In this article, we'll explore the basics of deep learning, how it works, and its potential applications in the future.

---

## **What is deep learning?**

Deep learning is a subset of machine learning that uses deep neural networks, which are neural networks with many layers. These layers allow the network to learn increasingly complex features of the data, leading to improved performance on tasks such as image and speech recognition.

## **How does deep learning work?**

Deep learning models are trained using a dataset of inputs and outputs. The model is fed the input data, and it uses the layers of the network to extract features and make a prediction or decision. The output is then compared to the desired output, and the model's weights and biases are adjusted to reduce the error. This process is repeated many times, until the model's predictions become accurate.

## **Applications of deep learning**

Deep learning has been used to achieve state-of-the-art performance in a wide range of applications, including:

- **Computer vision**: Deep learning has been used to create models that can recognize objects, faces, and even emotions in images and videos with high accuracy.
- **Natural language processing**: Deep learning models have been used to achieve human-like performance in tasks such as language translation and text generation.
- **Self-driving cars**: Deep learning is used to process sensor data and make decisions for self-driving cars.
- **Speech recognition**: Deep learning models have been used to create speech recognition systems that can transcribe speech with high accuracy.
- **Gaming**: Deep learning models have been used to create game-playing agents that can beat human players at games such as Go and poker.

---

Deep learning has been the driving force behind many recent breakthroughs in artificial intelligence and machine learning. It has the potential to revolutionize a wide range of industries, from healthcare to finance. As the field continues to evolve, we can expect to see even more impressive applications of deep learning in the future. It's an exciting time to be a part of the world of AI and ML, and we can't wait to see what the future holds for deep learning.
50 Keyboard Shortcuts that will make you a Visual Studio Code Pro.
Published: 2023-02-08 09:55:46

Visual studio code (VS Code) is one of the most popular IDE and text editor that most software developers use. It provides support for many languages and frameworks. And it's open source and free to use. 

This article contains 50 Keyboard Shortcuts that every developer need to know for easy programming. It'll help you save time and and make using Vs Code easy for you. 

**Shortcuts and what they do.**

1. `ctrl`+ `N`: Open a new file.
2. `Ctrl` + `S`: Save file.
3. `Ctrl` + `Shift` + `S` : Save as. 
4. `Ctrl`+ `X`: Cut line. 
5. `Ctrl` + `C`: Copy line. 
6. `Ctrl` + `F4`: Close file. 
7. `Ctrl` + `K` then `Ctrl` + `W`: Close all. 
8. `Ctrl` + `Shift` + `T`: Reopen closed editor. 
9. `Ctrl` + `Enter`: Insert new line or Insert line below. 
10. `Ctrl` + `Shift` + `Enter`: Insert line above. 
11. `Ctrl` + `Shift` + `N`: New window/Instance. 
12. `Ctrl` + `Shift` + `W`: Close window/instance. 
13. `Ctrl` + `K` then `P`: Copy path of active file. 
14. `Ctrl` + `Home`: Go to beginning of file. 
15. `Ctrl` + `End`: Go to end of file. 
16. `Home`: Go to beginning of line. 
17. `End`: Go to end of line. 
18. `Ctrl` + `K` then `Ctrl` + `C`: Add line comment. 
19. `Ctrl` + `K` then `Ctrl` + `U`: Remove line comment. 
20. `Ctrl` + `/`: Toggle line comment. 
21. `Shift` + `Alt` + `A`: Toggle block comment. 
22. `Ctrl` + `T`: Show all symbols. 
23. `Ctrl` + `G`: Go to line. 
24. `Ctrl` + `P`: Go to file. 
25. `Ctrl` + `F`: Find. 
26. `Ctrl` + `H`: Replace. 
27. `Ctrl` + `Spacebar`: Trigger suggestion. 
28. `Ctrl` + `.`: Quick fix. 
29. `Ctrl` + `K` then `M`: Change file language. 
30. `Ctrl` + `=`: Zoom in. 
31. `Ctrl` + `-`: Zoom out. 
32. `Ctrl` + `F4` then `Ctrl` + `W`: Close editor. 
33. `Ctrl` + `Shift` + `.`: Replace with next value. 
34. `Ctrl` + `Shift` + `/`: Replace with previous value. 
35. `Ctrl` + `K` then `F`: Close folder. 
36. `Ctrl` + `\`: Split folder. 
37. `Ctrl` + `Shift` + `\`: Jump to matching bracket. 
38. `Shift` + `F8`: Go to previous error/warning. 
39. `Alt` + `Right arrow`: Go forward. 
40. `Alt` + `Left arrow`: Go back. 
41. `Alt` + `Enter`: Select all occurrences to find match. 
42. `Alt` + `Up arrow`: Move line up. 
43. `Alt` + `Down arrow`: Move line down. 
44. `Shift` + `Alt` + `Up arrow`: Copy line up. 
45. `Shift` + `Alt` + `Down arrow`: Copy line down. 
46. `F12`: Go to definition. 
47. `F11`: Toggle screen. 
48. `F2`: Rename symbol. 
49. `Tab`: Emmet expand. 
50. `F8`: Go to next error/warning.
There are still many misconceptions and myths surrounding Chat GPT.
Tags: ai, openai, career, programming
Published: 2023-02-08 09:49:17

Now that Google has joined the race of #generativeai with Open AI's Chat GPT, there are still many misconceptions and myths surrounding Chat GPT.

Let us break them down one by one.
 
Myth 
Chat GPT algorithms are always accurate. 
Fact ✅
While Chat GPT algorithms can be very effective at specific tasks, they are not always accurate. The accuracy of a Chat GPT depends on the quality of the data it is trained to perform! We'd advise carefully evaluating the performance of tools and considering whether it is appropriate for the task at hand.

Myth 
Chat GPT can completely replace human job roles. 
Fact ✅
While Chat GPT can handle many everyday tasks, it's incapable of handling all interactions as it doesn't provide the same level of empathy and understanding as a human. Chat GPT can only assist humans in better productivity, but complete replacement is not possible.

Myth 
Chat GPT can understand the context of the conversation like a human 
Fact ✅
Chat GPT uses the input it receives to generate text, but it can't understand the context of the conversation as a human does. However, with the advancement in technology and more data, the model is getting better at understanding the context.
 
Myth 
Chat GPT is not safe to use 
Fact ✅
Chat GPT is a model that is trained on a large dataset of text with no intention to cannot cause harm. However, like any technology, it can be used for malicious purposes if obtained by bad actors. It's better to take precautions to ensure the security and safety of any data used to train or interact with the model.
 
Conclusion:
While Chat GPT has the potential to bring about significant advancements, it's essential to consider the potential negative consequences. As Google's BARD AI with LAMDA technology (Language Model for Dialogue Applications), announced by [Sundar Pichai](https://blog.google/technology/ai/bard-google-ai-search-updates/), is also in the making, have a clear understanding of Generative AI's capabilities and limitations to use it more effectively and avoid any misconceptions.
[ 
Follow us to gain insights and make more informed decision](https://hypeteq.com/)
super keyword
Published: 2023-02-08 09:46:51

```rb 
module M
    def report #3
        puts "'report' method in module M"
    end
end

class C  
    include M
    def report 
        puts "'report' method in class C" #1
        puts "--- --- ---" #2
        super # it defined in class method #3
    end
end

c = C.new 
c.report
```
prepend پیش انداختن
Published: 2023-02-08 09:35:15

prepend instead of include ? 

```rb 
module MeFirst
    def report
        puts "Hello from module!"
    end
end

class Person 
    prepend MeFirst
    
    def report
        puts "Hello from class"
    end
end

p = Person.new
p.report
```
method in module and class
Published: 2023-02-08 09:29:56

```rb
module InterestBearing
    def calculate_interest
        puts "Placeholder! we are in <module> InterestBearing"
    end
end

class BankAccount
    include InterestBearing

    def calculate_interest
        puts "Placeholder! we are in <class> BankAccount"
        puts """ the method in <class> is 
                 overriding than method in 
                 <module>."""
    end
end

account = BankAccount.new 
account.calculate_interest
```

```rb 
module M
    def report
        puts "'report' method in module M"
    end
end

module N
    def report 
        puts "'report' method in module N"
    end
end

class C  
    include M 
    include N
end

c = C.new 
c.report
```
```rb
module M
    def report
        puts "'report' method in module M"
    end
end

module N
    def report 
        puts "'report' method in module N"
    end
end

class C  
    include M 
    include N
    include M
end

c = C.new 
c.report # same result (N)
```