teleren/devto huggingface dataset:
How to check if a key exists in a dictionary python
Tags: python, programming, tutorial, beginners
Published: 2023-03-04 17:08:59

Python dictionary is used to store value as key value pair, unlike python list value inside a dictionary can be accessed using the key.

[Simple Python Dictionary Example](https://www.programdoc.com/python/dictionaries)
```py
d = {"one": 10, "two": 22, "three": 28}
print(d["two"]) # Output: 22
```

when we try to access a key value from dictionary which is not in the variable then it will throw a exception.
```py
d = {"one": 10, "two": 22, "three": 28}
print(d["five"]) 

Error:
Traceback (most recent call last):
File "<string>", line 2, in <module>
KeyError: 'five'
```

## Check if a key exists or not in a dict
To avoid this we can use the [python in membership operator](https://www.programdoc.com/python/operators) to check whether the key is in the dict or not
```py
d = {"one": 10, "two": 22, "three": 28}
print("one" in d)
print("five" in d)

Output:
True
False
```
by checking the key is in or not will help us to avoid keyerror.




### Explore Other Related Articles
[Python try exception tutorial](https://dev.to/max24816/python-try-exception-tutorial-2nlp)
[Python classes and objects tutorial](https://dev.to/max24816/python-class-and-objects-21k6)
[Python Recursion Function Tutorial](https://dev.to/max24816/python-recursion-function-tutorial-3jmo)
[Python Lambda Function Tutorial](https://dev.to/max24816/python-lambda-function-tutorial-1o30)
[Python If, If-Else Statements Tutorial](https://dev.to/max24816/python-if-if-else-statements-tutorial-2g4k)
[Python Function Tutorial](https://dev.to/max24816/python-function-tutorial-5fh0)
Deploying Vite / React App to GitHub Pages
Tags: tutorial, react, vite, github
Published: 2023-03-04 16:57:06

Just follow these simple steps:

#### 1. Install the `gh-pages` package (`ctrl+~` to open the terminal in VS Code)
```
npm install gh-pages --save-dev
```
#### 2. In the `package.json` file add these lines before `"build": "vite build",`
```
"predeploy": "npm run build",
"deploy": "gh-pages -d dist",
```
#### 3. In the `vite.config.js` file add this line before `plugins: [react()],`
```
base: "/YOUR_REPOSITORY_NAME",
```
Change `YOUR_REPOSITORY_NAME` to the name of your GitHub repository.
#### 4. In terminal type
```
npm run deploy
```
🎉 You now have a `gh-pages` branch in your repository and your app is deployed (you can check it under `Settings -> Pages` )

P.S. To update your app deployment, just run the `npm run deploy` command again.
What is Hashicorp Vault? Manage your secrets in production.
Tags: security, javascript, programming, devops
Published: 2023-03-04 16:46:09

## What is hashicorp vault?
It's a cloud-agnostic secrets management system.

API-driven

It allows you to safely store and manage sensitive data in hybrid cloud environments

Used to generate dynamic short-lived credentials, or encrypt application data on the fly.

## What is a secret?
Usernames and passwords

Certificates

SSH Keys

API keys

Encryption keys

What problems does vault solve?
Secrets sprawl

Below are some common places where secrets get stored:

On a developer's computer in excel or notepad files

Hard-coded into the source code.

On a sticky note under an engineer's keyboard

In a version control system such as GitHub and sometimes exposed publicly.

Vault use cases
Secrets management

Centrally store, access, and distribute secrets.
Encrypting application data

Keep application data secure with centralized key management
Identity-based Access

Authenticate and access different clouds, systems, and endpoints using trusted identities.
Secret management
KV Secrets Engine
The idea is to share between the client and the vault. (A client could be a person, user, or application)

The client makes a call to the vault with a specific path(In the vault everything is path based)

Vault checks its policy for authorizing the client to share the secrets.

Encrypting Application Data
Vault provides an EAAS(Encryption as a service), also called a transit secrets engine inside the vault.

So after encrypting the application data using a vault, now the web server can use or store that data in a database for the next use cases.

Vault will not store data, only pass it back to requesting client.

Basic Vault CLI commands
Vault by itself will give you a list of many Vault CLI commands.(starts with common ones)


  `$ vault
  $ vault version # tells the version of vault
  $ vault read # used to read secrets from vault
  $ vault write #used to write secrets to vault
  $ vault write -h # -h, -help and --help flags can be added `

to get help for any vault CLI command.
What's a process in Elixir?
Tags: elixir, concurrency, process, beam
Published: 2023-03-04 16:10:02

To learn what a process is in Elixir, you must first know what a function is.

For example, `IO.puts/1` is a function that writes something to the screen. The function is called `puts`, it is in the `IO` module (input I and output O), and it takes one argument:
```elixir
iex(1)> IO.puts("Adolfo")
Adolfo
:ok
```

If all goes well, it returns the ``:ok`` atom .
One function that lets you spawn a process is `Kernel.spawn/1`.

Again, the name is `spawn`. It's part of the `Kernel` module and takes one argument.

Can I do
```elixir
Kernel.spawn(IO.puts("Adolfo"))
```
?
No!

Let's start simple: every function that is part of the `Kernel` module doesn't need the module name before it.
You just call

``elixir
spawn(IO.puts("Adolfo"))
```

It will still be wrong, but with fewer letters. 

What ``Kernel.spawn/1` gets is an arity 0 function, i.e., one that takes no arguments.
How do we do that?
Like this:

```elixir
fn -> 1 end
```

The above function has no name (anonymous) and returns 1.

But see in the image that if you spawn it, nothing interesting happens: 


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




First, see that

```elixir
fn -> 1 end
```
returned some sort of "code" that identifies the function:

```elixir
#Function<43.3316493/0 in :erl_eval.expr/6>
```

and

```elixir
spawn(fn -> 1 end)
```
returned a _PID_, a _Process IDentifier_:

```elixir
#PID<0.120.0>
```
I can assign this PID to a variable:

```elixir
iex(1)> pid = spawn(fn -> 1 end)
#PID<0.110.0>
```

And then ask if the process that was spawned is alive:

```elixir
iex(2)> Process.alive?(pid)
false
```

It is not alive because it was a very fast function, which only returned 1.
I can, for example, make the process "sleep" for 10 seconds before returning 1.

```elixir
iex(3)> pid = spawn(fn -> Process.sleep(10000); 1 end)
#PID<0.113.0>
```

If I quickly ask if the process, whose identifier is in the pid variable, is alive, the answer is yes.

```elixir
iex(4)> Process.alive?(pid)
true
```

But if I ask again after 10 seconds, the answer is no.

```elixir
iex(5)> Process.alive?(pid)
false
```
If I do this here

```elixir
iex(6)> pid = spawn(fn -> Process.sleep(10000); IO.puts("Adolfo") end)
#PID<0.117.0>
Adolfo
```
it will take 10 seconds for "Adolfo" to be written to the screen. 

Whereas if I do the following, it will be immediate for "Adolfo" to appear on the screen.

```elixir
iex(7)> pid = spawn(fn -> IO.puts("Adolfo") end)
Adolfo
#PID<0.119.0>
```

Anyway, this is just the basics of the basics. Read more at
[https://elixirschool.com/pt/lessons/intermediate/concurrency](https://elixirschool.com/pt/lessons/intermediate/concurrency)

Or in the Getting Started of the Elixir language
[https://elixir-lang.org/getting-started/processes.html
](https://elixir-lang.org/getting-started/processes.html
)


I did all this without even mentioning `send` and `receive`. 

Finally: a process in Elixir is a processing unit that performs a function.
A Beginner's Guide to Curl: Part 1 - Your First Curl
Tags: bash, zsh, linux, http
Published: 2023-03-04 16:01:53

Curl (client-URL) is a command line utility app.  In the same way your web browser accesses online resources via the address bar, so curl does the same via the a command line interface.

For example, open a new tab and go to this website, [www.example.com](http://www.example.com). You probably saw a very boring looking example webpage.  If you inspect the HTML in your browser, you'll see it's the standard `<head>` and `<body>` with some `<div>`, `<h1>`, and `<p>` tags.  That's because the remote server behind this domain name serves HTML back when any client makes a GET request to that specific url.  Your browser is able present the HTML visually to you.

Now, do the same thing in your terminal or command prompt.  Type the following command and hit return.  

*Don't worry about typing the "$".  That just shows this is a shell command we're typing.*

```bash
$ curl http://www.example.com
```
You should have received several lines of text as a response.  In the exact same way that example.com returned HTML to your web browser, it returned the same response to your command line client.  You successfully just consumed a server response by using a terminal client *instead* of a browser.  

Curl is very powerful, because you can work with server requests and responses directly without a browser getting in your way.

If you've ever used a tool like Postman for working with APIs, you'll find that curl can do almost all the same things if you know how to use it.

Curl is very simple.  You type the word `curl` followed by an address (URL).  Hit return and you get a response!

That's not all!  You can customize your command with many different options and flags.  Each one accomplishes a specific purpose.  You could spend months or years trying to master all the different functionalities of curl.  

Are you ready?  Let's get started in my next article, [A Beginner's Guide to Curl: Part 2](https://dev.to/jvon1904/a-beginners-guide-to-curl-part-2-2dko)
CSS Houdini: Unlocking the Power of Custom CSS
Published: 2023-03-04 16:00:35

CSS Houdini is an exciting new development in the world of web development that allows developers to extend the CSS rendering engine, unlocking the power of custom CSS properties, functions, and animations. With CSS Houdini, web developers can create unique and custom visual effects that were previously not possible with CSS alone.

In this blog post, we will explore what CSS Houdini is, how it works, and provide examples of how it can be used to create stunning visual effects.

## What is CSS Houdini?

CSS Houdini is a collection of APIs that enable web developers to create custom CSS properties, functions, and animations. It allows developers to extend the CSS rendering engine, giving them access to low-level APIs that were previously only available to browser vendors.

CSS Houdini is a game-changer for web developers, as it enables them to create custom and unique visual effects without resorting to hacks or third-party libraries.

## How Does CSS Houdini Work?

CSS Houdini works by providing access to low-level APIs that allow developers to extend the CSS rendering engine. These APIs are exposed through JavaScript, allowing developers to create custom CSS properties, functions, and animations.

CSS Houdini is made up of several modules, including the Paint API, Layout API, and Animation API. Each module provides a different set of APIs that developers can use to create custom visual effects.

## Example: Using the Paint API to Create a Custom Gradient

Let's take a look at an example of how CSS Houdini can be used to create a custom gradient using the Paint API.

First, we define a custom CSS property called "--gradient-colors" that takes a comma-separated list of colors:


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

Next, we define a new paint function called "gradient" that takes two parameters: "context" and "size".


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

Finally, we apply the "gradient" paint function to a CSS class:


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

Now, when we apply the "gradient" class to an HTML element, it will have a custom gradient background based on the colors defined in the "--gradient-colors" CSS property.

## Conclusion

CSS Houdini is a game-changer for web developers, as it enables them to create custom and unique visual effects without resorting to hacks or third-party libraries. With CSS Houdini, developers can extend the CSS rendering engine and unlock the power of custom CSS properties, functions, and animations.

We hope this post has provided a good overview of what CSS Houdini is and how it can be used to create stunning visual effects. As always, we encourage you to continue learning and exploring new web development concepts to stay ahead of the curve.
CSSCSS 1.0.7 Released!
Tags: css, npm, webdev, productivity
Published: 2023-03-04 15:57:26

We're excited to announce the release of CSSCSS version 1.0.7! 

# New Features
### Font Family
We've added the tx-sans font family, which is sets the font family property to the popular Open Sans font. You can now use this font family in your CSS by simply including the following class:
> ### tx-sans
CSS Code: `.tx-sans {font-family: 'Open Sans', sans-serif;}`

## Transparent Backgrounds 
We've also added support for transparent backgrounds with the new bg-trans class. This makes it easy to create backgrounds that are transparent, without having to write any complicated CSS. Here's how you can use it:
> ### bg-trans
CSS Code: `.bg-trans {background: transparent;}`

## Inset Box Shadow
Finally, we've added support for inset box shadows. This allows you to create more complex box shadows that appear inside an element. Here's how you can use it:
> ### box-shadow-i-1
CSS Code: `.box-shadow-i-1 {box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.1); }`

Upgrade Instructions
To upgrade to CSSCSS 1.0.7, simply update your package.json file with the new version number:
`"dependencies": {
  "csscss": "^1.0.7"
}`
Then, run npm install to install the new version.

# Conclusion
We hope you enjoy using CSSCSS 1.0.7! As always, if you have any questions or feedback, please don't hesitate to get in touch with us.
Setting up Typescript in React
Published: 2023-03-04 15:27:12

**Introduction**
React is a JavaScript library use for building user interface.

TypeScript is a syntactic superset of JavaScript, this means typeScript adds syntax on top of JavaScript.

in this tutorial, I will discuss how to set up typeScript in a react project.

**Prerequisite** 
if you are familiar with React and the basic of typescript, you are good to go.
check out my typescript cheatsheet part 1 writeup here [TypeScript Cheatsheet Part 1](https://dev.to/ayomikecharles/typescript-cheatsheet-part-1-5efh)

**Getting started**

if you are starting a new react project,

ensure you have node and npm installed in your system.
first of all, open your terminal and create a folder to work in

```
mkdir Reat-typscript-setup
cd Reat-typscript-setup
```
next, install your react typeScript project

```
npx create-react-app name-of-app --template typescript
```
or

```
yarn create react-app name-of-app --template typescript
```

its as simple as that, your react typeScript project should install and you are good to go.

if you already have an existing react project and you want to add typescript to the project, you simply install typeScript into the project. make sure you are in the project directory in you terminal, then install typeScript as seen below

```
npm install --save typescript @types/node @types/react @types/react-dom @types/jest
```
or

```
yarn add typescript @types/node @types/react @types/react-dom @types/jest
```
Finally, rename all javaScript file to be a TypeScript file (e.g. src/App.js to src/App.tsx) and restart your development server!

you now have a fully typeScript project, but some type errors show up in the same console as the build one, correct these errors and continue your development.

Enjoy typing.
O que é um processo em Elixir?
Tags: elixir, concorrência, processos, beam
Published: 2023-03-04 15:15:36

Para aprender o que é um processo em Elixir, antes você tem que saber o que é uma função.

Por exemplo, `IO.puts/1` é uma função que escreve algo na tela. A função se chama `puts`, ela está no módulo `IO` (de entrada I e saída O) e ela recebe um argumento:
```elixir
iex(1)> IO.puts("Adolfo")
Adolfo
:ok
```

Se tudo dá certo ela retorna o átomo `:ok`.
Uma função que te permite gerar (tradução talvez imprecisa de _spawn_, em inglês) é `Kernel.spawn/1`.

Novamente, o nome dela é `spawn`, ela faz parte do módulo `Kernel` e recebe um argumento.
Eu consigo fazer

```elixir
Kernel.spawn(IO.puts("Adolfo"))
```
?
Não!

Vamos começar simplificando: toda função que faz parte do módulo `Kernel` não precisa do nome do módulo antes.
Basta chamar

```elixir
spawn(IO.puts("Adolfo"))
```

Vai continuar errado mas com menos letras. 
O que `Kernel.spawn/1` recebe é uma função de aridade 0, ou seja, que não recebe nenhum argumento.
Como fazemos isso?
Assim:

```elixir
fn -> 1 end
```

A função acima não tem nome (anônima) e retorna 1.

Mas veja na imagem que se você dá um spawn nela, nada de interessante acontece: 


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



Em primeiro lugar, veja que

```elixir
fn -> 1 end
```
retornou uma espécie de "código" que identifica a função:

```elixir
#Function<43.3316493/0 in :erl_eval.expr/6>
```
E

```elixir
spawn(fn -> 1 end)
```
retornou um _PID_, um _Process IDentifier_, um identificador de processo:

```elixir
#PID<0.120.0>
```
Eu posso atribuir este PID a uma variável:

```elixir
iex(1)> pid = spawn(fn -> 1 end)
#PID<0.110.0>
```

E depois perguntar se o processo que foi gerado está vivo:

```elixir
iex(2)> Process.alive?(pid)
false
```

Não está pois era uma função muito rápida, que só retornava 1.
Eu posso, por exemplo, fazer o processo "dormir" por 10 segundos antes de retornar o 1.

```elixir
iex(3)> pid = spawn(fn -> Process.sleep(10000); 1 end)
#PID<0.113.0>
```

Se rapidamente eu pergunto se o processo, cujo identificador está na variável pid, está vivo, a resposta é sim.

```elixir
iex(4)> Process.alive?(pid)
true
```

Mas se pergunto novamente depois de 10 segundos, a resposta será não.

```elixir
iex(5)> Process.alive?(pid)
false
```
Se eu fizer isto aqui

```elixir
iex(6)> pid = spawn(fn -> Process.sleep(10000); IO.puts("Adolfo") end)
#PID<0.117.0>
Adolfo
```
vai demorar 10 segundos para "Adolfo" ser escrito na tela. 

Já se eu fizer isto, será imediato para "Adolfo" aparecer na tela.

```elixir
iex(7)> pid = spawn(fn -> IO.puts("Adolfo") end)
Adolfo
#PID<0.119.0>
```

Enfim, isto é somente o básico do básico. Leia mais em
[https://elixirschool.com/pt/lessons/intermediate/concurrency](https://elixirschool.com/pt/lessons/intermediate/concurrency)
Ou no Getting Started da linguagem Elixir
[https://elixir-lang.org/getting-started/processes.html
](https://elixir-lang.org/getting-started/processes.html
)

Fiz tudo isso sem sequer mencionar `send` e `receive`. 

Finalizando: um processo em Elixir é uma unidade de processamento que executa uma função.
Why You Need to Hire an Expert Web Development Company
Tags: webdevelopmentcompany, websitedesign, customizedwebsitedesign, hirewebdevelopmentcompany
Published: 2023-03-04 15:13:38

In today's digital age, having a strong online presence is crucial for businesses of all sizes. A well-designed and functional website can help attract potential customers, build brand awareness, and increase revenue. However, creating a website that meets the needs of your business and customers requires expertise in web development.

**Hiring an expert web development company** can provide numerous benefits for your business. Here are some reasons why you should consider hiring a professional web development company:


## Customized Website Design

A professional [web development company](https://69thedeal.com/) can design a website that is tailored to your business needs and brand image. They will work closely with you to understand your business goals, target audience, and website requirements. This ensures that your website is unique and stands out from your competitors.


## User Experience Optimization 

A web development company can optimize your website to provide the best possible user experience for your visitors. This includes designing a user-friendly interface, ensuring fast page loading speeds, and making sure the website is compatible with different devices and browsers.


## Search Engine Optimization (SEO) 

SEO is crucial for the success of any website. An expert web development company can optimize your website for search engines, including keyword research, on-page optimization, and link building. This will help improve your website's visibility and drive more traffic to your site.


## Security
 
Security is a critical concern for any website. A professional web development company will take all necessary measures to ensure that your website is secure, including regular software updates, malware protection, and data backups.


## Cost-Effective

Hiring a professional web development company may seem expensive at first, but it can actually save you money in the long run. A well-designed website that is optimized for search engines and user experience can attract more customers and generate more revenue for your business.


## Ongoing Support and Maintenance

A web development company can provide ongoing support and maintenance for your website, including software updates, bug fixes, and website backups. This ensures that your website is always up-to-date and running smoothly.

In conclusion, hiring an expert web development company can provide numerous benefits for your business, including customized website design, user experience optimization, search engine optimization, security, cost-effectiveness, and ongoing support and maintenance. With their expertise and experience, a web development company can help take your online presence to the next level and help your business succeed in the digital world.