teleren/devto huggingface dataset:
What is Blockchain and How Does it Work?
Tags: webdev, blockchain, web3, beginners
Published: 2023-01-09 18:04:20

##Introduction:

Blockchain is a decentralized, distributed ledger that records transactions on multiple computers so that the record cannot be altered retroactively without the alteration of all subsequent blocks and the consensus of the network. In this article, we'll take a closer look at what blockchain is and how it works.

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

##What is Blockchain?

A blockchain is essentially a chain of blocks that contain information. Each block in the chain contains a set of transactions, a timestamp, and a link to the previous block. When a new transaction is added to the blockchain, it is grouped with other transactions into a block. The block is then added to the blockchain, creating a permanent and unalterable record of the transaction.

##How Does Blockchain Work?

_Here is a simple example of how a blockchain works:_

1. Alice wants to send Bob 1 bitcoin.
2. The transaction is broadcast to the network and verified by multiple computers on the network.
3. Once the transaction is verified, it is added to a block along with other transactions.
4. The block is added to the blockchain, creating a permanent and unalterable record of the transaction.
5. The transaction is complete, and the ownership of the bitcoin is transferred from Alice to Bob.

##Benefits of Blockchain

_There are several benefits to using blockchain technology:_

- Decentralized and distributed: Because the blockchain is decentralized and distributed across a network of computers, it is secure and resistant to tampering.
- Transparent: All transactions are recorded and visible to anyone on the network.
- Efficiency: Blockchain technology can streamline processes and reduce the need for intermediaries, which can save time and money.
Examples of Blockchain Technology

Blockchain technology has many practical applications beyond just cryptocurrency. Some examples of blockchain technology include:

1. Smart contracts: Blockchain technology can be used to create self-executing contracts with the terms of the agreement between buyer and seller being directly written into lines of code.
2. Supply chain management: Blockchain technology can be used to track the movement of goods from the point of origin to the point of sale, improving transparency and reducing the risk of fraud.
3. Identity verification: Blockchain technology can be used to create secure and immutable records of identity, which can be useful for applications such as voting and immigration.

##Conclusion

Blockchain is a powerful and innovative technology with the potential to greatly impact various industries. From enabling secure financial transactions to streamlining supply chain management, the possibilities are endless. As the technology continues to evolve and mature, we can expect to see even more exciting developments in the world of blockchain.

I hope this article was helpful in giving you a basic understanding of what blockchain is and how it works!
Automatic Show/Hide FAB on scroll in Flutter
Tags: flutter, beginners, dart
Published: 2023-01-09 18:03:36

Hello readers, Welcome back to another article on flutter.

In this we will see how to hide or show the Floating action button in flutter app when the user scrolls the screen.

Sometimes it is required to hide the FAB button when user scrolls because it blocks the behind view of the screen.

**So this is what we want to do today.**

![Task To Achieve Today](https://miro.medium.com/max/750/1*T7AFJnzpcjgSkGbaLWGeoQ.gif)

**Creating Scroll View**
First create a screen with any scrolling view like list view or grid view in it and a Floating action button.

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

Now to hide the fab on scroll we need to listen to the scrolling events of scroll view.
To listen to the scrolling events we need to give the scroll view a custom scroll controller.
![Code](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tja1ma8zmdmo6ky83kdl.png)
Now we can listen to the scroll events of this list view by add callback to the scroll controller .

**Creating Custom FAB**
Now create a custom Floating action button which will hide/show automatically based on the scroll event. To do this first create a stateful widget and return FAB in the build method.
![Code](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ce5h2o2ds1qw0fto18oe.png)
Now wrap this FAB inside visibility widget to hide or show the Fab.
Create a Boolean variable **isVisible** to control the visibility of the visibility widget.

![Code](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0jn2jste8ucmpwfwazvr.png)



Now in the constructor of this **CustomFab** widget add a parameter of Scroll Controller. So that we can listen scroll events in this widget.

In the **initState** method of this widget add a callback to this scroll controller.
![Code](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hb87bi2tk68wjzjjnpam.png)
Now add a condition that if user scroll down make isVisible to false and if user scrolls up name isVisible to true.

To do this we can use the **controller.position.userScrollDirection** property of controller. This will give the direction in which the user is scrolling(forward or reverse).

Using this we can add a if condition in callback to show / hide our FAB and update the UI by calling **setState**.

![Code](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/54ej4qlb3dxqfryaue4n.png)



set the visible parameter of Visibility widget to **isVisible**.

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

**Another Example**
Using similar method we can also achieve something like this with extended Floating action button.

![Code](https://miro.medium.com/max/750/1*B_y_0ihuHhsro4NTHj8Ahw.gif)



## Follow Me

Thanks For reading this article until now, If you liked this than you can also read more articles and follow me.
{% embed https://medium.com/@aakashpp %}
{% embed https://dev.to/aakashp %}
{% embed https://twitter.com/Aakash_P_ %}
How to make some extra money as a student/independent developer
Tags: earning, money, sideincome, opensource
Published: 2023-01-09 17:29:38

If you want to work on interesting open-source projects and make a few bucks, this [application](https://play.google.com/store/apps/details?id=com.codesluice.codesluice) provides a list of verified projects. You can apply to join a project as a developer or designer. Some of the projects offer stipends so you can make some money.

There are only few projects at the moment so you might want to check the list from time to time. Right now there are projects mostly for mobile (Flutter) and backend developers.
Zonas y regiones de Google Cloud
Tags: cloud, zones, region, googlecloud
Published: 2023-01-09 17:24:23

Google Cloud se ejecuta en la propia red global de Google y esta contruida para tener un buen rendimiento y baja latencia.

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

Cada lugar se divide en regiones y zonas. Las regiones son un área geográfica independientes entre si y cada una de ellas tiene diferentes zonas. Es en la zona donde se implementan los recursos de Google Cloud.

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

Esto ayuda mucho para poder crear aplicaciones a los usuarios de todo el mundo debido a que la distancia de los recursos es más corta y, también para la protección de la información cuando exista problemas en una región, por ejemplo, debido a un desastre natural.

Existen servicios de Google Cloud que permiten colorcar los recursos en diferentes regiones, conocido como “regiones múltiples”. Esto ayuda a tener la información en diferentes zonas, de diferentes regiones.

Google Cloud actualmente tiene 106 zonas en 35 regiones.

Si deseas ayuda para elegir que región teniendo en cuenta la huella de carbono, el precio, el tráfico y la latencia puedes utilizar [Google Cloud Region Picker](https://cloud.withgoogle.com/region-picker/).
Bet on me in 2023
Published: 2023-01-09 17:17:46

***Cross post from [Emmettnaughton.com](https://emmettnaughton.com)***

I don't make asks very often. I try to give way more value to others and see them win, but this year 2023 is the year I ask for what I want, and what I deserve. 


### What I am looking for 
- Remote role
- A place to grow and help others 
- Build meaningful things/support meaningful missions 


### My experience in the Emergency Room is a benefit to you! 

Talking to patients in stressful situations. A lot of times the worst day of their life. Making sure they felt comfortable and heard about their problems and struggles. Translates directly to taking care of customers who have questions and complaints. 

### Running a Community Slack Channel

Another skill I have is running and building community. I run a community for Dads that Code.  [#CoderDads](https://coderdads.carrd.co/) 

Building a community around Dads that have similar stories to mine has given me a lot of pride and hope for the future. Dads getting to buy their first house, Dads doubling their salary from selling car tires to being a developer.

It's also taught me that I am not alone in the journey and to share my daily struggles. 


## 2023: I'm gonna bet on me, and so should you. 

I will bring the ability to build meaningful products, and build customer relationships that will last and turn your customers into advocates for your product. I have the skills and ability to jump right in and start building. Let's chat.
Day 6: Making Cool Raspberry Pi Projects even Cooler with Voice AI (1/4)
Tags: raspberrypi, challenge, 100daysofcode, beginners
Published: 2023-01-09 17:15:00

The next four days we'll show how to make your cool Raspberry Pi projects even cooler with voice AI.

**Adding a Wake Word**
Even if you do not know what wake word is, you probably know Alexa, Hey Siri or OK Google. They're wake words. Wake words activate dormant software. Wake words engines detect those special words to trigger an action such as listening to voice commands. 

Picovoice [Porcupine Wake Word](https://picovoice.ai/platform/porcupine/) Engine allows you to train custom wake words (e.g. Jarvis, Porcupine, *insert your RPI project name*) for Raspberry Pi. Even better? It can run on Raspberry Pi Zero in real time.

You might be asking why you need a wake word engine when you can do everything with an ASR (automatic speech recognition) engine. It's a bad idea because ASRs

- are highly computational, requiring a large number of resources,
- have known accuracy challenges when it comes to proper nouns and homophones,
- may wait for decoding until the end of the recording.

[If you want to learn more details, here's an [article](https://picovoice.ai/blog/using-asr-for-wake-word-recognition/)]

In this demo we'll use Raspberry Pi Zero - ReSpeaker

**Requirements**

```
sudo apt-get install libasound2-dev
```
**AccessKey**
If you don't have one, you can get your AccessKey from the [Picovoice Console](https://console.picovoice.ai/) for free.

**Build**
```
gcc -std=c99 -O3 -o demo/respeaker-rpi0/porcupine_demo_mic \
-I include/ demo/respeaker-rpi0/porcupine_demo_mic.c \
-ldl -lasound
```
**Run**
{% embed https://www.youtube.com/watch?v=Fi_IJEcNr3I %}
Below are the colors associated with supported wake words for this demo:

```
#ffff33 Alexa
#ff8000 Bumblebee
#ffffff Computer
#ff0000 Hey Google
#800080 Hey Siri
#ff3399 Jarvis
#00ff00 Picovoice
#0000ff Porcupine
#000000 Terminator
```

From the root of the repository run:
```
./demo/respeaker-rpi0/porcupine_demo_mic \
${ACCESS_KEY} \
lib/raspberry-pi/arm11/libpv_porcupine.so \
lib/common/porcupine_params.pv \
0.65 \
plughw:CARD=seeed2micvoicec,DEV=0 \
resources/keyword_files/raspberry-pi/alexa_raspberry-pi.ppn \
resources/keyword_files/raspberry-pi/computer_raspberry-pi.ppn \
resources/keyword_files/raspberry-pi/hey\ google_raspberry-pi.ppn \
resources/keyword_files/raspberry-pi/hey\ siri_raspberry-pi.ppn \
resources/keyword_files/raspberry-pi/jarvis_raspberry-pi.ppn \
resources/keyword_files/raspberry-pi/picovoice_raspberry-pi.ppn \
resources/keyword_files/raspberry-pi/porcupine_raspberry-pi.ppn \
resources/keyword_files/raspberry-pi/bumblebee_raspberry-pi.ppn \
resources/keyword_files/raspberry-pi/terminator_raspberry-pi.ppn
```

Wait for the demo to initialize and print `[Listening]` in the terminal. 
Say:
`Picovoice`
The demo outputs: detected 'Picovoice'
The lights are now set to green. 
Say:
`Alexa`
The lights are set to yellow now. 
Say:
`Terminator`
to turn off the lights.
Can you make creative button? With using HTML and CSS?
Tags: tutorial, css, html
Published: 2023-01-09 17:12:12

Hello there!
I'm Jalol and I want to teach you how to make a creative button with using HTML&CSS!

First lets create `a`:
```
<a href="#" class="btn">Creative Button</a>
```
And add some styles:

```
.btn{
  font-size: 30px;
  font-family: sans-serif;
  background: #fca311;
  text-decoration: none;
  color: #fff;
  padding: 20px 30px;
  border-radius: 10px;
  outline: 3px solid #fca311;
  transition: .2s;
  outline-offset: 0;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%)
}
```
And let's add hover effect:

```
.btn:hover{
  outline-offset: 5px;
}
```
And done!
If you want to see preview site here's codepen link: https://codepen.io/nurjalol/pen/MWBJrpN

Hope it's helpful! 👨‍💻
Stay with me! 😁
What bootcamps, programs or online learning have you done?
Tags: javascript, beginners, webdev, programming
Published: 2023-01-09 17:05:39

Comment a testimony of where the best place to learn how to code is and why!

Shout out to our good friend Patricia for the photo! 
( @patrycjaio - IG )
( @VSchool_ - IG )

https://www.instagram.com/p/CmcRiplBeCI/
Auth Guarding in react
Tags: authentication, react, reactrouter, javascript
Published: 2023-01-09 16:55:09



After we authenticate we might want to guard certain routes and redirect to the login page if not authenticated

the most common way to do it is 

```ts
import { Navigate } from 'react-router-dom';

export const ProtectedRoute = ({ user,children }) => {
  if (!user) {
   return <Navigate to="/login" replace />;
    }
  return children;
  };

```

and wrap the childern with the component
```ts
          <Routes>
            <Route
              path="/"
              element={
                <ProtectedRoute user={user}>
                  <Home user={user} />
                </ProtectedRoute>
              }
            />
            </Routes>
```

but with the react-router v6+ routes can be nested inside layouts which unlocks new patterns

```ts
import { useEffect } from 'react';
import { useNavigate } from 'react-router-dom';
import { PBUser } from '../../utils/types/types';

export const useAuthGuard = (user:PBUser,test_mode:boolean) => {
    const navigate = useNavigate();

    useEffect(() => {
        if (!user?.email && !test_mode) {
            navigate("/auth");
        }
    }, [user?.email]);
};
```
and use the hook in the main layout or layout for whichever route you want to guard

```ts
import { Outlet} from 'react-router-dom';
import { Toolbar } from '../../components/toolbar/Toolbar';
import { PBUser } from '../../utils/types/types';
import { useAuthGuard } from './../../shared/hooks/useAuthGuard';

interface RootLayoutProps {
  user: PBUser;
  test_mode: boolean;
}

export const RootLayout = ({user,test_mode}: RootLayoutProps) => {

  useAuthGuard(user,test_mode)

  return (
    <div className="w-full h-full dark:bg-slate-900">
      <div
        className="h-14 w-full  bg-slate-700 dark:bg-slate-800
          bg-opacity-30 dark:bg-opacity-90 max-h-[50px] p-1
         sticky top-0 z-40"
      >
        <Toolbar user={user} />
      </div>
      <main className=" w-full h-[90%] fixed top-12 overflow-y-scroll">
        <Outlet />
      </main>
    </div>
  );
};

```
Creating an application in Yii3 - part 4: the final
Tags: yii3, php, yiiframework
Published: 2023-01-09 16:48:22

**Part 4:**  The final.

The factory is useful if you need to create objects using [definition syntax](https://github.com/yiisoft/definitions) and/or want to configure defaults for objects created.

```php
$container = new PSR11DependencyInjectionContainer();
$factoryConfig = [
    EngineInterface::class => [
        'class' => EngineMarkOne::class,
        '__construct()' => [
            'power' => 42,
        ],
    ]
];

$factory = new Factory($container, $factoryConfig);

$one = $factory->create(EngineInterface::class);
$two = $factory->create(
    [
        'class' => EngineInterface::class,
        '__construct()' => [
           'power' => 146,
        ],
    ],
);
```

In the code above we define factory config specifying that when we need `EngineInterface`, an instance of `EngineMarkOne` will be created with `power` constructor argument equals to 42. We also specify that all the dependencies requested by the object created should be resolved by `PSR11DependencyInjectionContainer`.

First call to `create()` uses default configuration of `EngineInterface` as is. Second call specifies custom configuration for `power` constructor argument. In this case, configuration specified is merged with default configuration overriding its keys when the key name is the same.

The [factory](https://github.com/yiisoft/factory) always create new instance. The [container di](https://github.com/yiisoft/di) create new instance once and return same on next calls.

Now that we are clear about the concepts of configuration, [container di](https://github.com/yiisoft/di) and [factory](https://github.com/yiisoft/factory), let's see the complexity of creating an app.

```bash
composer create-project --prefer-dist --stability=dev yiisoft/app app-template
```

Take a look at the [configuration](https://github.com/yiisoft/app/tree/master/config), and you'll see that changing it is as simple as changing a parameter in [params.php](https://github.com/yiisoft/app/blob/master/config/params.php), we've developed the right tools, that will do the job for you, that's simplicity.


 **Welcome to Yii3**.

In the next post we will talk about [assets](https://github.com/yiisoft/assets), [view](https://github.com/yiisoft/view), [widget](https://github.com/yiisoft/widget), [db](https://github.com/yiisoft/db) and [active-record](https://github.com/yiisoft/active-record).


Wilmer Arámbula.

[Team Developer YiiFramework](https://www.yiiframework.com/team)
[Twitter follow](https://twitter.com/Terabytesoftw)
The Best Way To Land a JOB in TECH Today!
Tags: aws, webdev, productivity, career
Published: 2023-01-09 16:45:48

This Piece of Advice goes out to all those looking for a job within AWS or any other Tech Job out there this 2023, The best way to flex your Tech skills is use your time Productively, instead of just uploading your CV everywhere and scouring the Net, Develop a Website, for example, check out https://deadkideveloper.click/ I developed this site over the weekend whilst doing prep work for my upcoming #AdvancedNetworking Specialty Exam. A few things stand out immediately to an Employer, just from analyzing the URL, SSL Encryption for example, and the use of your own Domain, it tells them, this Individual Knows how to use #Route53, it also shows them that you understand the importance of Web Security & Encryption using Secure Sockets Layer, using #ACM (Amazon Certificate Manager), behind the scene's sure there is a lot more I had to do to ensure the site is highly available & scalable and is connected to a Backend DB, however, I now have a fully Managed website that I can host my Youtube Channel Video's on that show me not only demonstrating my Ability but also imparting knowledge and sharing with the community as that's what #AWS is all about #communitydevelopment & #buildingtogether
Feel free to check out the link and contact me on the connect with us page to learn more about you can get started (This site was developed using Amazon's Free Tier) only $3 was used to register the domain: https://deadkideveloper.click/
#awscommunitybuilders #webdevelopment #networksecurity #awscertified #ciscochampion #ciscocert #jobhunt #2023goals #interviewtips
#Rust 🦀- Working with threads 🧵 (concurrency)
Tags: englishpost, multithread, rust
Published: 2023-01-10 15:46:27

---
title: #Rust 🦀- Working with threads 🧵 (concurrency)
published: true
date: 2023-01-09 16:39:15 UTC
tags: EnglishPost,EnglishPost,MultiThread,Rust
canonical_url: 
---

Hi !

Working with threads is usually an interesting (challenging) task, when we program in low level languages. I love how easy is to do this in C# or Python, however, multi-threading in C++ is … a super fun moment.

So, the idea behind this is to have sections of code in our application runing in parallel to other sections of code.

And, with just 15 lines of code, we can see how easy is to do this in Rust.

```

use std::thread;
use std::time::Duration;

fn main() {
    thread::spawn(|| {
        println!(" >> Begin thread work, wait 2 seconds ...");
        thread::sleep(Duration::from_millis(2000));
        println!(" >> End thread work ...");
    });

    for i in 0..5 {
        println!("Loop 1 iteration: {}", i);
        thread::sleep(Duration::from_millis(500));
    }
}

```

Our main thread will run a for loop, displaying a message every one second. And a secondary thread, will display a message, wait 2 seconds and then, show a 2nd message.

The output is similar to this one.

```

Loop 1 iteration: 0
  >> Begin thread work, wait 2 seconds ...
Loop 1 iteration: 1
Loop 1 iteration: 2
Loop 1 iteration: 3
  >> End thread work ...
Loop 1 iteration: 4

```

Super easy !

I use the thread::spawn function to create a new thread. The spawn function takes a closure as a parameter, which defines code that should be executed by the thread.

In following posts, I’ll deep a little more in this sample.

Happy coding!

Greetings

El Bruno

More posts in my blog [ElBruno.com](https://www.elbruno.com).

* * *
Why is open source essential for cyber-physical systems (CPS)?
Tags: cps, opensource, microservices, luos
Published: 2023-01-09 16:32:43

🤔 Why is open source essential for cyber-physical systems (CPS)? 

✅ It allows for flexibility and scalability in hardware choice, as well as the ability to reuse and share code and knowledge. 

⏩[Learn more](https://www.luos.io/blog/why-open-source-is-essential-for-cyber-physical-systems) about this