teleren/devto huggingface dataset:
The Weekly Dev - 202221
Published: 2022-05-22 13:07:55

---
title: The Weekly Dev - 202221
published: true
description: 
tags: 
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dg8hwu8plwlgarpp9j58.png
canonical_url: 'https://kevwe.com/weekly/202221'
---
Cryptography for good


To anyone who tried to put some asset out online, it is absolutely obvious the need for some sort of security.


It's not some sort of paranoia, if you have something out like an email server, a webserver, a PBX or anything else, just take a look at your logs!

After just a couple of days, you will start to notice all kind of strange requests, spamming, phishing an whatnot.


It is overwhelming, probably something near to 90% of your traffic is due to those extraneous, nonsensical, puzzling requests.


I said "If you had a look", but it goes without saying that is something that of course you have to do.


Also I assume that if you have those services out there it is because you care about them, because you need them.


Then all the competences regarding security, encryption schemas, certificate management should be something you're familiar with, because it's part of how things work:


https://kevwe.com/weekly/202221
dynamoman – the perfect import-export utility for AWS DynamoDB administration
Published: 2022-05-22 13:05:20

It is quite surprising that AWS didn’t provide an import export support for its popular database DynamoDB. When I started using DynamoDB for my project, I found the unavailability of import export feature hounding me during data migration or copying data between environments.

This made me to start looking for options for exporting the tables of DynamoDB. I found there are some options must most of them are more than 1 year old and lacks intuitive features. This made me to think about creating a cli which will handle the import export of tables, thus created a new cli – [dynamoman ](https://www.npmjs.com/package/dynamoman)([https://www.npmjs.com/package/dynamoman](https://www.npmjs.com/package/dynamoman))

## Features
Easily export the dynamoDB table as JSON
Imports the data into any dynamoDB table
Export from one region and import in to another
Supports batch import (chunks of 25 records)
Supports Windows / Linux / Mac

## Installation

You can use npm / yarn to install the cli

  `npm install -g  dynamoman`

To verify the Installation

  `dynamoman --help`

## Getting started

For importing the data use the import command and for exporting use the export command

`dynamoman import --file table_dump.json --table <mytable>`
`dynamoman export --file output.json --table <mytable>`

More feature are there in the pipeline including
- Export all tables to a zip
- Import all tables from a zip

> If you like to contribute to this project, please feel free to submit a pull request @ https://github.com/vinodsr/dynamoman
How to apply Scale-down Mode to delete/deallocate nodes in AKS
Tags: azure, kubernetes, aks, scale
Published: 2022-05-22 12:53:41



By default, scale-up operations performed manually or by using the cluster autoscaler require the allocation and provisioning of new nodes, and scale-down operations delete nodes. Scale-down Mode approves us to determine whether we would like to delete or deallocate the nodes in our Azure Kubernetes Service (AKS) cluster upon scaling down.

We won't be charged for the compute resources of the stopped virtual machine. We need to pay for the OS and data storage disks that are attached to the VM. The container images will be preserved on those nodes.

Our deployment uses cached images and this behavior allows for faster operation speeds. The `scale-down mode` eliminates the need for pre-provision and pre-pull images.


## Before we start

We have an existing AKS cluster. If we need an AKS cluster, see the AKS quick start [using the Azure CLI](https://docs.microsoft.com/en-us/azure/aks/learn/quick-kubernetes-deploy-cli), [using Azure PowerShell](https://docs.microsoft.com/en-us/azure/aks/learn/quick-kubernetes-deploy-powershell), or [using the Azure portal](https://docs.microsoft.com/en-us/azure/aks/learn/quick-kubernetes-deploy-portal).

## Using Scale-down Mode to deallocate nodes


By setting `--scale-down-mode deallocate`, we will be able to deallocate during a scale-down of our pool. The deallocated nodes are stopped. When the pool needs to scale up, the deallocated nodes will be the first to be started.

In this example, we create a new pool with 20 nodes and specify that upon scale-down, they will be dealt with via `--scale-down-mode Deallocate`.




```
az aks nodepool add --node-count 20 --scale-down-mode Deallocate --node-osdisk-type Managed --max-pods 10 --name kcdpool1 --cluster-name kcdAKSCluster --resource-group kcdrg
```

We will deallocate 15 nodes by scaling the pool and changing the count to 5.



```
az aks nodepool scale --node-count 5 --name kcdpool1 --cluster-name kcdAKSCluster --resource-group kcdrg
```


## Deleting formerly deallocated nodes



The Scale-down Mode to Delete can be changed by setting it. The 15 nodes will be deleted.


```
az aks nodepool update --scale-down-mode Delete --name kcdpool1 --cluster-name kcdAKSCluster --resource-group kcdrg
```


## Using Scale-down Mode to remove nodes

When you scale-down your cluster, the default behavior of AKS is to remove your nodes. This behavior can be achieved by setting Scale-down Mode.

In this example, we create a new pool and specify that our nodes will be deleted upon scale-down. The cluster autoscaler will handle scaling operations.




```
az aks nodepool add --enable-cluster-autoscaler --min-count 1 --max-count 10 --max-pods 10 --node-osdisk-type Managed --scale-down-mode Delete --name kcdpool3 --cluster-name kcdAKSCluster --resource-group kcdrg
```


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.
Use "source" Jekyll configuration to avoid deployment mistake
Tags: jekyll, ruby
Published: 2022-05-22 12:40:14

---
title: Use "source" Jekyll configuration to avoid deployment mistake
published: true
description: Instead of the "exclude" key, "source" key is the way to go
tags: jekyll, ruby
canonical_url: https://www.clpsplug.com/en/2022/05/22/jekyll-source.html
//cover_image: https://direct_url_to_image.jpg
---

By default, Jekyll includes into the website whatever exists at the project root minus some files and directories that has special meanings.

```
my_jekyll_site
|- GemFile  // safe by default
|- GemFile.lock  // safe by default
|- _config.yml  // safe by default
|- .gitignore  // safe by default
|- index.md  // included
|- _posts  // included (parsed and then included)
 |- ...
```

There is one problem with this setup. **If you add a script file here, you are going to expose that file!**

```
my_jekyll_site
|- Gemfile
|- ...
|- script.sh  // uh oh, you're exposing this file!
```

> There can be multiple reasons for creating a non-Jekyll related scripts, examples being:
> * Automated build script for the server to publish your site
> * Yarn/Webpack config for your javascript needs

You could specify `exclude` key in your `_config.yml`, but this is merely *a manual denylist* - you may forget to add stuff until it is too late.

```yaml
exclude: ["webpack.js"]
```

There is even better way:

## The `source` key

This tells Jekyll to stop looking at the project root for the content to build; instead, **it will use the directory you have specified.**

```yaml
source: "_src"
```

In this example, you put everything into `_src` directory and everything will work just as fine. No more need to update your `exclude` key!

One small notice is if you're generating stuff outside of Jekyll, e.g., transpiling your typescript, you need to point the input and output into the `source` directory.
Git - What actually is Version Control System ?
Tags: github, git
Published: 2022-05-22 12:17:57



I have seen many people (beginners) asking,

> what is the difference between the Git and GitHub?

So, I think, this needs to be clarified in a proper post.

Generally, the ones, asking these questions, are not much aware of Git and the immense need of this tool, especially in the field of programming, whether it be development or some other application.

# Git - Version Control System

Lets understand Git... a bit.

It is a _Version Control System_, as everyone says, but what does _VCS actually mean_?

Lets say, you are making notes of something in a simple text file, named as "notes.txt"

![image](https://github.com/hasabTech/blog/blob/main/Images/Git%20-%20What%20Actually%20is%20VCS/image1.png?raw=true)

The notes were quite rough, so you refined it later and named it as, "notes - refined .txt"
Now, you have two files:

![image](https://github.com/hasabTech/blog/blob/main/Images/Git%20-%20What%20Actually%20is%20VCS/image2.png?raw=true)

Lets say, you researched about a topic, or discussed it with a friend or someone asked a revision of it, and you are like me, you always want to keep a copy (i.e., history) of what you have been doing throughout your time on particular work.
So, you renamed it again:

![image](https://github.com/hasabTech/blog/blob/main/Images/Git%20-%20What%20Actually%20is%20VCS/image3.png?raw=true)

As revisions, refinement, research and/or modifications increases, so would your files because you want to _keep track_ of what you are doing and how you are doing it.

But wait... Even after all that hassle, you can keep track of versions of files but you still cannot track what you have been editing all this time, right?

One solution could be prepare Excel file where you keep names of files in one column and description of versions on another column for proper tracking of the files and their different versions.

Now, you wish, there was some assistant of yours who could arrange all of that work but unfortunately, you are not rich like me who can afford an assistant for all of this work

```
Enters Git!
```

A free of cost assistant, to manage and solve the problem that we just discussed!

We will be sharing how it solves the aforementioned problems in detail in our upcoming article.
Dealing with currency in Laravel
Tags: laravel, php, opensource
Published: 2022-05-22 12:17:03

Most applications have to deal with currencies in some way or another and unfortunately it isn't always straightforward due to database limitations. 

Among a few different solutions to how to store currency in the database my choice always is storing it in cents as an integer. _(if you prefer another way turn around now)_

Storing in cents solves many of our problems like dealing with floats and such, however, creates a new challenge, **remembering what state your variables are in**. The amount of times I would by mistake store a currency in USD format instead or converted cents to cents again is way too damn high. Also converting constantly back and forth gets quite old quickly and **don't we all hate writing the same thing over and over again?**
Let me demonstrate what I am talking about.

```php
$currency = 1;
$currencyInCents = $currency * 100;
$someFeeRate = 0.12;

$currencyInCentsWithFee = $currencyInCents * $someFeeRate;

$model = Model::create([
  'amount' => $currencyInCentsWithFee
]);

// $model->amount - 
//I already lost what format this was in may be I have a bad memory

return response()->json([
  'currency' => '$'.number_format($model->amount / 100, 2)
]);
```

Did you realise how many times I had to write `"inCents"` within my variables? 
Of course I am exaggerating a little bit with this example but once there more levels of calculations things get worse and worse _if you have been there, you know_.

There is also a good chance that the next developer within the project is going to do something completely different to what I just did.

As a solution we came up with a simple package for currency:
https://github.com/Kodeas/currency

```php
$currency = Currency::fromUsd(1);

$someFeeRate = 0.12;

$currencyWithFee = Currency::fromCents($currency->inCents() * $someFeeRate);

//model has currency as a cast of Currency::class
$model = Model::create([
  'amount' => $currencyWithFee
]);

//$model->amount - 
//this is now an instance of Currency::class so it is in whatever format you wish

return response()->json([
  'currency' => $model->amount->toReadable('$')
]);
```

The `currency` class is used as a cast to standardise currency operations in your entire app, regardless of who is the developer writing it. Your currency will always be stored in cents and you will never forget what state your currency was during your operations.


I also appreciate you might be sceptical of adding a package for something so simple therefore, I also [wrote](https://dev.to/kodeas/creating-casts-like-carbon-in-laravel-3k49) about how it was made so you can also **create one of your own**.

There it is, nice and quick solution to most of your currency issues while using Laravel.

Please feel free to contribute to the package if you have any additions and show some ❤️ with a like if this helped you.
remove windows home screen icons with this
Tags: discuss, suggestion, windows
Published: 2022-05-22 12:10:21

---
title: remove windows home screen icons with this
published: true
description: if you want a clean home screen with any apps/file/folder on windows you can try this 
tags: discuss, suggestion, windows
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/njvl1ex9l0jn0t9ho3jk.png
---

if you want a clean home screen with any apps/file/folder on windows you can try this 

leftclick > views > uncheck `show desktop icons`
![show desktop icons](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d4vloz26itoat1bq9dkt.png)
 

wow so clean 😲,

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/njvl1ex9l0jn0t9ho3jk.png)
We' ve Just Launched !
Tags: apisecurity, api, saas, blstsecurity
Published: 2022-05-22 11:54:51

> "BLST detects broken business logic in your API and maps it into a simple, integrated platform"

At [BLST (Business Logic Security Testing)](https://www.blstsecurity.com/?promo=blst&domain=https://nathan.devto1) we provide security testing for APIs throughout the software development lifecycle, making it easy for DevOps and AppSec teams to find and fix potential vulnerabilities. By automating security testing, we helps teams shift left in the CI/CD process, improving system security and saving time and money.

We just release our SaaS-based API security testing services which provides comprehensive, continuous, and cost-effective protection for your APIs. By deploying these services, you can quickly and easily get the expert protection you need to keep your APIs safe from logical anomalies.
While in your development process, if you need to learn a new API, imagine having a tool that will produce a complete real-time endpoints map and will guide you through with a params table. Wouldn’t that be sweet?

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


Join our Discord server: https://discord.gg/Q3mCAJYZ
Like our [Cherrybomb](https://github.com/blst-security/cherrybomb) project: [https://github.com/blst-security/cherrybomb](https://github.com/blst-security/cherrybomb)
Subtract the Product and Sum of Digits of an Integer | Leetcode
Tags: programming, python, solution, beginners
Published: 2022-05-22 11:35:36

Hey coders welcome to our new series of solving programming questions. So we are back with Leet Code solution in C++ and Python, so let's start.

**Problem Statement**
Given an integer number n, return the difference between the product of its digits and the sum of its digits.
 

**Example 1:**

`Input: n = 234
Output: 15 
Explanation: 
Product of digits = 2 * 3 * 4 = 24 
Sum of digits = 2 + 3 + 4 = 9 
Result = 24 - 9 = 15`

**Example 2:**
`Input: n = 4421
Output: 21
Explanation: 
Product of digits = 4 * 4 * 2 * 1 = 32 
Sum of digits = 4 + 4 + 2 + 1 = 11 
Result = 32 - 11 = 21`

**C++ Solution**
```
class Solution {
public:
    int subtractProductAndSum(int n) {
        int sum = 0;
        int product = 1;
        
        while(n != 0){
            int digit = n % 10;
            sum += digit;
            product = product * digit;
            n = n / 10;
        }
        
        int subtract = product - sum;
        return subtract;
    }
};
```

**Python3 Solution**

```


def subtractProductAndSum(n):
    sums = 0
    product = 1
    
    while(n != 0):
        digit = n % 10
        sums += digit
        product = product * digit
        n = n // 10
    
    return (product - sums)

print(subtractProductAndSum(234))
```
So this was the simplest solution for this problem you can also try different approaches to solve this problem in a efficient way.

Thanks for your valuable time. You can like my post and
you can.

[By me a Coffee](https://www.buymeacoffee.com/saim783)

[My other Blog Website over Technology](https://www.saimtechnews.in)

[My YouTube Vlog Channel](https://www.youtube.com/c/abdullavlogs)
DO NOT do this, while building a React app!
Tags: react, reactnative, programming, architecture
Published: 2022-05-22 11:11:11

Maintaining standards and a good workflow while building the React application can give you some hard times, mainly because of time constraints. We usually do some things that make it hard to either debug or read our code later and that's a bad practice.

Here's a list of things to avoid when build React applications. Consider that most of these points can be used in things like Angular and Vue.

- 💡 **Do not share CSS across multiple components**

So one big mistake we make once in a while would be to have a central CSS file usually our app.css and just put all our styling inside that, this is very bad mainly because when the project starts getting large styles may start conflicting.

- 💡 **Avoid having large Component files.**

Having large component files gets annoying for everyone working in your team, and in time it may be hard debugging components previously built. Dividing components should be done by tearing down a user interface to the most basic building blocks or components. This reduces the complexity of the component and provides an easier way of knowing if something goes wrong.

- 💡 **Share reusable Functions across Components**

Try your best to have components or files that aren't large, by declaring util functions that are used across multiple components and exporting those functions. This way the components can access them, and it helps to remove repeated codes.

- 💡 **Passing functions down as children params**

During development, we run into issues like parent components needing to update states to cause a re-render during the app's running process, so we create a function in the parent component and pass the function that interacts with that component. But in a case where the component for some reason doesn't work, we'd have to go a long way searching for the parent component that doesn't pass this function. One way to avoid this is to use the React context provider which shares state with all the children component it has in the application.
#BehindTheGame
Tags: gamedev, javascript, html
Published: 2022-05-22 11:07:25

Hi all! I am here to discuss about some of new ongoing project named **#BehindTheGame**, an initiative of talking about the techniques I used during the development process of my games via YouTube videos.

These videos will be uploaded from time to time (depending on my free time) especially after I released the games to multiple platforms (see my bio for details) and received feedbacks from players across the globe. This way, I can make sure that the videos will be based on the best version of the games that I made. The videos will also be divided into parts to make it easier for people to watch at their own choice and pace.

That's all for now. Stay tuned for more updates.

Links:
[Official YouTube Channel](https://bit.ly/38RjP9P)
[Official Itch Website](https://bit.ly/3vr130x)
[Official GameJolt Website](https://bit.ly/3Oj8O1l)
[Official Liluo Website](https://bit.ly/38uQpyJ)
Smart code vs dump code.
Tags: programming
Published: 2022-05-22 10:56:36

About 6 months ago my team wrote an app that allows a user to change aspects of their order.

The app works by first initiating a transaction and then guides the user through a series of steps until a "review changes" page is reached. On the review page the user can review their changes and either submit, repeat the flow and make further changes or cancel.

Between each step in the flow an api call, updateOrder, is made to save progress.  However when moving from the last page in the flow to the review page a different api call, updateOrderWithPrice, needs to be made, which, in addition to saving their changes also recalculates the price of the order to be presented on the review page.

The api call updateOrderWithPrice takes longer than updateOrder because in addition to saving the changes to the transaction it has to also calculate the new price.

Everything works well, except that the decision of when to use updateOrder or updateOrderWithPrice is left up to the developer and therefore the developer has to be familiar with the api. This is particularly a problem when onboarding new developers and I have seen the wrong api being used.

We know that the updateOrderWithPrice api is synonymous with moving from the last page in the flow to the review page. likewise, updateOrder is synonymous with moving between the earlier pages in the flow.

Therefore to reduce the cognitive load and human error we should remove the choice from the developer and instead have an underlying mechanism in the application that makes to decision for the developer.  Therefore the developer only needs to specify which page to move to next and the application will decide whether it needs to call updateOrder or updateOrderWithPrice.  This removes the burden from the developer and therefore the chance for human error.

There are many ways this could be done and it would depend on the application. This particular application uses React Redux so we can therefore take advantage of this by introducing a middleware that persists calls the appropriate api when the the action to move to the next page is dispatched.

To me this is the difference between smart code and dumb code.  Dumb code simply executes what it's told to and leaves all of the decisions up to the developer. Smart code by contrast is  goal focused and takes care of the underlying details of achieving that goal.  In the case above, the developers goal is the move to the next page and only needs to decide which page that is, the rest is left up to the application.

This would also simplify testing as you would initially have a test to prove that we moving between pages the right api is called.  The when creating a new flow you would only need to test that the user is navigated to the right page, not which api is called since that test already exists.
Nuxt and Cloudflare, how to get SSR working (2 settings)
Tags: nuxt, cloudflare, ssr, localhost
Published: 2022-05-22 10:00:21

You have nuxt with cloudflare and might notice your pages are not server side rendering and are instead trying to fetch the data in the browser.

In cloudflare switch off javascript and html minification to fix the issue:
![Image "cloudflare options to fix nuxt ssr"](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/niogw29i0vbrmo06thgp.png)
 
**Why?**
It seems cloudflare minification removes things that nuxt needs to function.