teleren/devto huggingface dataset:
Ruby: nested hash iterations
Tags: ruby, programming, tutorial, opensource
Published: 2022-10-15 15:59:58

## How to iterate over nested hashes in ruby?

Before we can iterate through nested hashes, we must first know what a hash is. 

hash: a hash is a collection of keys and values enclosed in curly brackets, hashes are identical to javascript objects.

nested hash ex: 

```
 apple = {
 "Hardware Products" => {
   :computers => "Mac",
   :laptops => ["Macbook Pro", "Macbook Air"],
   :tablets => ["Ipad Air", "Ipad Pro"],
   :phones => "Iphone"
   },
   "Software Products" => {
    :entertainment => ["Apple Music", "Apple Tv", "Apple Podcast"],
    :finance => ["Apple Wallet", "Apple Card"],
    :other => ["Apple Fitness", "Apple Maps"]
   }
   }
```

_nested hash of Apple's Hardware and Software products_

The code block above is an example of a nested hash. A <u>nested hash</u> is normally a **value pair** in a hash. 


Now that we are clear on what a hash is, how do we iterate over the nested hash? 

**example deliverable:** _output the :finance value["Apple Wallet", "Apple Card"]to the terminal._

<u>step 1</u>: 
    Iterate over the parent hash using each method, set two parameters to reference the key and value (**product_type, inventory**).

``` 
finance_products = apple.each do |product_type, inventory|
puts "product_type: #{product_type}"
puts "inventory: #{inventory}"
end

=> product_type => "Hardware Products"

=> inventory: => {
   computers => "Mac",
   laptops => ["Macbook Pro", "Macbook Air"],
   tablets => ["Ipad Air", "Ipad Pro"],
   phones => "Iphone"
   }

=> product_type => "Software Products"

=> inventory: => {
 :entertainment => ["Apple Music", "Apple Tv", "Apple Podcast"],
 :finance => ["Apple Wallet", "Apple Card"],
 :other => ["Apple Fitness", "Apple Maps"]
}

```

<u>step 2</u>: 
    Using a [conditional statement]
(https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/conditionals)  _(more on conditionals here)_ we access the value in "Software Products". Then iterate over value(**inventory**) and pass 2 parameters, these will reference the nested hash keys and values! 

```
finance_products = apple.each do |product_type, inventory|

if product_type == "Software Products"

inventory.each do |product, type|
puts "product: #{product}"
puts "type: #{type}"
    end
   end
  end

"terminal output"

product: entertainment
type: ["Apple Music", "Apple Tv", "Apple Podcast"]
product: finance
type: ["Apple Wallet", "Apple Card"]
product: other
type: ["Apple Fitness", "Apple Maps"]
```

<u>step 3</u>: 
    Using a conditional statement to retrieve the :finance key from (**product**), we then iterate over the values(**type**) using each method and pass a parameter(**finance**) and print (**finance**) to meet the deliverable. 

```
finance_products = apple.each do |product_type, inventory|

if product_type == "Software Products"

inventory.each do |product, type|

if product == :finance

type.each do |finance|
puts "#{finance}"

    end
   end
  end
 end 
end

"terminal output"

Apple Wallet
Apple Card
```
Up and running with Azure Functions
Tags: azure, azurefunctions, faas, serverless
Published: 2022-10-16 03:28:29

---
title: Up and running with Azure Functions
published: true
date: 2022-10-15 15:58:01 UTC
tags: #azure #azurefunctions #faas #serverless
canonical_url: https://blog.cloudbuff.in/up-and-running-with-azure-functions
---

This is a series of articles to help get started with Azure Functions.

1. [Azure Functions: overview of concepts](https://dev.to/sjejurkar/up-and-running-with-azure-functions-part-1-1j22)
2. [Creating our first Azure Function](https://dev.to/sjejurkar/up-and-running-with-azure-functions-part-2-150d)
3. [Deploying our first function to Azure](https://dev.to/sjejurkar/deploying-our-first-function-to-azure-1kcb)
4. [Azure Function with Storage Queue Trigger](https://dev.to/sjejurkar/azure-function-with-storage-queue-trigger-p4p)
5. [Deploying Storage Queue Trigger Function](https://dev.to/sjejurkar/deploying-storage-queue-trigger-function-479k)
6. [Sending Function logs to Log Analytics](https://dev.to/sjejurkar/sending-function-logs-to-log-analytics-i3c)
7. [Azure Functions: Output Bindings](https://dev.to/sjejurkar/azure-functions-output-bindings-5h2k)
8. [Azure Functions: Hosting Plans](https://dev.to/sjejurkar/azure-functions-hosting-plans-28j4)
I made a library to print object as a tree structure like the unix tree command
Tags: javascript, npm, opensource, showdev
Published: 2022-10-15 15:55:11

I'm currently working on a project where I have some hierarchical data that need's to be printed in the console as a tree structure.

At first, I thought let me see if it's available on npm. But before going to npm I told myself: "Why don't I try it myself first?". So I started working on it and by the time I finished it I realized that it's 2 am in the morning 😅. Today I've published the library on npm. It's called [flexible-tree-printer](https://www.npmjs.com/package/flexible-tree-printer).

Example:

```js
import { printTree } from "flexible-tree-printer";

const categories = {
  study: {
    academic: { Math: null, English: null },
    programming: {
      DSA: null,
      "Number Theory": {},
      Backend: {
        "Node.Js": {},
        Sqlite: {},
      },
    },
  },
  work: {
    personal_projects: null,
    job: {},
  },
};

printTree({
  parentNode: categories,
  printRootNode: () => console.log("categories"),
});
```
Running the above snippet produces the following result:

```
categories
├── study
│   ├── academic
│   │   ├── Math
│   │   └── English
│   └── programming
│       ├── DSA
│       ├── Number Theory
│       └── Backend
│           ├── Node.Js
│           └── Sqlite
└── work
    ├── personal_projects
    └── job
```

Almost every behavior of printing is customizable and the library has a very flexible API.

I would love to hear your feedback and kindly give it a ⭐ [GitHub](https://github.com/h-sifat/flexible-tree-printer) if you find it interesting.
Amazing Typing Effect using Typed.js (JavaScript)
Tags: javascript, webdev, beginners, css
Published: 2022-10-15 15:38:52

Hello Guys! Welcome to [Coding Torque](https://codingtorque.com). In this blog, I'm going to explain to you how to make an amazing typing effect using Typed.js. This will be a step-by-step guide including HTML and CSS. Let's get started 🚀.

## **Let's cover HTML Part**
We use HTML to make the skeleton of a website. HTML is a markup language. 

Now let's import the fonts using Google Fonts API. Below is the code for `Poppins` Font. Paste the below code in `<head>` tag.

```html
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Poppins&display=swap" rel="stylesheet">
```

Now let's design the container in our `<body>` tag. In the below HTML code, we have created a container that contains welcome heading and designation which will have a type effect.

```html
<div class="container">
    <h1>Hi! I'm Piyush Patil</h1>
    <h6 style="display: flex; align-items: center;">
        <p id="designation"></p>
    </h6>
</div>
```

Add the below script tag before ending your body tag. This is the CDN of typed.js JavaScript Library

```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/typed.js/2.0.0/typed.js"
        integrity="sha512-ioFpA4cD4gmoOhHglW4f6gep7w+YL7UMKtXx4ebJ5NN4SscmnZYYmSjkA+DaHGvBI4wpYVPx2C7DmmV9TgbIbQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer"></script>
```



## **Here is the final HTML code**

```html
<!doctype html>
<html lang="en">

<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- Google Fonts  -->
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Poppins&display=swap" rel="stylesheet">

    <title>Amazing Type Effect using JavaScript - @code.scientist x @codingtorque</title>
</head>


<body>
    <div class="container">
        <h1>Hi! I'm Piyush Patil</h1>
        <h6 style="display: flex; align-items: center;">
            <p id="designation"></p>
        </h6>
    </div>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/typed.js/2.0.0/typed.js"
        integrity="sha512-ioFpA4cD4gmoOhHglW4f6gep7w+YL7UMKtXx4ebJ5NN4SscmnZYYmSjkA+DaHGvBI4wpYVPx2C7DmmV9TgbIbQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer"></script>
 
</body>

</html>
```


### **Output Till Now**


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

[continue reading](https://www.codingtorque.com/2022/08/amazing-typing-effect-using-typedjs.html)
How to work with Python's normal venv and pipenv simultaneously
Tags: python, venv, shriekdj, pipenv
Published: 2022-10-15 15:17:41

## Why Need to solve this issue.

So I Just Want to Use pipenv but do not want my `venv` folder to built in my automatically decided location and also want to use `pipenv` automatically building the `requirements` list.

So For Resolving this issue I build a method of how to do that.

Straight to the Point The Steps are given below.

### Create Virtual Environment normally with `venv` module

#### For Windows

```powershell
py -3 -m venv venv_folder
```

#### For Linux or Mac Operating System

```bash
python -m venv venv_folder
``` 
or

```bash
python3 -m venv venv_folder
```

### Activate the manually created virtual environment folder

#### For Windows

```bash
# for windows powershell
./venv_folder/Scripts/Activate.ps1

# for windows cmd
./venv_folder/Scripts/activate.bat

# for windows with posix shell like git bash cli
source venv_folder/Scripts/activate
```

#### For Linux Based operating system or MacOS

```bash
source venv_folder/bin/activate
```

if you have any issues activating the venv please refer below post

{% link https://dev.to/shriekdj/how-to-create-and-activate-the-virtual-environment-for-python3-project-3g4l %}

{% link https://dev.to/shriekdj/python-venv-or-virtualenv-wont-activate-on-windows-3e2 %}


### Install pipenv twice

Install the pipenv like given below

```python
pip install pipenv

pipenv install pipenv
Courtesy Notice: Pipenv found itself running within a virtual environment, so it will automatically use that environment, instead of creating its own for any project. You can set PIPENV_IGNORE_VIRTUALENVS=1 to force pipenv to ignore that environment and create its own instead. You can set PIPENV_VERBOSITY=-1 to suppress this warning.
Installing pipenv...
...
```

### Now install packages with pipenv as normal

You will now have pipenv and venv_folder both at the same time to run it.
React Just Got Even More Awesome
Tags: react, webdev, javascript, typescript
Published: 2022-10-15 15:11:58


If you've worked on any react or next.js application in the past, you've probably noticed that it's very unopinionated in general, especially when it comes to how you handle async. Which played a big role in how we've fetched data in our react applications. So far we've either used `useEffect`, `useSWR` or more recently [react-query](https://tanstack.com/query/v4). But now we're getting an exciting new feature in react that will make all things async especially data fetching a lot easier.


## Introducing the use hook
[More info here](https://github.com/acdlite/rfcs/blob/first-class-promises/text/0000-first-class-support-for-promises.md)


Essentially, we're finally getting a native way to handle async functionallity in React. Meaning we don't really need to relly on `useEffect` to fetch our data we can simple create an axios fetch request and wrap it in a `use` hook. 

For example:
```tsx
export const Post = (id:string) => {
  const fetchPost = axios.get(`/api/posts/${id}`));
  const post = use(fetchPost);
  return (
    <div>
      <h1>{post.title}</h1>
      <p>{post.body}</p>
    </div>
  )
}
```
This will fetch the post data and render it on the page. No `useEffect` required or any other async handling library required. 🎉

## How does the use hook work

Similary to `await` it simply unwraps the value of a promise, meaning that any async behaviour can be wrapped in a use hook now and react will natively handle the promise for us.

## Do we still need react-query then?

Yes, we do. While the use hook is a great addition to react, it's still not a replacement for react-query. The use hook is only meant to handle async behaviour, not caching or any other advanced features. So if you're looking for a more advanced data fetching library, react-query is still the way to go. However it's a step in the right direction for the react team and a welcome addition to the react ecosystem. I can't wait to see what the community does with this new feature. 🤩

## Other interesting stuff of note

Unlike all other hooks the `use` hook appears to support conditional execution. Much like react-query's `enabled` option. This means that we can conditionally fetch data based on some condition. This is of course not supported by other hooks and it appears that the use hook is the only hook will support this. A cool future proposal in the RFC is that we can wrap React Context in a use hook as well. Which would allow us to use context in a more declarative way. Not sure if this will make it into the final RFC but it's an interesting idea.


## Conclusion

This is by far one of the coolest upcoming features in react. I personally can not wait to use it in my next project. I'm sure we'll see a lot of interesting use cases for this new hook. If you're interested in learning more about the use hook, I highly recommend you check out the RFC. It's a very interesting read and it's a great insight into how the react team thinks about new features.
picity high park
Published: 2022-10-15 15:09:35

Đối với mọi biên bản hoặc văn bản pháp lý và biên bản bàn giao nhà cho thuê cũng vậy luôn cần phải đạt được một số yêu cầu đã được quy định cụ thể. Hãy cùng picity high park tìm hiểu về thông tin này nhé.
https://nha.chotot.com/du-an-picity-high-park-quan-12-pj1745608650
#duanpicityhighpark #duanbatdongsan #muabanpicityhighpark #chothuepicityhighpark #nhatot
How to setup pyspark with Jupyter Notebook for Data Engineer
Tags: beginners, tutorial, python, datascience
Published: 2022-10-15 13:55:36

I have to conclusion how to setup pyspark for building ETL pipeline with Jupyter Notebook by summary step like this.

**First step**, Install [python 3.9.1] (https://www.python.org/downloads/release/python-391/) for use on python.

**Second step**, install scala `$ brew install scala`

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

**Third step**, start with `$ pyspark`

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

**Fourth step**, run data frame

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

Reference: [apache-spark](https://www.bmc.com/blogs/jupyter-notebooks-apache-spark/), [Getting started with mongodb, pyspark and jupyter-notebook](https://www.mongodb.com/blog/post/getting-started-with-mongodb-pyspark-and-jupyter-notebook), [How to install pyspark on mac](https://sparkbyexamples.com/pyspark/how-to-install-pyspark-on-mac/)
Share a Screenshot of Your Terminal 💻
Tags: terminal, programming, discuss
Published: 2022-10-15 15:01:33

Curious to see what everyones terminal looks like. I know us developers spend hours, days, weeks, months, and sometimes years configuring them to look perfect.

I'll go first 😎.

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

Don't be discouraged if you have a stock terminal or minimal customizations we still want to see.

If you're interested in any of my setup, checkout out my [dotfiles](https://github.com/hacksore/dotfiles).
Day25 of #100DaysOfCode
Tags: 100daysofcode, webdev, javascript, tailwindcss
Published: 2022-10-15 14:47:53

As [Hashing.Energy](hashing.energy) is online now, I have found out that there are a few bugs that I need to fix.  I didn’t get to fix it today but I have listed it all out.

Also the articles on the website will need custom artworks.

I do also wish I’m better at design…

I also drafted a few wireframes for the company pages and energy profile pages.

The goal of Hashing.Energy is to be the go-to site to learn more about the impact Bitcoin mining has to different energy sectors.

I believe it will be beneficial to bitcoin miners and energy players alike.

Plus, it’s so much fun to learn how to code using this project as a hands on experience!
Default vs Named exports
Tags: javascript, webdev, beginners, react
Published: 2022-10-15 14:47:09


There are two primary ways to export values with JavaScript: default exports and named exports. But you can use one or both of them in the same file. A file can have not more than one default export, but it can have as many named exports as you like

Export Statements:
`export default function Button() {} // default export 
export function Button() {}  // named export`

Import Statements:
`import  Button  from './button.js';   // default export 
import { Button } from './button.js';   // Named export `


When you write a default import, you can put any name you want after import. 
For example, you could write 
`import Banana from './button.js' `
and it would still provide you with the same default export. 
In contrast, with named imports, the name has to match on both sides. That’s why they are called named imports!
A maior de todas as fraquezas é o medo de parecer fraco
Tags: career
Published: 2022-10-15 14:42:57

"A maior de todas as fraquezas é o medo de parecer fraco".

Quem disse essa frase foi J.B Bossuet em A politica tirada da Sagrada Escritura.

Não me pergunte o porquê mais eu leio coisas assim. E sim, adoro saber e aprender sobre politica e desenvolvimento humano.

As pessoas por natureza são ótimas para transmitir conhecimento até que elas se sintam ameaçadas.

Enquanto as pessoas não conseguem uma relação de ganha-a-ganha nesse processo, elas se retraem de maneira assustadora, inclusive para elas mesmas.

Nunca é fácil a escolha do não compartilhamento.

Voce já deve ter ouvido dizer que alguns Devs naturalmente não realizam esses movimentos de compartilhar, por serem pessoas introvertida, pode até ser se voce achar que as pessoas desenvolvedoras precisam ser palestrantes. 

Mas no momento que alguém escreve um código, que revisa ou escreve um pull request, o como testar ou a regra de negócio,  ou responde um questionamento, ele está compartilhando conhecimento.

Todo nosso processo evolutivo foi baseado em criar formas de transmissão de conhecimento.
A própria cultura ágil de software tem muito disso.

Quando voce se sente ameaçado por compartilhar conhecimento, impressões, vivências ou tarefas, talvez seja porque você ainda não tenha percebido o quanto voce ganha nessa escolha.

Ter a noção clara de que cada conhecimento transmitido permite que a gente fique pronto para novos aprendizados e tem muito mais a se evoluir do que imaginamos.

Caixas quando estão cheias precisam remover itens para dar espaço para que novos itens ocupem e complete o "vazio" criado.

É muito bom abrir a internet encontrar uma documentação, um relato de um problema que alguém superou, é bom diante de um novo desafio encontrar uma literatura que te ajude a trilhar o caminho, não é? Então, o que te impede de ser parte disso?

Quando a gente se encontra em posição que outros ainda poderão precisar superar, nada mais humano que a gente pavimente esse caminho.

Pavimentar o caminho é não ter medo de passar suas impressões em determinadas situações, não ter medo é sinal de confiança em você e nas pessoas.

Preparar o caminho para quem vem depois é aceitar ser mentor de alguém que sofrem por situações que voce ja vivenciou ou tem conhecimento acumulado que os ajudem a superar mais facilmente que você, pois essa é a grandeza de quem é desbravador.

A humanidade se desenvolve ao pensar novos problemas e não em esperar dias na busca por uma solução já existente e que uma resposta sua na rede social já teria ajudo muito.

Ter tempo de aprender a aprender é justo, ter a dor do crescimento é justo, injusto é o silêncio, o ignorar, as respostas vazias que não colaboram, injusto é fingir apoio e nunca ficar disponível.

Enfim, devaneios de um sábado nublado e sem pedais por sp.
Deep Inside Django's ORM @ DjangoCon EU 2022
Tags: python, django
Published: 2022-10-15 14:41:46


## Slides

You can find the slides here:

[https://bas.surf/djangoconeu22-slides](https://bas.surf/djangoconeu22-slides)

## Recording

Also there is a recording of my talk on DjangoCon Europe's YouTube channel:

{% embed https://www.youtube.com/embed/OEN5wONsaYU %}
Useful Ressources
Tags: codenewbie, beginners
Published: 2022-10-15 14:38:55

Hello,
I am a student who learn programming.
Here is some ressources that i find really useful :
- [Carbon](https://carbon.now.sh/) : Share nice images of your code
- [Regexr](https://regexr.com/) : Test your regexs. Even the hardest one to understand.
- [CoderPad](pad.new) : Online IDE, that supports 36 languages. Practice when you need to test fast a code without installing a hole environnement
- [Coolors](coolors.co/generate) : Generate colors that are nice together. Really useful for font-end dev.
- [Canva](canva.com) : Make fast designs to explain your code projects.
- [Fancy Text generator](https://fancy-text.net/fr/) : Generate Fancy Text
- [HTTP Cats](https://http.cat/) : Learn HTTP error codes with funny pictures of cats
- [have i been pwned?](https://haveibeenpwned.com/) : Check if your mail or you phone number is in a data breach
I hope it will help you as it helps me.
PS : Share in comments the sites that you find useful.