teleren/devto huggingface dataset:
Automated Key rotation in Key Vault
Tags: azure, keyvault, rotationpolicy, keyrotation
Published: 2022-05-29 15:50:29

## Introduction

Key vault has an `automated key rotation feature` that will automatically generate a new key version. `Rotation policy` can be used to set rotation for individual keys. It is recommended that the encryption keys be changed at least `every two years`.

This feature allows `end-to-end zero-touch rotation` for the customer-managed key in the azure key vault. There is an additional cost for each scheduled key rotation.


Key management permission is required for the Key Vault key rotation feature. You can assign a role to manage rotation policy and on-demand rotation.

## Key rotation policy


Users can use the key rotation policy to set rotation and event grid notifications.

## 1. Expiry time

It's used to set an expired date on a new key. It doesn't affect the current key.

## 2. Enabled/disabled

There is a flag that can be enabled or disabled for the key. 

## 3. Rotation types

- You can automatically renew at a given time after creation.
- You can automatically renew at a given time before expiry.

## 4. Rotation time

The minimum value is seven days from creation and seven days from the end of the rotation. 

## 5. Notification time

The key is near the end of the event interval. 


![rotating policy](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0fk0xy2fqa33itldo8n5.JPG)

Key rotation policy should be configured `during key creation`.


![key creation](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/at7eeou7cllihneknjzz.JPG)

The rotation policy should be configured on the existing keys.


![existing keys](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sptaljnkcj10kgcgyem4.JPG)


Key rotation can be invoked manually. To invoke rotation, click `Rotate Now`.


![Rotate now](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g4o6ob1mbt4nnb94h5rb.JPG)


The event grid key has a configuration of expiry notification. Notification can be configured with days, months and years before the event.


![event grid](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gxlxuhwxvcxxlsuwaxq6.JPG)

Key rotation can be configured with the [ARM template](https://github.com/MakendranG/Keyvault-Keyrotation/blob/main/ARM%20template). Key rotation policy can be configured using templates.


Thanks for reading my article till end. I hope you learned something special today. If you enjoyed this article then please share to your friends and if you have suggestions or thoughts to share with me then please write in the comment box.



Above blog is submitted as part of 'Devtron Blogathon 2022' - https://devtron.ai/
Check out Devtron's GitHub repo - https://github.com/devtron-labs/devtron/ and give a ⭐ to show your love & support.
Follow Devtron on LinkedIn - https://www.linkedin.com/company/devtron-labs/ and Twitter - https://twitter.com/DevtronL/, to keep yourself updated on this Open Source project.
Redis : Your db for in memory
Published: 2022-05-29 15:28:42


Hello everyone knows what is redis, it’s the most popular in-memory data structure store used as a database, cache, message broker, and streaming engine. It offers great data structures out of the boxes such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs, geospatial indexes, and streams.

And out of all things it is a open source software so everyone can take a look at the source code, if you want countribute check out the link

GitHub - redis/redis: Redis is an in-memory database that persists on disk. The data model is…
Redis is an in-memory database that persists on disk. The data model is key-value, but many different kind of values…
github.com

Today I will show you how to use redis with python to create your database in memory using redis. So let’s jump into it.

Requirements
First you need python and redis installed in your machine, best option is to use docker and redis for this tutorial.so deploy your redis docker instance with one command in your terminal:

`docker run --name redis -p 6379:6379 -d redis`

It will create a redis instance at port 6379. Now it’s created let’s create our python code to store the sata into redis database. For this we need redis library from pip. If you don’ have it on your machiner install it with this command.

pip install redis
Now let’s code…

First create a file with anyname , let’s say test.py and add this code,

Connect to Redis
The following code creates a connection to Redis using redis-py:

import redis
r = redis.Redis(
    host='hostname',
    port=port, 
    password='password')
To adapt this example to your code, replace the following values with your database’s values:

In line 4, set host to your database’s hostname or IP address
In line 5, set port to your database’s port
In line 6, set password to your database’s password
Example code for Redis commands
Once connected to Redis, you can read and write data with Redis command functions.

The following code snippet assigns the value bar to the Redis key foo, reads it back, and prints it:

# open a connection to Redis
```
 
r.set('foo', 'bar')
value = r.get('foo')
print(value)
```
Example output:

$ python test.py
bar
Conclusion
So this is how you can use redis and python to create your database in redis, also you can use for caching for applications. Below is some more resources for you to follow.

Redis with Python
To use Redis with Python, you need a Python Redis client. The following sections demonstrate the use of redis-py, a…
docs.redis.com

Redis | The Real-time Data Platform
Build and run faster apps with the world's leading real-time data platform.
redis.com
Re-Deploy in your Project in firebase and heroku
Published: 2022-05-29 15:28:20

**Client side** : 

First of all client side code upload in github.

`git add .
git commit -m" commit message"
git push`

then:

```javascript
npm run build
firebase deploy
```

**Server side**

First of all Server side code upload in github.

`git add .
git commit -m" commit message"
git push`

then:

```javascript
git push heroku main
```
How do I speed up my website? It is not what we think.
Tags: web, performance, database, optimisation
Published: 2022-05-29 15:24:41

Recalling some onsite work with a public facing website and being asked to improve the database indexes, we unearthed a lot more than first suspected.

We explain the challenges to optimising a legacy website platform given the choice of database and use of Azure cloud technologies. Not a bad thing, just a different approach.

You can see the text version of this article here;  https://www.inforhino.co.uk/article/Discussion/Guides/How-do-I-make-my-website-run-faster-9-May-2022 

and the YouTube version here; 
https://youtu.be/Q5mV2tM3ogU
Growing via Sharing: the way of a true hero
Tags: aws, hero, softwaredvelopment, diversity
Published: 2022-05-29 15:03:56

One of the most inspiring things in life is to see somebody who has overcome difficulties and remained human.


Hiroko Nishimura is one such person. She had brain surgery, but that didn't stop her will to help other people. When she found it is harder to study for her than before, she created her own tutorials for newbies in the AWS (https://introtoaws.com/). No wonder she became an AWS Hero. 


Thinking that I only have medical depression, asthma, and some sort of strong autism, makes me blush. While I was stuck in depression, Hiroko was helping other people. 


どうもありがとうございます。(thank you very much), Hiroko. Now it will be easier for me to keep growing and keep helping people with my OSS involvement.

Please watch @HirokoNishimura's talking about her experience, it is a great video: https://www.youtube.com/watch?v=n8HPuSy8u5w
6 months coding challenge
Published: 2022-05-29 14:48:25

So hey,
 I am another random pearson on the internet.Nice to meet you.

So its been 6 months of 2022 lets just have a quick recap of whats has happened till now :

- Covid is nearly gone(India)

- I finally went to school after 2 years (India)

- Monkey pox is spreading

- Everything is nearly back to normal

NOW DON'T CLICK OFF AFTER READING I AM FROM A THIRD WORLD COUNTRY. I AM NOT UNEDUCATED!! :)

So Now the problem is due the reopening of school as a 13 year old I cannot manage my time (like any teenager)and during lockdown I had learnt python,a bit of java and cyber security with a bit of pentesting.Now due to school I am not able to practise coding or learn any new skill (mind it ,I study and 2 syllabuses simultaneously) and I wanna finish learning java , c# and python from zero(tbh I know python).
Let's point down what I wanna do:
1. C#
2. Python
3. Java
4. R (optinal)

So to finish these goals I  am gonna put 9 hour's a weekend.So it does not affect my studies.

I am gonna post updates every 2 months :).

Lets see how much I can do : )
New landing page of TemplatesKart website
Tags: react, webdev, showdev, chakraui
Published: 2022-05-29 14:43:40

On weekend, I modified TemplatesKart website landing page. 
Let's have a look what changes I made.

## Links
Website: [TemplatesKart](https://templateskart.com)
Github Repo: [TemplatesKart Code](https://github.com/MA-Ahmad/templateskart)

## Old Hero Section

![Old hero section](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2seopts4ff4dcmxs2tgy.png)


## New Hero Section

![New hero section](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b20knw0wket099xaphnt.png)

## New Components Preview Section

![components preview image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i4mdv6rnvy7dzssatp1r.png)
Laravel sendinblue emails
Tags: laravel, sendinblue, beginners, webdev
Published: 2022-05-29 14:35:55

Hi! In this post i will share small code with you, how you can send Laravel Sendinblue emails. We will send emails using the CURL options provided by sendinblue.

```php
public static function sendSendInBlueMail()
{
    $html = view('emails.template', [
        'name' => 'User Name'
    ]);

    $fields = [
        'to' => [
            [
                "email" => 'to@example.com',
                "name" => 'User Name'
            ]
        ],
        "sender" => [
            "name" => 'Website Name',
            "email" => 'from@example.com'
        ],
        "subject" => 'Sendinblue Email',
        "cc" => [
            [
                "email" => 'to@example.com',
                "name" => 'User Name'
            ]
        ],
        "htmlContent" => "<html><head></head>" . $html . "</html>"
    ];

    $fields = json_encode($fields);

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'https://api.sendinblue.com/v3/smtp/email');
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
        'accept: application/json',
        'api-key:' . env("SENDINBLUEAPIKEY") . '', 'content-type: application/json'
    ]);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

    $response = curl_exec($ch);

    return $response;
}
```
Email blade template

```php
<body style="padding:0px;margin:0px;font-family: sans-serif;">
    <h1>{{$name}}</h1>
</body>
```
Get [Sendinblue API here](https://account.sendinblue.com/advanced/api)
---

Please like share and give positive feedback to motivate me to write more.

For more tutorials [visit my website](https://www.w3courses.org/category/code-examples/).

Thanks:)
Happy Coding:)
Run npm packages in developers console on any site
Published: 2022-05-29 14:05:29

If you want to test a npm package directly in the browser, there is a way to do this!

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


# How? 

The tric is to load a javascript file programmatically in the developers console:
```
const script = document.createElement('script');
script.src = 'localhost:666/bundle.js';
document.body.appendChild(script);
```

Only what is **bundle.js**?  

That's a bundle that we will create in a minute with `browserify`.

And what is **localhost:666/**

That's a local server that you will serve (later in this tutorial), because chrome browser does not allow local files to be loaded. 

## Let's start building

You can replace `cheerio` with any npm package you like (but not all of them work in the browser)

- Open up a new directory
- `npm init -y`
- `npm i -D browserify http-server` (as dev dependencies)
- `npm i cheerio` (or any package you want to use)
- `touch main.js`
- `code .` (launch visual code studio)
- in main.js edit the following:
```
const cheerio = require("cheerio");
window.cheerio = cheerio; // this makes it available in the console later
```
- in package.json add the following:
```
"scripts": {
    "serve": "browserify main.js -o build/bundle.js && http-server -p 666 build/"
  },
```
- `npm run build`
- open browser
- check if this loads: localhost:666/bundle.js
- if so copy paste this to Chrome's developers console (on any page)
```
const script = document.createElement('script');
script.src = 'localhost:666/bundle.js';
document.body.appendChild(script);
```
- Now play around in your developer console with the npm package, in our case:
```
const $ = cheerio.load(document.body.innerHTML);
$('a');
```

PS: Not all npm packages work, I tried `request` but it gave an error in the developer console. But nowadays I would recommend to use the new standard `fetch` for this.

Github: [You can clone this repo also!](https://github.com/wimdenherder/npm-in-the-browser)
Terminal style website. (UPDATE)
Tags: javascript, webdev, react, nextjs
Published: 2022-05-29 13:59:39

A little while ago, I created a highly customizable terminal styled website, that you can self-host, and use it as your own Portfolio.


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

I recently added theme support to it, so you can give it any look you like. make sure you visit the [themes section](https://github.com/m4tt72/terminal/tree/master/docs/themes) in the docs to see all available themes.

The project can be easily deployed to Github Pages. Just like any Next.js project, follow Next.js [static-html-export](https://nextjs.org/docs/advanced-features/static-html-export) guide to start.


Check out the [project's repo](https://github.com/m4tt72/terminal), and the [live demo](https://term.m4tt72.com) I have hosted in [Vercel](https://vercel.com/).
Send e-mails with Tailwind CSS - Laravel
Tags: php, laravel, tailwindcss, webdev
Published: 2022-05-29 13:39:57

I found this great article that talks about how to improve the look and design of mails using Tailwind CSS. I found it great and useful because it can be used in your upcoming projects and gives you a lot of powerful formatting in your email submissions

https://ralphjsmit.com/laravel-emails-tailwind-css

- Create a new e-mail template and use Tailwind CSS
- Create a special `mail.css` file with Tailwind CSS
- Create a Blade-component with the base layout
- Inline Laravel e-mail CSS with the CSS inliner

These are the main points in the article. I hope you benefit from the article and share your knowledge with others. Enjoy.
Day 1 - Licenses and Pragma
Tags: solidity, 100daysofcode, web3, blockchain
Published: 2022-05-29 13:37:00

This is Day `1` of `30` in Solidity Series.

Today I Learned About Licenses and Pragma Keyword in Solidity

---

## Licenses


```solidity
// SPDX-License-Identifier: License Name
```

SPDX license identifiers should be added to the top of contract files.
The license should be from one of the following: [https://spdx.org/licenses/](https://spdx.org/licenses/).

⚠️ If the license identifier isn’t included in the contract file the compiler will now show a warning.

❗ If there are multiple license identifiers in the contract file the compiler will now show an error.

eg - 

```solidity
// SPDX-License-Identifier: MIT
```

---

## Pragma


In Solidity the pragma keyword is used to configure compiler features and checks. The pragma directive is always local to the current file and is not global. Hence to make it applicable in your entire project of Solidity you have to include pragma directive in every file to work.

The first line is a pragma directive which tells that the source code is written for which Solidity version.

```solidity
pragma solidity ^0.8.7;
// Anything above 0.8.7

pragma solidity >=0.8.0 <0.9.0;
// Anything between 0.8.0 to 0.9.0 where 0.9.0 is not included.

pragma solidity 0.8.7;
// Only Version 0.8.7
```

---

{% embed https://github.com/Envoy-VC/30-Days-of-Solidity noreadme %}
My first game using Python (OOP)
Tags: python, gamedev, oop, learning
Published: 2022-05-29 12:50:22

Hi there! Welcome to my first post on Dev.to.

Honestly I've never wrote a post before, so I'm not sure what I have to write here, but I'm going to do my best!

Just want to talk a bit about my program developed with python. This is not probably the game you would like to play every time you can, but it has the basics OOP concepts applied on it. This was made just to practice.

I'm currently studying CS on Codecademy, and if you were wondering about this platform, let me tell you that is an amazing platform to inquire deep knowledge about important topics like CS, data structures, algorithms and more.

I'll leave the link to the repository here: https://github.com/fedeArzuaga/python_game

Just follow the instructions you will find in the README.md file I wrote.

I hope this is interesting for you, thanks for reading until here!

Best,
Federico Arzuaga - Self-taught and curious Frontend Dev
Building A Text Based Adventure Game with Java ⚔🗺
Tags: showdev, java, gamedev, programming
Published: 2022-05-29 12:49:04

## Adventure TUI
### Adventuring from the Terminal! ⚔🗺️

## What is this

Adventure TUI is a text adventure game, where you can explore different world right from you terminal.

You can add your own adventures too, see below to learn how.

## Inspiration

I have spent so many nights on text-based adventure games, this is my tribute to Will Crowther's original "Adventure" from early 1970s.

## Prerequisites

Before you begin, ensure you have met the following requirements:

- You have installed the latest version of `java`

## Getting adventure-tui

To get adventure-tui, follow these steps:

```bash
git clone https://github.com/2kabhishek/adventure-tui
cd adventure-tui
```

## Using adventure-tui

After cloning you can use VS Code (with Java extentsions), or any other editor/IDE to run this.

For running it from the command line, follow these steps

```
cd src/
# Compile Adventure.java
javac Adventure.java
# Run Adventure.java
java Adventure
```

Once you run the game you will be asked to choose an adventure, You can choose between `Crowther`, `Small` or a custom adventure you added.

If you see errors while running from the Terminal, you can edit the `DATA_PATH` variable in `src/Adventure.java`

## How it was built

adventure-tui was built using `java` and lots of imagination!

## Challenges faced

- Building out the Abstractions was challenging
- Breaking the problem into smaller pieces was daunting in the begining

## What I learned

While building adventure-tui I learned about

- How to build abstractions using OOP
- Efficient use of txt files for data storage
- Building Text adventure games is fun!

## What's next

Maybe add a new game, just have to add a new rooms and objects file!

Hit the ⭐ button if you found this useful.

## More Info

[Demo Video](https://vimeo.com/714924428)

{% embed https://github.com/2kabhishek/adventure-tui %}
First Impression
Published: 2022-05-29 12:19:31

关于crit。好久没有在这里写博客。简单说几句。看作品first impression可以捕捉一下。如果要给批评意见可以。最近的一个经历就是，本来想说，这个作品很随便，后来想想，人家那叫随性。其实那个画家也可以画非常雕琢的作品，但那多费劲。一开始觉得别人给的feedback没啥用，后来发现还是有用的。虽然那些feedback都是基于first impression，作者本人失去的就是first impression。

It's been a while since I've blogged here about crit. Just a few words. Look at the work first impression can capture a little. If you want to give a critical opinion can. One of my recent experiences is that I wanted to say that this work is very casual, but then I thought about it, people call it casual. In fact, the painter can also paint very sculpted works, but that much effort. At first, I thought the feedbacks given by others were useless, but later I found that they were still useful. Although those feedbacks are based on first impression, the author himself lost is the first impression. #knee-jerk-critic


Translated with www.DeepL.com/Translator (free version)
How to use Lodash compact function?
Tags: node, javascript, beginners, tutorial
Published: 2022-05-29 12:10:00

Note: This tutorial also exist in my [GitHub](https://github.com/harithzainudin/how-to-lodash#how-to-lodash)

**Compact function** will remove all falsey values in the array that you provided

Falsey values in javascript are something that evaluates to FALSE.
There are only six falsey values in JavaScript: undefined, null, NaN, 0, "" (empty string), and false.

How to use it? Simple.
```
const falseyValues = ["", null, undefined, 0, "Harith", "Malaysia"];

const cleanWords = _.compact(data.randomWord)
console.log(cleanWords)
```
 
The result will be
![Result of lodash compact function](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nc29jgw7fsff29babnj1.png)

It will remove all the falsey values in the array that we provided. Simple as that
 
---------------------------------------------------------
Thank you for reading :D

Psstt pstt :p
Do consider to love this article ❤️ and follow me! Why not right? It's FREE~ 
I would really appreciate it 👨🏻‍💻 
Will be posting more on things related to AWS, Javascript, Python, Serverless and more!
Proxying websockets via nginx
Tags: devops, nginx, http, websockets
Published: 2022-05-29 12:06:13

Be me. Have an existing nginx config setup that works for HTTP, but now big guy ask me to also tunnel websocket connections through it.

In the nginx conf, in the `http` section, add these

```
http {
    ...

    map $http_upgrade $connection_upgrade {
        default upgrade;
        '' close;
    }

    ...
}
```

In the nginx conf, in the `http > server > location` section, add

```
http {
    ...

    server {
        ...

        location ... {
            ...

            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection $connection_upgrade;

            ...
        }
    }
}
```

Poke nginx

```
systemctl restart nginx
```

Everything works!

Be me. Go back to watching TV.