teleren/devto huggingface dataset:
Coding just got better with Amazon CodeWhisperer
Tags: developers, webdev, aws, coding
Published: 2023-01-18 09:54:58

**CodeWhisperer** is a ML-powered service that helps improve developer productivity by generating code recommendations based on their comments in natural language and code in the IDE.

**CodeWhisperer** will continually examine your code and your comments, and present you with syntactically correct recommendations. The recommendations are synthesized based on your coding style and variable names, and are not simply snippets.

CodeWhisperer uses multiple contextual clues to drive recommendations including the cursor location in the source code, code that precedes the cursor, comments, and code in other files in the same projects. You can use the recommendations as-is, or you can enhance and customize them as needed. We trained (and continue to train) CodeWhisperer on billions of lines of code drawn from open source repositories, internal Amazon repositories, API documentation, and forums.

Join the Preview. During the preview period, developers can use CodeWhisperer at no cost. 👈

The preview supports code written in Python, Java, and JavaScript, using VS Code, IntelliJ IDEA, PyCharm, WebStorm, and AWS Cloud9.

#CodeWhisperer
Dynamics365 Business central - Upgrade tags
Tags: businesscentral, al, microsoft, dynamics365
Published: 2023-01-18 09:37:04

## The problem
Sometimes you get into situations in which you need to change certain things within the BC database, or some other third party service, before allowing the user to use the application

Maybe you want to migrate some records from table A to table B, or turn on a new setting on all existing records within a table.

On most platforms, something like that would be called an "upgrade script", or a "seeder", and a system like this is definitely possible using business central's "upgrade tags"

---

## Upgrade tags
In Business central, you can add upgrade tags to your application which keeps track of all of the previous versions. That way you can compare the last upgrade tag to the current version, and do certain upgrade functions based on that.

This is all handled within your install codeunit (a codeunit with SubType=Install), and upgrade codeunit (a codeunit with SubType=Upgrade).

These upgrade tags do have a specific format standardized by Microsoft, however you can technically use any format. Microsoft recommends using `[CompanyPrefix]-[ID]-[Description]-[YYYYMMDD]`. For example: `ABC-1234-MyExtensionUpgrade-20201206`.

---

## Install codeunits
In the install codeunit, we need to set the upgrade tags that you decided to have until now, for example:

{% embed https://gist.github.com/justlucdewit/cb972bffc093784d99fb44e1ceb9b703 %}

Whats happening here isn't that complicated. All we are doing is checking if an upgrade tag exists, and if not: make it exist.

That way, when we freshly install the extension, we can be sure that all upgrade tags have been initialized, and therefore no upgrade function will be run (since we only want to run them when you upgrade from version A to version B, not when you do a fresh install).

---

##  Upgrade codeunit
Now in the upgrade codeunit, we can check what upgrade tags we are missing, in which case we can activate some upgrade function, and add the upgrade function when we are done.

This is done like the following:

{% embed https://gist.github.com/justlucdewit/1dd6e6d6a4c84852ddbcd85f35471ddc %}

---

## Debugging upgrade codeunit
You might have some troubles debugging the upgrade script since its only triggered once you upgrade from one version to another. However this is easily fixed since you can force upgrade business central to upgrade from version X to the same version X. This wont actually do anything except trigger the upgrade codeunit (which we want)

To do this, you need to go to your launch.json and set forceUpgrade to true:

```
{
    "configurations": [
        {
            "forceUpgrade": true
        }
    ]
}
```

---

## Conclusion
Upgrade Tags in business central is an excellent tool to handle seeders/upgrade scripts. And I highly recommend this system when tackling this problem.

Make use of these build-in Microsoft AL functionalities as much as you want, and have fun coding!
How to Install Django and Start Your Project
Tags: django, python, programming, backend
Published: 2023-01-18 09:35:15

To install Django, you'll need to have Python installed on your computer. Once you have Python, you can use pip, which is a package manager for Python, to install Django.

Open a terminal or command prompt and enter the following command:

Copy code
``pip install Django``
This will install the latest version of Django. Once the installation is complete, you can start a new Django project by running the following command:

Copy code
``django-admin startproject projectname``
This will create a new directory called "projectname" in your current directory, with the basic file structure of a Django project.

To start the development server, navigate to the project directory and run the following command:

Copy code
``python manage.py runserver``
You can then view your project by navigating to http://127.0.0.1:8000/ in your web browser.

You can refer to Django official documentation for more detailed information about how to start programming with Django. https://docs.djangoproject.com/en/3.2/intro/tutorial01/
Send Fanout Event Notifications with SQS and SNS
Tags: aws, cloud, awscommunity, 100daysofcloud
Published: 2023-01-18 09:07:17

[18/100] #100DaysOfCloud Today, I implemented a fanout scenario using Amazon SNS and Amazon SQS. 

<u>Amazon SNS :</u>
Amazon Simple Notification Service (Amazon SNS) is a managed service that provides message delivery from publishers to subscribers (also known as producers and consumers). Publishers communicate asynchronously with subscribers by sending messages to a topic, which is a logical access point and communication channel. Clients can subscribe to the SNS topic and receive published messages using a supported endpoint type, such as Amazon Kinesis Data Firehose, Amazon SQS, AWS Lambda, HTTP, email, mobile push notifications, and mobile text messages (SMS).

<u>Amazon SQS :</u>
Amazon Simple Queue Service (Amazon SQS) offers a secure, durable, and available hosted queue that lets you integrate and decouple distributed software systems and components. Amazon SQS offers common constructs such as dead-letter queues and cost allocation tags. It provides a generic web services API that you can access using any programming language that the AWS SDK supports.

<u>Fanout Scenario :</u>
- The Fanout scenario is when a message published to an SNS topic is replicated and pushed to multiple endpoints, such as Kinesis Data Firehose delivery streams, Amazon SQS queues, HTTP(S) endpoints, and Lambda functions. This allows for parallel asynchronous processing.
- For example, you can develop an application that publishes a message to an SNS topic whenever an order is placed for a product. Then, SQS queues that are subscribed to the SNS topic receive identical notifications for the new order. An Amazon Elastic Compute Cloud (Amazon EC2) server instance attached to one of the SQS queues can handle the processing or fulfillment of the order. And you can attach another Amazon EC2 server instance to a data warehouse for analysis of all orders received.
- You can also use fanout to replicate data sent to your production environment with your test environment.

You can try to Implement a fanout scenario using Amazon SNS and Amazon SQS by yourself by following the steps from the link below:
[GitHub](https://github.com/aaditunni/100DaysOfCloud/blob/main/Journey/018/Readme.md)
Tìm path của JDK từ command line
Tags: java
Published: 2023-01-18 08:45:34

If you are using Linux/Unix/Mac OS X:

Try this:

```
$ which java
```

If you are using Windows:

```
c:\> for %i in (java.exe) do @echo.   %~$PATH:i
```



https://stackoverflow.com/a/4681109/373266
The CIA Triad + AAA
Tags: cybersecurity, security, beginners
Published: 2023-01-18 08:41:18

The CIA triad is a model for information security that stands for **Confidentiality**, **Integrity**, and **Availability**.

## Confidentiality
Confidentiality refers to protecting sensitive information from unauthorized access or disclosure. This includes things like user passwords, personal data, and confidential business information. Ensuring that only authorized people have access to sensitive information is a key aspect of confidentiality.

## Integrity
Integrity refers to ensuring that information is accurate and trustworthy, and protecting it from unauthorized modification or destruction. This includes things like data validation, backups, and access controls. It ensures that the information is accurate and has not been tampered with or corrupted.

## Availability
Availability refers to ensuring that authorized users can access the information they need, when they need it. This includes things like disaster recovery, load balancing, and redundant systems. This means that the system should be up and running most of the time and the information should be accessible to the authorized users.

The CIA triad is a widely recognized standard for information security and is often used as a framework for developing security policies and procedures. It is used to ensure that all aspects of security are considered and addressed, from protecting sensitive information to ensuring that users can access the resources they need.

But it can also be expanded to also include **Authorization**, **Authentication**, and **Auditing**.

## Authorization
Authorization refers to the process of determining what actions a user is allowed to perform. It ensures that a user can only access or perform actions on the resources they are authorized to access or use.

## Authentication
Authentication refers to the process of verifying the identity of a user. It ensures that only authorized users can access the system, and that they are who they claim to be.

## Auditing
Auditing is the process of recording and reviewing system activities, it can be used to detect any unauthorized access, modification or deletion of data. It also helps to ensure compliance with regulations and standards.

By adding these three concepts, the CIA triad becomes a more robust model. Authorization, Authentication, and Auditing work together with Confidentiality, Integrity, and Availability to ensure that the sensitive information is protected at all times, that the data is accurate and trustworthy, the systems are always available and accessible to only authorized users, and that any variation from the expected usage can be detected and investigated.

More reading:
https://www.fortinet.com/resources/cyberglossary/cia-triad
https://github.com/OWASP/DevGuide/blob/master/01-Foundations/01-Security%20Fundamentals.md
https://nvlpubs.nist.gov/nistpubs/ir/2017/NIST.IR.8062.pdf
Developer Productivity: Apple unveils MacBook Pro featuring M2 Pro and M2 Max
Tags: apple, laptop, developer, productivity
Published: 2023-01-18 08:01:39

**Apple** has [released](https://www.apple.com/newsroom/2023/01/apple-unveils-macbook-pro-featuring-m2-pro-and-m2-max/) a new generation of its **MacBook Pro with M2 Pro** and **M2 Max chips**. The only problem is that I already bought the M1Max and it's perfect.

New MacBook Pro features up to 6x faster performance than fastest Intel-based MacBook Pro and support for up to 96GB of unified memory for demanding pro workflows.

![MacBook Pro with new M2 Pro and M2 Max](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oeoiekn0dh57snag5oq4.jpg)

For curiosity, I ran a test with MacBook Pro M1 Max apple silicon, and I can confirm that compile/build tasks show performance x2-x3 times faster, as well as application startup and settings load sometimes x5 faster (subjective opinion).

I really love new Apple chips, plus they are completely silent.

If you're still on older laptops, it's definitely worth considering an upgrade.

Have you tried the new chips yet? What performance numbers did you get?
A Fun Programming Joke To Start Your Day
Tags: jokes, dailydeveloperjokes
Published: 2023-01-18 08:00:24

---
title: "A Fun Programming Joke To Start Your Day"
description: "Check out today's daily developer joke! (a project by Fred Adams at xtrp.io)"
series: "Daily Developer Jokes"
published: true
tags: #jokes, #dailydeveloperjokes
---

Hi there! Here's today's Daily Developer Joke. We hope you enjoy it; it's a good one.

![Joke Image](https://private.xtrp.io/projects/DailyDeveloperJokes/public_image_server/images/5e1258cecd22f.png)

---

For more jokes, and to submit your own joke to get featured, check out the [Daily Developer Jokes Website](https://dailydeveloperjokes.github.io/). We're also open sourced, so feel free to view [our GitHub Profile](https://github.com/dailydeveloperjokes).

### Leave this post a ❤️ if you liked today's joke, and stay tuned for tomorrow's joke too!

_This joke comes from [Dad-Jokes GitHub Repo by Wes Bos](https://github.com/wesbos/dad-jokes) (thank you!), whose owner has given me permission to use this joke with credit._

<!--
Joke text:
___Q:___ Why did the computer squeak?

___A:___ Because someone stepped on its mouse!
 -->
generate_series() in Oracle like in PostgreSQL
Tags: oracle, postgres, sql
Published: 2023-01-18 07:59:55

If you often switch between RDS databases you may be annoyed by the lack of similar API despites the SQL standard.

When I want to quickly generate rows in PostgreSQL or PostgreSQL-compatible like Amazon Aurora or YugabyteDB, I use `generate_series()` like:

```sql
create table demo ( id bigint primary key, value int default 0 );
insert  into demo ( id ) select id from generate_series(1,1000) id;
```

How to do the same on Oracle?
For a long time, I used:
```sql
(select rownum as id from dual connect by level <=1000);
```
But this is long for more than a thousand rows and is a side effect of the non-standard implementation for recursive queries. Basically, it works but you don't know why.

AS I'm from the lucky generation that has seen these beautiful XML functions coming into the database, I use:
```sql
(select to_number(column_value) as id from xmltable('1 to 1000'));
```
which is more efficient to generate millions of rows. But not better for understanding: writing the range of integers as a character string containing the boomer's XQuery loop with a `to `clause 😂 and this XMLTABLE() function where I never remember that there's no underscore in it unlike most SQL functions.

When you move to PostgreSQL, `generate_series(start,stop)` comes as a much better solution. Thanks to SQL Macros, it is easy to emulate in Oracle:

```sql
create or replace function generate_series( "start" in int, "stop" in int )
  return varchar2 SQL_MACRO(TABLE) as
begin
 return 'select to_number(column_value) as generate_series from xmltable('''
  ||generate_series."start"||' to '||generate_series."stop"
  ||''')';
end;
/
```

The idea of SQL Macros is that they generate the SQL string. You write once this ugly `xmltable(' ... to ...')` and use it as you would use the PostgreSQL one with a start and stop value.
Testing and Modules
Tags: webdev, django, tdd, python
Published: 2023-01-18 07:50:17

## What are Unit tests and TDD?

### Unit tests:

Unit tests are some pieces of code that exercise the input, the output, and the behavior of your code.

### TDD tests:

Test-Driven Development is a strategy that entails first thinking about (and writing!) tests.

## Baby Steps:

1. what is the smaller test that we can do against a function?
    

```python
  def test_should_return_female_when_the_name_is_from_female_gender():
    detector = GenderDetector()
    expected_gender = detector.run(‘Ana’)
    assert expected_gender == ‘female’
```

1. There are some details to pay attention. The first one is the test name. The tests can be considered as your live documentation.
    
2. The test file name should follow the same name as the module name.
    
3. It’s ideal to separate the tests folder from the production code (the implementation)
    
4. Another thing to care about is the structure. A convention widely used is the `AAA`: **Arrange, Act and Assert**.
    

> > * Arrange: you need to organize the data needed to execute that piece of code (input)
> >     
> > * Act: here you will execute the code being tested (exercise the behaviour)
> >     
> > * Assert: after executing the code, you will check if the result (output) is the same as you were expecting
> >     

## The Cycle:

### The cycle is made by three steps:

* 🆘 Write a unit test and make it fail (it needs to fail because the feature isn’t there, right? If this test passes, call the Ghostwriters, really)
    
* ✅ Write the feature and make the test pass! (you can dance after that)
    
* 🔵 Refactor the code — the first version doesn’t need to be the beautiful one (don’t be shy)
    

## Takeaways

### [To remember:](https://code.likeagirl.io/in-tests-we-trust-tdd-with-python-af69f47e6932)

* The greatest advantage of TDD is to craft the software design first.
    
* Your code will be more reliable: after a change, you can run your tests and be in peace.
    
* The beginning may be hard — and that’s fine. You just need to practice!
do you prefer Makefile or package.json
Tags: makefile, make, packagejson
Published: 2023-01-18 07:49:39

---
title: do you prefer Makefile or package.json
published: true
description: as php developer I always used Makefile to run simple tasks. Often to wrap some docker commands, for example. But is package.json a better alternative?
tags: makefile, make, packagejson
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kt6kc4sm0m8tosocyz0r.png
---

## Scenario

As developer I need a tool to run some tasks programmatically. Since I have the memory of a goldfish, I always used Makefile, thus each task is written inside a target.

## Autocomplete

With autocomplete Makefiles helped me in digitations and in memory issues. In those cases tab is a good friend whenever I was in a terminal. I can type `make` and then press tab. Autocomplete show all targets available and this can make the job very easy.

## Node.js projects

In Node.js project we have a package.json. I never used autocompletion in those cases. The nice part of Node.js projects, in this kind of context, is that we already have a package.json file and no other stuffs are needed.

## Replace Makefiles with package.json

Because of I am developing Node.js exercices for some youtube videos, .. I am moving all the things I always had in Makefile, .. inside package.json scripts.

## package.json example

```json
{
    "name": "youtube-poliglotta",
    "version": "1.0.0",
    "dependencies": {
        "@fastify/mongodb": "5.0.0",
        "fastify": "4.11.0"
    },
    "scripts": {
        "start": "node server.js",
        "start-mongo": "docker run -d  --name my-mongo -p 27017:27017 -e MONGO_INITDB_ROOT_USERNAME=mongoadmin -e MONGO_INITDB_ROOT_PASSWORD=secret mongo",
        "stop-mongo": "docker stop my-mongo"
    }
}
```

In this case: `npm run start-mongo` help me to run, for example, mongo container.

## The same with Makefile

```json
up:
	docker-compose up -d
```

In this case we have simple configuration.

## Conclusion, pros, cons, ...

Both instruments are good. I love Makefile mainly for the autocomplete feature. This issue can be solved with [this npm package](https://docs.npmjs.com/cli/v6/commands/npm-completion) for example. With Makefile we have separate file for tasks. Both are good to store somewhere tasks and avoid some documentation to remember how things should be done. I've seen most developer use package.json to add some tasks. In the manner you can see in examples. Makefile sometimes is not known. Package works both with Windows and *nix system.

So, .. what's your point of view? Are there other alternatives you use to run tasks? Please leave a comment.
Shadowing in Rust
Tags: rust, beginners, programming
Published: 2023-01-18 07:47:46

While Rust comes with strict static typing, surprisingly it supports the concept of Shadowing for types. Shadowing allows  variable that was once declared as one type to be redeclared as a new type. In effect, shadowing or overwriting the previous declaration.

Let's take a quick look at Shadowing in Rust. Here's an example of the beginner's favorite guessing game example.

{% embed https://gist.github.com/hackintoshrao/8a5121c22930bada9aef219bbdac9b72 %}
Take a look at line number 10 and 15, and observe that the variable `guess` is declared. First time as a mutable string, and then as an immutable unsigned 32-bit integer.

Shadowing lets us re-use the guess name, rather than forcing us to come up with two unique names like `guess_str` and `guess`, or something else.
Magento Development
Published: 2023-01-18 07:25:48

iQlance Solutions is a Canadian company that provides Magento B2B Web Development services, integration, and support, among other things. Our **[Magento development](https://www.iqlance.com/magento-development/)** services are dependable and industry-specific. In addition to assisting you in reaching a larger audience and expanding your business, the scalability and adaptability of our services will assist you in attracting and converting more prospects.

Benefits Of Hiring iQlance Magento development Toronto

With our Magento developer Toronto, we design Magento websites with the user experience in mind, therefore we never scrimp on functionality or security. With a complete approach to development, meticulous respect for IT industry norms and deadlines, and an emphasis on producing designs that are both beautiful and technically easy, our Magento Development business provides solutions that are both powerful and industry-specific. Our primary objective is to provide you with an exceptional online buying experience.

iQlance Magento developers' team of experts in a variety of industries delivers Magento services and online solutions through their Custom Magento Design & Development Services. We create engaging sites that increase company and income by utilizing cutting-edge technology and clear lines of communication.
ProductDetails.jsx:55 Uncaught TypeError: Cannot read properties of undefined (reading 'name')
Published: 2023-01-18 07:22:50

I have got this error when I am trying to get product details from api.
ProductDetails.js : 
`
```import { useParams } from "react-router-dom";
import styles from "./ProductDetails.module.css";
import { useEffect } from "react";

import { useDispatch, useSelector } from "react-redux";
import { detailsProduct } from "../../Redux/actions/productActions";
import Loading from "../../components/Loading/Loading";
import MessageBox from "../../components/MessageBox/MessageBox";

function ProductDetails() {
  const dispatch = useDispatch();
  const { productId } = useParams();
  const { product, error, loading } = useSelector(
    (state) => state.productDetails
  );

  useEffect(() => {
    dispatch(detailsProduct(productId));
  }, [dispatch, productId]);

  return (
    <>
      <div className={styles.app}>
        <h2>{product.name}</h2>

        {loading ? (
          <Loading />
        ) : error ? (
          <MessageBox>{error}</MessageBox>
        ) : (
          <h2>{product.name}</h2>
        )}
      </div>
    </>
  );
}
`
export default ProductDetails;



productAction.js :

`
export const detailsProduct = (productId) => async (dispatch) => {
  dispatch({ type: PRODUCT_DETAILS_REQUEST, payload: productId, });
  try {
    const { data } = await Axios.get(`/api/products/${productId}`);
    dispatch({type: PRODUCT_DETAILS_SUCCESS,payload: data});
  } catch (error) {
    dispatch({
      type: PRODUCT_DETAILS_FAIL,
      payload:
        error.response && error.response.data.message
          ? error.response.data.message
          : error.message,
    });
  }
};
`



productReducer.js :

`
export const productDetailsReducer = (
  state = { loading: true, product: {} }, action) => {
  switch (action.type) {
    case PRODUCT_DETAILS_REQUEST:
      return { loading: true };

    case PRODUCT_DETAILS_SUCCESS:
      return { loading: false, product: action.payload };
    case PRODUCT_DETAILS_FAIL:
      return { loading: false, error: action.payload };

    default:
      return state;
  }
};
`