teleren/devto huggingface dataset:
How Typescript differ from Javascript
Tags: webdev, javascript, typescript, development
Published: 2023-07-17 10:17:26

In this small section we will be exploring typescript advantages over javascript how it can be used for the better development purpose.
**Types** Mostly Typescript contains some special keyword like **Number,String,Boolean** but some are very import as they might cause an lot of bug in code like **Any and Never** these two keyword makes hell if you don't use  them carefully many developer face problem with any and never keyword as Typescript is Type defined language so to be precises we have to used these data carefully what they are return value etc.

```
Javascript :
let value=32134;
Typescript 
let value:number=32134;
```
_Disclaimer not to use any_
let us take an example

```
let hero 

function gethero(){
return "gfg";
hero=gethero()
```
In above example typescript will automatically detect the return type and it will show us **any** this means no type is define so by default it will take any as type so this value can be changed if any keyword is define it can be boolean ,number ,string any thing this may create a havoc in your code so be careful while using any keyword  in your code.

In the next section we will learn about how to use typescript in your defined function lets say 

```
function data(email:string){
 email.toUpperCase();
```
Let us take the above example in that we have taken a function which will take parameter as email  and that to is defined as string that is new thing that we have introduced in Typescript,which was not in javascript
**If you want to return type of function**

```
function data(email:string):boolean{
return true;
```
Here we have defined the return type of function data which has return type of boolean so it will return the true and false value

In this section we will be learning **Interface** how to use? where to use? when to use ?

```
interface User{
name:string;
id:number;
above18:boolean
```
this is an interface defining to use the and define various data and the object inside it with single name if User which can be further used

```
const value:User{
name:"bet",
id:52,
above18;true,
```
This is the way how to use interface with the object value by use of previous data

There is lot of discussion in the Tech industry that where to use **interface vs type**
We can use both of them but there is problem if you want to add more data in type it will give error but on the other side interface it will not give you error.That means interface can be extended

One more major Advantage of type over interface is that it can be used as **union,tuples and primitive** this section will be covered in next blog 

Now here comes the important points where to use interface and where to use types 
Interface
- if new object need to bed defined
Type
- When your need is to define tuples,primitive and union
- if you are using map type function to take the value

some important topics like Generics,tuples,primitive usage of typescript in abstract class
How can I trigger two functions
Published: 2023-07-17 10:15:30

Hi I am a bit new to Laravel, I bought a template and I am trying to add Chatify to it, Chatify has its own Light/Dark mode and my template also has a light/dark mode, what I would like to do it have the template switch both.

These are the two functions, they are in different files.

`   // Theme Change by Header Button - main App switch
$("#themeMood").on("click", function () {
    if (currentTheme === "light") {
        currentTheme = "dark";
    } else {
        currentTheme = "light";
    }
    localStorage.theme = currentTheme;
    location.reload();
});

$("#grayScale").on("click", function () {
    if ($("html").hasClass("grayScale")) {
        $("html").removeClass("grayScale");
        localStorage.effect = "";
    } else {
        $("html").addClass("grayScale");
        localStorage.effect = "grayScale";
    }
});
// Switch to Dark/Light mode  - Chatify switch
$("body").on("click", ".dark-mode-switch", function () {
    if ($(this).attr("data-mode") == "0") {
        $(this).attr("data-mode", "1");
        $(this).removeClass("far");
        $(this).addClass("fas");
        dark_mode = "dark";
    } else {
        $(this).attr("data-mode", "0");
        $(this).removeClass("fas");
        $(this).addClass("far");
        dark_mode = "light";
    }
});
`

The button in Chatify uses the dark-mode-switch class and the template uses the themeMood id I have tried adding the class to the template button but its not triggering the function, I tried moving the function to the same file, but still didn't work.

Any idea how I can get this to work?
How to deploy gatsby static website on S3 and Cloudfront
Tags: staticwebapps, gatsby, staticwebsite, seo
Published: 2023-07-17 09:53:12

## Overview
In this page we will walks through how to deploy a Gatsby static website to AWS using S3 bucket and Cloudfront to improve loading time of site.
## Prerequisite
- Assume that you already have a AWS account and setup profile from local workstation. Check out the document to setup AWS profile at local machine.
- A Gatsby application deploped from machine and ready for deploy to AWS S3 and CloudFront.
- From AWS console, go to S3 bucket and create an S3 bucket e.g demobucket.com, the bucket name also is domain name for the static websit (it is optional to have bucket name match domain name if you using CloudFront). Follow the document to [config website hosting for S3 bucket ](https://docs.aws.amazon.com/AmazonS3/latest/userguide/HostingWebsiteOnS3Setup.html)
## Implement
To allow deploying to S3 we need to install additional S3 plugin and config gatsby-config.js file to to ready for use.
First make sure npm installed, then run the following to install s3 plugin
`npm install gatsby-plugin-s3`
Now the plugin already installed, we start adding configuration in gatsby-config.js

```
plugins: [
  {
    resolve: `gatsby-plugin-s3`,
    options: {
      bucketName: "<put-your-bucket-here>",
    },
  },
]
```

To allow deploy to S3 bucket, first add the following code block to package.json file

```
{
  "scripts": {
    "deploy": "gatsby-plugin-s3 deploy"
  }
}
```
then connect to the AWS by export the profile, follow the link to [config AWS profile](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html) from your local machine. After that, run build and deploy to do a build and deploy to the S3 bucket.

```
npm run build
npm run deploy
```
Now you can access to the S3 bucket and access from web browser for the static web. If you need an integration between Amazon S3 and Cloudfront check out the document [Static website on Amazon S3 and Cloudfront](https://www.galireview.com/blog/static-website-on-amazon-s3-and-cloudfront/).
Understanding AWS CloudFormation Execution Permissions
Tags: aws, cloud, devops, cloudformation
Published: 2023-07-17 09:51:12

Do you know how CloudFormation generates permissions to provision resources in your account?

In my new article on the AWS Fundamentals blog, we walk through the CloudFormation lifecycle and how you can apply security concepts like the least privileged access in the deployment of your stack.

https://blog.awsfundamentals.com/aws-cloudformation-execution-permissions
What Challenges Do Software Developers Face in Cyber Security?
Tags: cybersecurity, programming, development, developer
Published: 2023-07-17 09:32:47

![cyber-security-threats-for-software-developers](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jw1bxs8bj93eykwvej4d.jpg)Increasing digital awareness in the world of business has also led to the growth of cyber threats and attacks by cyber criminals using various methods, including exploiting any vulnerability associated with software or applications to target them by gaining unauthorized access.

Hence, developers need to be constantly updated about different cyber security threats, vulnerabilities, or challenges that are harmful for their software and applications, such as:

**1.Data Breaches**

**2.Malware Attacks**

**3.Ransomware** 

**4.Phishing Attacks**

**5.Trojan Horse Viruses**

**6. Distributed Denial-of-Service (DDoS) Attacks**

**7. Cloud Security**

**8. Data Theft**

**9. Unpatched Software Vulnerabilities**

Continue reading through the [Most Common Cyber Security Challenges of Software Developers](https://signmycode.com/blog/most-common-cybersecurity-challenges-of-software-developers) to discover each of these cyber security threats in detail and any possible solution to handle them effectively.
Peak-End Rule
Tags: peakperformance, userexperience, peakendrule, storybytes
Published: 2023-07-17 09:27:40


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/340jzmp98aafto2rd8k1.png)
What is more important, how we start or how we finish? As this question can be viewed from many angles, most of us agree that we want to finish it with a sense of satisfaction. In User Experience, the psychological layer does express many insights. Users do have emotions. Emotions can be up and down all the time on the entire digital journey of your solution. Some of the emotions do reach a peak at their moment - which can seed a positive or negative experience. As producers of a digital journey, we are responsible for seeding more positive experiences than negative ones. But, once the journey ends, you can’t control where the seed is now. Users judge an experience largely based on how they felt at its peak and at its end rather than the total sum or average of every moment of the experience. Not all users have the superpower to reflect and handle the good and the bad experiences in the end. That’s why never underestimate the Peak-end effect. Pay close attention to the most intense points and the final moments (the “end”) of the user journey. Identify the moments when your product is most helpful, valuable, or entertaining and design to delight to the end user. By seeking out and crafting certain experiences, we can seed better memories that will probably last longer. In the end, the end matters a lot.
best online react course
Tags: beginners, programming, react
Published: 2023-07-17 09:24:30

Learn React Online Course with IntelliMindz


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



React JS is one of the most popular JavaScript frameworks for structure the user interfaces. It is used by some of the biggest companies in the world, such as Facebook, Instagram, and Netflix. If you want to learn React JS through online, IntelliMindz is the perfect place to start.

Our React Online Course is designed to teach you everything you need to know about React JS, from the basics to advanced concepts. You will learn how to create React components, use state and props, and build complex React applications.

Our course is taught by experienced React JS developers who will help you understand the concepts and apply them to real-world projects. You will also have access to our online learning platform, where you can watch video lectures, take quizzes, and ask questions.

What you will learn in our React Online Course:

•	The basics of React JS			
•	How to create React components
•	How to use state and props
•	How to build complex React applications
•	How to use React with other JavaScript libraries
•	How to test React applications

Benefits of learning React JS:

•	React JS is in high demand, so there are many job opportunities available
•	React JS is a versatile framework that can be used to build a wide variety of applications
•	React JS is easy to learn, even if you don't have any prior JavaScript experience


Why choose IntelliMindz for your React JS training?

•	We have experienced React JS developers who will teach you the concepts and help you apply them to real-world projects
•	Our online learning platform makes it easy to learn at your own pace
•	We offer a 100% satisfaction guarantee
•	Enroll in our React JS Online Course today and start learning the skills you need to build amazing user interfaces!


To enroll or learn more about our online course, 
Please visit our website www.intellimindz.com
Or
Call our admissions team @ +91 9655877677 / +91 9655877577. 
We look forward to helping you achieve your data science goals!
Infrastructure as Code
Tags: devops, iac, storybytes
Published: 2023-07-17 09:19:01


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/odae23hw3iqb89u1sami.png)
Managing a server is a huge responsibility. One needs to carefully curate their critical systems and ensure the business runs smoothly by their continued function. You might’ve heard about new ways of managing environments like DevOps or Site Reliability Engineering. In today's world, many applications are quite complex. They need different components like a load balancer, web servers, database servers, and systems to process tasks in a queue. It takes a lot of time to set them up and manage them. Infrastructure as code (IaC)  makes this process much faster and easier! A framework like Chef, Ansible, AWS CloudFormation, or Puppet is commonly utilised to determine their infrastructure. The tool used isn’t unimportant because they all work similarly. Each allows a developer to define a computer system or network of computer systems necessary to run and support their code. With IaC, developers can define the basic elements needed for their application. Instead of manually setting up each component, the IaC framework takes care of it automatically. This means that what used to take hours can now be done in just a few minutes! The IaC framework creates the right environment for the application by putting together all the necessary pieces.  There are two ways to approach IaC: declarative or imperative. A declarative approach defines the system’s desired state, including what resources you need and any properties they should have, and an IaC tool will configure it for you.  An imperative approach instead defines the specific commands needed to achieve the desired configuration, and those commands then need to be executed in the correct order. In simpler terms, IaC is like having a blueprint for building an application's infrastructure. Instead of constructing each part by hand, the IaC framework does it for you, saving time and effort
Explore the best strategies to migrate to the AWS cloud
Published: 2023-07-17 09:15:17

## Best strategies to migrate to the AWS cloud

AWS migration refers to the process of moving an organization's IT infrastructure, applications and data to the cloud-based services offered by Amazon Web Services (AWS). The migration process can be complex and requires careful planning and execution to ensure a smooth transition to the cloud. 

> “A recent whitepaper by IDC shows, the customers that migrate to AWS can experience 51% reduced costs of operations, 62% increased IT staff productivity and 94% reductions in downtime. 

Some of the benefits of AWS migration include cost savings, scalability, increased security and access to a wide range of cloud-based services. In this white paper, we have described how AWS works, the four phases of the migration process and six common migration strategies in detail. 

**What you will learn about: **

- Introduction to Amazon Web Services 
- Understanding how AWS works 
- Brief overview of some AWS services 
- Overview of the four-phase migration process 
- Explanation of the 6 R's of migration strategies 
- Tips for employing a successful migration strategy 
- Laying the groundwork for a successful migration 

![Best strategies to migrate to the AWS cloud](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0uwjlkg7wd3uxm6bqwkk.png)

Are you looking to move your data to AWS Cloud? Softweb Solutions can help! Our team of experts ensures a seamless transition to the cloud environment. Maximize the benefits of AWS Cloud with our proven methods. Trust us to handle your data migration securely and efficiently. 

Join the many satisfied clients who have made the move to AWS Cloud with Softweb Solutions. Get in touch today to get started on your migration journey. 

> To learn about the different migration strategies and best practices visit our whitepaper: **[Best strategies to migrate to the AWS cloud](https://go.softwebsolutions.com/resources/strategies-for-migrating-data-to-aws-cloud.html)**
Nextjs: How to check device serverside or know if mobile
Tags: nextjs, serverside, device, detectio
Published: 2023-07-17 08:55:58

I have different components that I render on Mobile vs Desktop. I like to dynamically import components depending on the device type to reduce the bundle size / unused code.

Here is a function that I use in production:
```javascript
export const getServerSideProps = async (context) => {
  // util code is in the codeblock below this one
  const {isMobile} = utilServerSideDeviceDetection(context)

  return {
   isMobile,
   ...yourotherdata
  }
}
```

```javascript
/* 
 paste this function into a file somewhere and import it 
 into a page where you need it, as seen above
*/
export const utilServerSideDeviceDetection = (context)=> {
  const isServer = !!context.req
  const userAgent: string = isServer
    ? context.req.headers['user-agent']
    : navigator.userAgent
  const isLine = /\bLine\//i.test(userAgent) || false
  const isMobile = /(iPad|iPhone|Android|Mobile)/i.test(userAgent) || false
  const rules = [
    'WebView',
    '(iPhone|iPod|iPad)(?!.*Safari/)',
    'Android.*(wv|.0.0.0)'
  ]

  const regex = new RegExp(`(${rules.join('|')})`, 'ig')
  const isInApp = Boolean(userAgent.match(regex))

  return {
    isMobile,
    isLine,
    isInApp,
    userAgent
  }
}
```
What's the Difference: Digital Certificate vs Digital Signature
Tags: cybersecurity, digitalcertificate, digitalsignature, encryption
Published: 2023-07-17 08:42:49


![digital-certificate-vs-digital-signature](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xdklob2m2tsn8z6c3s50.jpg)

Digital signatures and Digital Certificates play a crucial role in the world of cybersecurity. 

A Digital Signature guarantees the authenticity of a document, affirming its origin from a reputable organization. On the other hand, a Digital Certificate informs website visitors about the entity in possession of the corresponding public key.

While both Digital Signatures and Digital Certificates are important to cybersecurity, they differ in significant ways. If you're curious about these distinctions, we've compiled this article highlighting the major [Differences Between Digital Signatures and Digital Certificates](https://certerassl.com/blog/digital-certificate-vs-digital-signature).
Pub-Sub Architecture using FastAPI and Redis
Tags: redis, fastapi, pubsub, eventdriven
Published: 2023-07-17 08:07:31

I have tried to implement Redis as a message broker using FastAPI. Its a simple implementation to give a headstart for the event driven architecture.

Below is the high-level view for what I have implemented.


![pubsub_architecture](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h083hiigtwy40bk63k6n.png) 

Clone the [repo](https://github.com/Anu1996rag/pubsub) from here and give it a shot.

Please feel free to go through it and let me know your suggestions.
Hope to get some positive response as its my first ever post on any community platform so far ..:)

Happy Learning !!!
Openness and Trust
Tags: communication, collaboration, teaming, storybytes
Published: 2023-07-17 08:04:38


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qeh7mc9oqot8cy9msztn.png)
A safe work environment should be the ultimate goal of every organisation. It’s everyone’s job to set the tone and create the foundation for people to open up. Trust is a conviction that is built slowly through repeated interactions that take place over a long period. Openness and trust are essential for creating any personal, professional, or organisational relationship. Trust is the foundation of collaboration, communication, and performance, and it can make or break your success in any endeavour. Communication is the key to any relationship; openness and trust enhance it in many ways. It helps you to communicate empathetically, listen actively, acknowledge emotions, and show appreciation. By communicating transparently and openly, you build trust by demonstrating your reliability, credibility, and integrity and inviting feedback, input, and dialogue. Openness and Trust are not always easy or comfortable to practice, but their rewards make them worthwhile. To practice these values in your context, you should be clear about your purpose, values, and intentions and communicate them authentically. Share relevant information, feedback, and opinions without withholding or exaggerating. Listen attentively and respectfully to others without judging or dismissing their ideas. Ask for others’ feedback, input, and perspectives without assuming or ignoring them. Acknowledge your mistakes, apologise sincerely, and take action to correct them. Don’t forget to express your appreciation for others’ contributions and achievements. Finally, be open to learning and changing without being defensive or complacent. By embracing this and providing it back, the relationship will flourish - and trust will deepen.
Spending free time to self-improvement by several websites
Tags: career, homeoffice, telework
Published: 2023-07-17 08:03:02

Many programmer friends at the beginning of contact with Internet technology, it is best to find some learning materials or technical exchange forums, on the one hand, you can improve your level, on the other hand, programming process will inevitably encounter bugs or doubts, their own alone is boring can not solve the problem, help others is a good choice.

Below, I will recommend some very useful forums for your reference.

### 1. Masutaa Mutual Aid Forum

Official Website:https://masutaa.com/
Forum address: https://bbs.masutaa.com/index

The Masutaa Mutual Aid Community is a free Internet collaborative communication community under YashiSolution.

It aims to build the Masutaa Mutual Aid Community into the world's largest Internet mutual aid community exchange platform and help global IT talents flow across regions. At present, some HR, headhunters and Internet practitioners of large factories have been kindly invited to join the Masutaa mutual aid community. We hope to help some practitioners get the help and information they want in the community

The forum also provides reliable remote projects, providing part-time opportunities for the majority of excellent programmer friends.

### 2. kanxue Safety Forum

Official Website:https://bbs.kanxue.com/

Kanxue Forum is a software security technology exchange place, providing a technical exchange platform and resources for security technology enthusiasts.

Kanxue attaches great importance to software security, and has become an active community around the theme of software security based on this.

Programmer friends who are concerned about software security and encryption and decryption technology can take a look here.

### 3. Nightfall Crawler Forum

Official Website:https://bbs.nightteam.cn/

The field of crawlers is popular for its particularities such as wide knowledge, high-level content that is convenient for commercial money, and low-level content that is simple.

However, there is no dedicated technical community in the crawler field like programming languages, network engineering and other fields, but there are many communication groups in the crawler field, but it is difficult for ordinary programmers to obtain high-quality, latest developments from ordinary communication groups, so a crawler forum is a good choice.

At night, there are often technical exchanges about crawlers, and occasionally high-quality codes given by big guys. Newbies look at the night more, and the growth rate will be fast.

Well, these are the 3 forums that this article wants to recommend, and if you are interested, you can go to a wave and increase your knowledge!