teleren/devto huggingface dataset:
Q&A with Self-built Blockchain and Dapps (1)
Tags: blockchain, geth, beginners
Published: 2022-04-14 16:37:24

> The purpose of building this blog is to write down my memo for learning the dApps.

#### Q1: Is there any way to unlock the geth account permanently?
I have created a dapp where the user can sign a contract using metamask. However, the account that gets the money sent to keeps getting locked. Sure, I can manually unlock it, but this is really annoying. Is there any way to automate this, that it remains unlocked?

**A1:** You can unlock it for as long as the geth instance is running using a 0 as the duration parameter:

`web3.personal.unlockAccount("address", "pass", 0);`

---

#### Q2: What does block reached canonical chain mean?
In my geth node I see sometimes on the output the message: **block reached canonical chain**. I tried googling for the answer but could not find one. Does anyone know what this means?


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

**A2:** Without knowing why geth decides to write it like that I can give you a generic answer.

Canonical chain is the chain that is agreed to be the 'main' chain and not one of the side-chains which end. In theory it is never 100% sure which chain is the canonical chain. In theory you could still revert block number 1 (or is it block 2 which is after the genesis block) by continuing its side-chains with enough hashing power.

In practise different parties decide for themselves how many blocks they require on top of the block they're interested in for it to be considered part of the canonical chain. The more blocks there are mined on top of it, the more likely the block is to be part of the canonical chain. That is also what exchanges are referring to when they "require X confirmations" for transfers before accepting them. Typically this number is something like 5-10 for Ethereum.

So, I assume geth has decided on an internal X for the number of confirmations it requires for a block to be considered part of the canonical chain. And when a block has reached that amount of confirmations (blocks on top of it) geth tells you a block has reached canonical chain.

---

### References
https://ethereum.stackexchange.com/questions/11102/unlock-account-permanently
https://ethereum.stackexchange.com/questions/47016/what-does-block-reached-canonical-chain-mean
HOW TO CREATE A POSTGRESQL DATABASE ON UBUNTU 20.04
Tags: postgres, ubuntu
Published: 2022-04-14 16:34:20


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

First open terminal and

`sudo apt update`
`sudo apt install postgresql postgresql-contrib`

now you have downloaded necessary libraries. After that:

`sudo -i -u postgres`

This way you are switched to postgres user. and enter your password (of the previous user)

`psql`

With psql you are ready to perform postgres commands.

always use 

`\q`

to leave postgres command line.

Finally, to create a database:

`CREATE DATABASE exampledatabase;`

Wish you an easy coding!
Django Tutorial Part 5 -- polls アプリのページを追加
Tags: django
Published: 2022-04-14 16:27:13


https://docs.djangoproject.com/en/4.0/intro/tutorial03/#writing-more-views

## 現在の urls と views を確認

polls/urls.py

```py
urlpatterns = [
    path('', views.index, name='index'),
]
```

polls/views.py

```py
def index(request):
    return HttpResponse("Hello, world. You're at the polls index.")
```

* urlspatterns に polls の root から index への誘導
* def index に index へのメッセージ

これらしか書いてない。よって

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

現在 polls アプリで見れるのが index ページのこのメッセージしかない。
なので

* details 
* results
* votes 

のページを urls と views に追加作成して、ページを増やす。

---

## details, results, votes のページを作成する

```py
urlpatterns = [
    path('', views.index, name='index'),
    # ex: /polls/5/
    path('<int:question_id>/', views.detail, name='detail'),
]
```

polls/question_id/ で　views の detail に飛んで

```py
def detail(request, question_id):
    return HttpResponse("You're looking at question %s." % question_id)
```

views の detail で question_id を表示する

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

```py
    path('<int:question_id>/results', views.results, name='results'),
    path('<int:question_id>/votes', views.votes, name='votes'),
```

```py
def results(request, question_id):
    return HttpResponse("You're looking resutls of %s." % question_id)
def vote(request, question_id):
    return HttpResponse("You're voting on question %s." % question_id)
```


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


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

results, vote も同じように作る
Top 5 Sad Heart Touching Poetry in Urdu 2 lines
Published: 2022-04-14 16:06:46

In this post, we are going to share with you the top 5 sad heart touching poetry in urdu 2 lines. If you want to become a sad urdu poetry writer, this post will help you to do so effectively.

Let's get started:

## Best Sad Poetry in Urdu 2 lines

Sher No.1:

Yeh Dukh Nahi Keh Mujh Se Nigahen Badal Gaye
Gham Yeh Hai Keh Jeena Seekh Gaye Woh Mere Beghair

یہ دکھ نہیں کہ مجھ سے نگاہیں بدل گئے
غم یہ ہے کہ جینا سیکھ گئے وہ میرے بغیر

It's not sad that my eyes have changed
The sad fact is that they have learned to live without me

Sher No.2:

Beithe Thay Apne Moj Mein Aajanak Ro Paray
Yun Aakar Tere Khayal Ne Acha Nahi Kiya

بیٹھے تھے اپنے موج میں آجانک رو پڑے
یوں آکر تیرے خیال نے اچھا نہیں کیا

They were sitting and suddenly cried in their waves
It didn't work out that way

Sher No.3:

Aaj Aayi Hai Meri Yaad Usay
Zaroor Kisi Ne Thukra Diya Hoga

آج آی ہے میری یاداسے
ضرور کسی نے ٹھکرا دیا ہوگا

Today She remember Me
Someone must have turned it down

Sher No.4:

Khushiyan To Kab Ki Ruth Gayi Hain
Kaash Keh Ghamon Ko Bhi Kisi Ki Nazar Lag Jaye

خوشیاں تو کب کی روٹھ گی ہیں
کاش کہ غموں کو بھی کسی کی نظر لگ جائے

When will happiness come?
I wish someone could see the sorrows too

Sher No.5:

Baatain Itni Keh Jesay Wafa Un Pah Khatam
Jab Nibhane Ki Baat Aayi To Majboor Nikle

باتیں اتنی کہ جسے وفا ان پہ ختم
جب نبھانے کی بات آی تو مجبور نکلے

Talks so much that the one who is faithful to them ends up
When it came to bathing, they were forced out

If you want to Read More Heart Touching Sad Poetry in Urdu Click here:

[https://poetrybaaz.com/urdu-poetry/sad-poetry/](https://poetrybaaz.com/urdu-poetry/sad-poetry/
)

## Final Thoughts About Sad Poetry in Urdu 2 lines:

If you want to express your Heart Touching feelings, these sad poetry in urdu 2 lines are best to help you to describe your feelings. It's time to hear from you. Which is you're favorite Sad shayari sher, let me know in the comment box. I would love to hear from you. Thank you for being till the end.
What is Web 3.0
Published: 2022-04-14 16:05:41

##Introduction 
The complete modern world of the web and the future of decentralized internet is web3. The web we are experiencing today is completely different from the last 10 years. Society has changed, the technology changed and lifestyles also changed but the particular trend came with a particular period, and the web constantly evolved with different stages. Web3 also evolved with web1, web2, and now web3.

###What is Web 1.0?
Web 1.0 also known as Read-only, serves static data in form of only text and image format. Web 1.0 lasted approximately from 1990 to 2004. The data served from static files rather than databases and the zero interaction between users and produced content from organizations leads to known as Read-only.

###What is Web 2.0?
Web 2.0 also known as Read-write, we currently experiencing web 2.0 and we can think of web 2 as an interactive social web. Web 2 allows you to become a creator with inbuilt modern apps you don't need to be a developer for creating process. It allows anyone to be the creator and share with the world with video, audio, text, and all other social forms and reach out to the millions of people and allow them to share, comment, and like your work.

###What is Web 3.0?
Web 3 also known as Read-write-own, is the future of the modern web and the core of web3 is decentralization. The meaning of decentralization is the access to applications for all local contributors and in web 3 developers don’t deploy and build applications on single server or store data on a single server. Web3 applications run on decentralized networks referred to as dapps(decentralized apps). When we discuss web3 we notice blockchain and cryptocurrency are part of the conversations because cryptocurrency plays big role in many web3 protocols. The new way of building companies is tokens  people get ideas but for building ideas they need resources and money they take on venture capital and share percentages of companies. This is a basic example of a web3 application and how it works you can explore more about web3 on the internet to get started with it and one more thing which came with web3 is Decentralized Autonomous organization (DAO) we will explore more about it in the next article.

Hey amazing readers I am Ganesh from India developer and technical writer currently learning Web3 connect with me on [Twitter](https://twitter.com/PatilGanesh1010) to get more content related to 
- Web Development
- freelancing
- Content Writing
- Software Development
Get Started Part 4: Connect to the network display tool
Tags: tutorial, opensource, embedded, luos
Published: 2022-04-14 15:53:27

Get Started Part 4: Connect to the network display tool

⏩ https://docs.luos.io/tutorials/get-started/get-started4

The last part will guide you in using the Luos Network Display tool to view your entire network online.

A simple and intuitive way to discover our new alpha version of Luos App!
What is your best way to manage emails?
Tags: discuss, watercooler, tips, productivity
Published: 2022-04-14 15:52:45

Emails become harder to deal with time. A lot of emails get lost among spam or other more important emails.

How do you manage your emails? Do you use a tool or apply any labels?

For my personal email I use labels a lot but it doesn’t help much. For work I have set up smart mailboxes to try and keep track of important stuff.
What's a fun group activity that we could do during CodeLand 2022?
Tags: discuss, codeland, watercooler
Published: 2022-04-14 15:47:37

We're in the midst of prepping for [CodeLand 2022](https://community.codenewbie.org/codenewbie/codeland-2022-is-coming-in-june-submit-your-talk-today-2gnc), which is set to happen June 16 & 17 in the [CodeNewbie Community](https://community.codenewbie.org/).

As part of our preparations, we're looking for a fun game or activity that we could do as a ~~group~~ mob. 😀

In the past, we had a fun little game hosted by Twilio called Nom Nom where we split everybody into 2 teams and gave folks control over 2 Roomba vacuums — the first team to vacuum up the other teams confetti was declared winner. It's wonderfully chaotic and as goofy as it sounds, but hopefully easy to understand how fun it is when you watch the video:

{% embed https://youtu.be/V6nAePEEAZQ %}
Skip ahead to 5:05:39 or [click here](https://youtu.be/V6nAePEEAZQ?t=18339) to be taken directly to the Nom Nom game.

**So, anybody got any ideas for an activity that would be fun for a big group of folks to take part in online?** 

_Note: We need to keep things rolling, so I'm going to put a deadline on this discussion for next Tuesday, April 19th at 6 PM UTC._
Serve machine learning models with Pinferencia
Tags: machinelearning, programming, python, ai
Published: 2022-04-14 15:47:28

When reading this post, you perhaps have already known or tried torchserve, triton, seldon core, tf serving, even kserve. They are good products. However, if you are not using a very simple model or you have written many codes and the model is just a part of it. It is not that easy to integrate your codes with them.
Here, you have an alternative: **Pinferencia** (More tutorial, please visit:https://pinferencia.underneathall.app/)

Github: [Pinferencia](https://github.com/underneathall/pinferencia) - If you like it, give it a star.

## Install

```bash
pip install "pinferencia[uvicorn]"
```

## Quick Start

**Serve Any Model**

app.py
```python
from pinferencia import Server


class MyModel:
    def predict(self, data):
        return sum(data)


model = MyModel()

service = Server()
service.register(
    model_name="mymodel",
    model=model,
    entrypoint="predict",
)
```

Just run:
```
uvicorn app:service --reload
```

Hooray, your service is alive. Go to http://127.0.0.1:8000/ and have fun.

You will have a full API documentation page to play with:
![swagger ui](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k43ikxxyuiscitiqtx4s.png)

You can test your model right here: 

![try it out](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0crd6lxyk6woq3fwxe3f.png)
 

**Any Deep Learning Models?** Just as easy. Simply train or load your model, and register it with the service. Go alive immediately.

**Pytorch**

```python
import torch

from pinferencia import Server


# train your models
model = "..."

# or load your models (1)
# from state_dict
model = TheModelClass(*args, **kwargs)
model.load_state_dict(torch.load(PATH))

# entire model
model = torch.load(PATH)

# torchscript
model = torch.jit.load('model_scripted.pt')

model.eval()

service = Server()
service.register(
    model_name="mymodel",
    model=model,
)
```

**Tensorflow**

```python
import tensorflow as tf

from pinferencia import Server


# train your models
model = "..."

# or load your models (1)
# saved_model
model = tf.keras.models.load_model('saved_model/model')

# HDF5
model = tf.keras.models.load_model('model.h5')

# from weights
model = create_model()
model.load_weights('./checkpoints/my_checkpoint')
loss, acc = model.evaluate(test_images, test_labels, verbose=2)

service = Server()
service.register(
    model_name="mymodel",
    model=model,
    entrypoint="predict",
)
```

Any model of any framework will just work the same way. Now run `uvicorn app:service --reload` and enjoy!
#66 Days of Data
Tags: python, datascience, mrankitgupta, ankitgupta
Published: 2022-04-14 15:42:06

## **Learning Python**  👨‍💻

D 54 | 55 of #66daysofdata 📈

Today done with Statistics - Intro, Descriptive statistics - Mean, Median, Mode, Variance, & Standard deviation, Data Visualization 👨‍💻

Checkout 👉 [My #66 Days of Data timeline on Github](https://github.com/mrankitgupta/66DaysOfData)

Say me Hi! 
I'll be glad to connect on 
👇

**Twitter** @ [MrAnkitGupta_](https://twitter.com/MrAnkitGupta_)

**Github** @ [MrAnkitGupta](https://github.com/mrankitgupta)

**LinkedIn** @ [MrAnkitGupta](https://www.linkedin.com/in/mrankitgupta)
Synchronous Rendering
Tags: react
Published: 2022-04-14 15:38:56

I have a WebGL context that updates on a frame-loop, within a broader React application.

I want to create a second React application to overlay an SVG element above the WebGL context, but critically I need this SVG element to update synchronously in the same frame that the WebGL context renders.

I understand that in most cases asynchronous rendering is a feature not a bug, but in my use-case, I need frame-by-frame integration between the WebGL update cycle and the SVG DOM updates.

It doesn't look like this is possible. `flushSync` forces updates, but doesn't force rendering. Is there a `renderNow` or similar function hiding in the React API?

Thanks in advance, Alec
Hibernate - LAZY fetching
Tags: hibernate, database, spring
Published: 2022-04-14 15:37:19

## I know what is LAZY in theoretically. Tell me in a real world scenario!!!

> Consider an online store, which is a standard Internet web application. A product catalog is kept at the store. This may be depicted as a catalog entity handling a collection of product entities at the most basic level. There might be tens of thousands of goods divided into many overlapping categories in a large store.
> The catalog must be loaded from the database when a consumer enters the store. We presumably don't want the implementation to load each and every one of the entities that represent the tens of thousands of goods into memory. Given the amount of physical memory available on the system, this may not even be practical for a sufficiently big store.
> Even if this were possible, the site's performance would almost certainly suffer as a result. Instead, we'd like the catalog to load first, followed by the categories. Only a fraction of the goods in each category should be loaded from the database when the user digs down into the categories.
> Hibernate includes a feature called lazy loading to address this issue. When enabled, the associated entities of an entity will only be loaded when they are specifically requested.


## How can 'LAZY' solve the above problem?  🐌

Look at the below manner:

```java
//Following code loads only a single category from the database
Category category = (Category)session.get(Category.class,33);
 
//This code will fetch all products for category 33 from database
Set<Product> products = category.getProducts();
```

This solves the problem right? Now, Hibernate will make it for you... Look at the below code snippet:

```java
@OneToMany( mappedBy = "category", fetch = FetchType.LAZY )
private Set<ProductEntity> products; 
```


## To sum up

Advantages:

- Much smaller initial load time than in the other approach
- Less memory consumption than in the other approach

Disadvantages:

- Delayed initialization might impact performance during unwanted moments.
- In some cases we need to handle lazily initialized objects with special care, or we might end up with an exception. (which will be mentioned in the next post)
Creating Github pull request templates
Tags: github, webdev, tutorial, programming
Published: 2022-04-14 15:25:54

## Getting started

To create a template for your repository all you need to do is create a file named PULL_REQUEST_TEMPLATE.md in either:
- a .github folder - my preferred option here
- the root of your project
- a docs folder

Once this is pushed to the default branch for the project Github will start using it as the default template for new pull requests. It's as simple as that! ✨

## The benefits

There are many benefits to setting up a default pull request template. The biggest is consistency, all of the developers working on that project will fill out a consistently structured pull request making them easier to read and review.

Another great benefit of setting up a template is that it could prompt the submitter for extra detail. For example this may be screenshots of their changes or requiring them to fill out a checklist of pre-submission tasks.

Gone will be the days of opening up a pull request to see those dreaded words "No description" - That's just not helpful to anyone. Now you and your collaborators can finally open a PR and quickly understand what the change is and why it's been created.

## My templates

I've composed a few templates below to help you get started, these can all of course be customised and chopped apart to suit your needs!

### Internal team collaboration project
```markdown
## Description 📋

Please include a summary of the changes made in this PR.

## Type of change 🤔

Please tick any that are relevant to this PR and remove any that aren't.

- [ ] Bugfix 🐛
- [ ] Feature 🥳
- [ ] Refactoring 🤓
- [ ] CI 🤖
- [ ] Documentation 📒
- [ ] Tests 🧪
- [ ] Other (please detail in description) ❓

## Screenshots 📷

If possible provide screenshots of your visual changes to make it easier for reviewers.
```

### Open source project
```markdown
## Description 📋

Please include a summary of the changes made in this PR and provide any context necessary for the change.
Fixes # (issues)

## Type of change 🤔

Please tick any that are relevant to this PR and remove any that aren't.

- [ ] Bugfix (non breaking change which resolve an issue)
- [ ] Feature (non breaking change which adds functionality)
- [ ] Breaking Change (a change which would cause existing functionality to not work as expected)
- [ ] Documentation (a change to documentation)

## Submission checklist ✅

- [ ] I have performed a self review of my changes
- [ ] I have updated the documentation where relevant
- [ ] My changes are well written and all ci is passing
```

### Minimal
```markdown
## Description 📋

Please include a summary of the changes made in this PR and provide any context necessary for the change.

```
Introduction to GitLab CI | What is GitLab CI | GitLab Tutorial For Beginners | Part I
Tags: devops, beginners, tutorial, git
Published: 2022-04-14 15:02:35

GitLab is an open-source end-to-end DevOps platform that leverages the upstream concepts of Agile Methodologies, DevOps, and Continuous Delivery. [Start FREE Testing](https://accounts.lambdatest.com/register?utm_source=devto&utm_medium=organic&utm_campaign=apr14_sb&utm_term=sb&utm_content=tutorial_video)!

Integrate GitLab with LambdaTest: [https://bit.ly/3ti02GM](https://bit.ly/3ti02GM)


This is Part 1 of the GitLab Tutorial for beginners, wherein Moss(@tech_with_moss), a DevOps engineer, introduces you to the GitLab CI, the fundamental commands of Git, and showcases how to work with GitLab using GitLab flow. He further explains how to migrate from Jenkins Pipelines to GitLab and deploy software using GitLab packaging and releasing features. 

This video will help answer the following questions 🎫 -: 
🔹What is GitLab CI?
🔹Why GitLab is used?
🔹How does GitLab CI work?
🔹What is the difference between Git and GitHub and GitLab?
🔹How do I migrate from Jenkins to GitLab?

In this video tutorial module, Moss helps you learn the basics of Git and understand what is GitLab. You will get to know the major components of the GitLab interface, basic workflow in GitLab called GitLab flow, and multiple examples of performing activities with the GitLab flow. Further, deep-diving into more advanced topics of how to do CI/CD in GitLab, explore GitLab packaging and releasing, and learn how to integrate LambdaTest platform with GitLab CI/CD and perform cross browser testing.
Paracetamol.js💊| #101: Explica este código JavaScript
Tags: javascript, spanish, webdev, beginners
Published: 2022-04-14 15:01:28

## **<center>Explica este código JavaScript</center>**
#### <center>**Dificultad:** <mark>Avanzado</mark></center>
**¿Cuál de las siguientes funciones es pura?**
```js
//#1
const returnNumber = num => num;
console.log(returnNumber(Math.random()));

//#2
const returnDate = date => date;
console.log(returnDate(Date.now()));

//#3
const getApi = (api) => {
  return fetch(api)
    .then(res => res.json())
    .then(response => console.log(response))
}
console.log(getApi("https://jsonplaceholder.typicode.com/users"));

//#4
const exp = (x, y) => x ** y;
console.log(exp(2,8));
```

A. `getApi` y `returnNumber` son funciones puras
B. Ninguna es una función pura
C. Todas son funciones puras
D. Solo `exp` es una función pura

Respuesta en el primer comentario.

---