teleren/devto huggingface dataset:
Why my console app freezes randomly and I need to press a key for it to continue
Tags: windows, console, dotnet
Published: 2021-08-09 08:37:19

In my current project, we have a console app that runs in the background and sends data to a frontend application. The app works great but sometimes it stops working and we need to press a key for it to continue. It turned out it was because of Windows Console's `Quick Mode` feature. [When a user clicks on the console window, it hangs the app execution to allow the user to select the text.](https://stackoverflow.com/a/30517482).

Fortunately, you can easily disable Quick Edit for your app:

```csharp
// http://msdn.microsoft.com/en-us/library/ms686033(VS.85).aspx
[DllImport("kernel32.dll")]
public static extern bool SetConsoleMode(IntPtr hConsoleHandle, uint dwMode);

private const uint ENABLE_EXTENDED_FLAGS = 0x0080;

private static void DisableQuickEditMode()
{
    // Disable QuickEdit Mode
    // Quick Edit mode freezes the app to let users select text.
    // We don't want that. We want the app to run smoothly in the background.
    // - https://stackoverflow.com/q/4453692
    // - https://stackoverflow.com/a/4453779
    // - https://stackoverflow.com/a/30517482

    IntPtr handle = Process.GetCurrentProcess().MainWindowHandle;
    SetConsoleMode(handle, ENABLE_EXTENDED_FLAGS);
}

public static void Main(string[] args)
{
    DisableQuickEditMode();
    // Do stuff
}
```
How to get secure cookies working with Nginx
Tags: tutorial, nginx, node
Published: 2021-08-09 08:25:35


## Background

As I was setting up my Node server in a VPS, I got confused as to why my cookies weren't being set.
After some time I figured out that it works in the `development` environment, but not in the `production` environment.
I kept prodding around to find out that when I set the `secure` option to true the cookies weren't being sent.

> Note: I'm using express-sessions my code roughly looks like this.

```ts
app.use(
  session({
    secret: process.env.SESSION_SECRET as string,
    resave: false,
    saveUninitialized: false,
    name: 'sid',
    store: new RedisStore({ client: redisClient }),
    proxy: process.env.NODE_ENV === 'production',
    cookie: {
      httpOnly: true,
      secure: process.env.NODE_ENV === 'production',
      maxAge: 1000 * 60 * 60 * 24 * 365, // 1 year
    },
  })
);
```

After hours of fiddling, researching, failing, and _crying_, I **finally** found the solution.

## The Solution

Apparently, you need to add the directive `proxy_set_header X-Forwarded-Proto https;` to your nginx file.

For example:

```nginx
location / {
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_set_header X-NginX-Proxy true;

    proxy_pass http://127.0.0.1:4000/;
	proxy_set_header X-Forwarded-Proto https;
}
```

And that's it! So much confusion just for one line.

## Conclusion

I mainly wrote this article out of frustration with the hours spent, hoping someone else won't go through that.

As always you can follow me on [Twitter](https://twitter.com/PaoloTiu_), and I have a [newsletter](https://buttondown.email/paolotiu) if you're into that.

## Resources

- [Related Github Issue](https://github.com/expressjs/session/issues/281#issuecomment-191359194)
MATLAB MONDAYS💥- Crash Course part-7
Tags: matlab, matabmondays
Published: 2021-08-09 08:12:27

Friends, today is the last lecture of the series MATLAB MONDAYS. Today let us summarize whatever we have learnt till now throughout the course. 
### Summary of MATLAB MONDAYS
- [Part 1](https://dev.to/aatmaj/matlab-mondays-crash-course-part-1-3o80) We had an introduction to what MATLAB is and where is it used. MATLAB stands for MATrix LABoratory. MATLAB is a scientific programming language used for simulations and data driven research. We also wrote our hello world code in this part. After that, we learnt about MATLAB variables. We can declare variables using the '=' sign, that is the assignment operator.

- [Part 2](https://dev.to/aatmaj/matlab-mondays-crash-course-part-2-2ol1) We learnt about some predefined functions in MATLAB like `rand()` `scatter()` and `min()`. MATLAB contains loads of other functions, whose documentation can be found out [here](https://in.mathworks.com/help/matlab/elementary-math.html?s_tid=CRUX_lftnav). After that we learnt control statements in MATLAB including the syntax for the while loop, for loop and if-else-elseif statements.

- [Part 3](https://dev.to/aatmaj/matlab-mondays-crash-course-part-3-414k) We studied  row and column vectors in MATLAB. Sometimes, however we may require to create row or column vectors with large number of equidistant points. We learnt how to do that automatically in MATLAB. At the end we also learnt how to take the transpose of any matrix.

- [Part 4](https://dev.to/aatmaj/matlab-mondays-crash-course-part-4-2c43) We understood the syntax for the generation of matrices. In a similar way of making matrices, we can combine them together and fuse two matrices. Besides, there also exist inbuilt functions for matrix generation, which we covered in the part.

- [Part 5](https://dev.to/aatmaj/matlab-mondays-crash-course-part-5-pm6) We checked out how to operate on matrices in MATLAB. Then we had a look at matrix multiplications Matrix multiplication can be done easily by just multiplying the two together. Many times we need to find mean, mode or median of a vector. Such a statistical analysis of the data can be done easily in MATLAB using inbuilt functions.

- [Part 6](https://dev.to/aatmaj/matlab-mondays-crash-course-part-6-2c3c) This part was reserved for accessing vectors and matrices. Many times, we need to access the elements in middle of a vector or matrix. MATLAB provides easy methods to extract out the elements. Similarly we can easily access matrices.

____
So friends, this marks the end of our course. If any among you feel that anything is remaining to be taught, or have any suggestions, doubts etc, please post in the comments below.👇
also, you can gmail me for any suggestion or help 🙌
[![LinkedIn][1.2]][1]
[![Gmail][2.2]][2]


[1.2]: https://img.shields.io/badge/linkedin-%230077B5.svg?&style=for-the-badge&logo=linkedin&logoColor=white 
[2.2]: https://img.shields.io/badge/Gmail-D14836?style=for-the-badge&logo=gmail&logoColor=white

[1]: https://www.linkedin.com/in/aatmajmhatre/
[2]: https://aatmaj.mhatre@gmail.com

Bye for now 🖐
Meet you all soon👍
15 JavaScript Project  For You
Tags: javascript
Published: 2021-08-09 07:49:31

Hello friends,
So I decided to publish 15 projects from my 100Days of JavaScript Course on YouTube.

Feel free to check it out to see my teaching style and please leave a like and comment on the video.

Here - [15 JavaScript Projects YouTube ](https://www.youtube.com/watch?v=MrnzrbaCY7U)

Discount Link to 100Days of JavaScript Full Course

- 100 Days of JavaScript Course:

5 DAY COUPON ($9.99)
[https://www.udemy.com/course/100-days-of-javascript/?couponCode=YOUTUBE-9](https://www.udemy.com/course/100-days-of-javascript/?couponCode=YOUTUBE-9)

30 DAY COUPON ($12.99)
[https://www.udemy.com/course/100-days-of-javascript/?couponCode=YOUTUBE-12 ](https://www.udemy.com/course/100-days-of-javascript/?couponCode=YOUTUBE-15)

Thanks guys.
AMP Pages are half dead, Time to focus on Core Web Vitals
Tags: webdev, amp, frontend
Published: 2021-08-09 07:24:55

The end has come to AMP pages and will be replaced with Core Web Vitals

If you work as a Full Stack Developer or have the ability to explore things that are involved with Search Engines and understand the user Experience and Optimize Websites for the users as well as search engines, then this post is for you

I have been Optimizing Websites for AMP Technology for a long time, where I used to work on the websites that produced news related content for the users and gained high ranking visibility in search engines, now things are getting changing and I have to focus on Speed and Performance of the websites rather than depending on AMP

##What is AMP technology?
Accelerated Mobile Pages or AMP is an open-source HTML framework developed by Google, this technology is introduced almost 5 years ago
Its purpose was to optimize websites for better performance for mobiles

**Why You should care**
Earlier Google Forced Content Publishers to Use AMP for their Websites, Once your content is AMP friendly then google showed up the pages in the top news section, If you are a News Content Publisher or a regular Blogger,
writing and publishing content alone didn't help to get a higher ranking from search engines, to reach a higher audience AMP played a good role.

On April 19, 2021, Google Officially Announced that your Content should not need to be AMP for getting visibility in the Top Stories, and a few days ago Google removed the AMP icon from the pages of Top News Sections as well as search result pages, and bring an update of Page Experience which will effect at the end of August

##problem with developers

AMP wasn't a challenging thing at all, if you work on a CMS like WordPress it was easier to make the website AMP friendly, 

What if your Website or your Client Website is not on WordPress, and that was a self-made CMS or an E-commerce Store
in these cases, we have to face the challenges with [AMP Technology](https://amp.dev)

Challenges we faced
* Custom JavaScript not allowed
* Forms didn't Work Well
* Separate subdomain for AMP pages
* Problem with third party Advertising
* AMP errors in Search Console

Now all these problems can be resolved by avoiding AMP as this Technology will no longer be able to add any value to your Websites and its the time focus on Developing websites that loads faster like this website [Dev.to](https://dev.to)

##what you should focus on

Focus on Core Web Vitals, learn more about core web vitals here [https://web.dev/vitals/](https://web.dev/vitals/) 

Google Rolling an Algorithm update this year, which will effect at the end of August

If your website doesn't load fast then you will be a loser in the market, and its the right time to test your website for Core Web Vitals Eligibility and Optimize for Better Performance

hope you like this post, let me know your thought on Improving Website Speed and Performance

In my free time, I used to blog on [Techncyber](https://www.techncyber.com) have a look
Cloud Beginner? Don't Learn DevOps: Here's Why.
Tags: devops, cloud, beginners, career
Published: 2021-08-09 07:24:23

---
title: Cloud Beginner? Don't Learn DevOps: Here's Why.
published: true
tags: devops, cloud, beginners, career
---

DevOps? What on earth is DevOps, and should you, as a cloud beginner target the DevOps role? My short answer: no. 

The DevOps role is very confused across the industry, with many companies having a vastly different idea of what a DevOps person does, making it much harder to build a learning plan around, and making it harder to prepare for interviews. 

This doesn't mean you shouldn't apply for jobs with the title DevOps, just that I don't recommend using it as a role to target.

{% youtube FU19cXr1_vI %}
Photo search app in Next JS
Tags: react, nextjs, showdev, unsplash
Published: 2021-08-09 07:23:47

Hello!

Recently I started creating a photo search app in React ([Next.js](https://nextjs.org/)) using [Unsplash API](https://unsplash.com/developers/).

### A little introduction to myself
 I am Mohd Ahmad, this is my first project after a [todo app](https://todo-app-zakiazfar.vercel.app/), my username is  @zakiazfar, it is because Mohd Ahmad is a popular name, so finding a username is hard.

## So, why Next.js instead of CRA
Because it is awesome and provides many features out of the box like,
- Zero Config
- Image Optimization
- Typescript
- File System Routing 
- Internationalisation
- API Routes
- and many more [Read Here](https://nextjs.org/)

 Here's what I got, visit the [Live URL](https://photon-three.vercel.app/) or see screenshots below.
**Suggest me how can I make it better**
{% github zakiAzfar/photon no-readme %}

### Home Page
![Photon home page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o0vapmcs48aq6hi6d4f7.png)
![Photon home page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hmcvxe3dqr5qqg7w3tw4.png)

### Home Page Dark
![Photon home page dark mode](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/26o15dbbzyuec2gm3pla.png)

### Category Page
![Photon category page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0rpnkkr3tdi94fedxg0z.png)
  
### Search Page
![Photon search page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pcp5665d297q6gayjg9f.png)
Create react app without CRA (using vite)
Tags: react, vite
Published: 2021-08-09 07:15:58

## What is vite JS
Vite (French word for "fast") is a build tool that aims to provide a faster and leaner development experience for modern web projects. 

## Why we use Vite
Today most people use CRA ```npx create-react-app``` for starting a react project. Its very time consuming because it install many unused packages to the project. 

Here, we use **Vite** for creating a react project. its less time consuming, because it only install necessary packages for the project.

When comparing to CRA, vite only take less time to start the server and updation.

So, here we start...

- Install react app using vite
```javascript
npm init @vitejs/app my-react-app
```
- Choose the variant
  Here vite asked for the app and varient. These are the technologies installed using vite js
    - vanilla
    - vanilla-ts
    - vue
    - vue-ts
    - react
    - react-ts
    - preact
    - preact-ts
    - lit-element
    - lit-element-ts
    - svelte
    - svelte-ts
Then Choose a variable and hit enter.
It create a folder named ```my-react-app``` and create the template files.

- change the directory
  ```javascript
  cd my-react-ap
  ```
- Intsall dependencies
  ```javascript
  npm install

  or

  npm i
  ```
- Run development server
  ```javascript
  npm run dev
  ```

  Now we completed the installation.
  Now you can open a editor and start the work.
Store files in cloud and On premises using Storage Gateway
Tags: aws, devops, cloudskills, cloud
Published: 2021-08-09 07:06:51

What if we want to store some of our data on premises and some on the cloud. AWS has some options for it for storage there is `Storage Gateway`. AWS Storage Gateway is a set of hybrid cloud services that gives you on-premises access to virtually unlimited cloud storage.

## Storage Gateway

It helps you to bridge the gap between on premise data and cloud storage. It simplifies and seamlessly connect your on premises storage to cloud storage.  This service includes an optimized and efficient data transfer mechanism, with bandwidth and automated resilience, and which provides a consistent experience using the AWS Console on-premises and in the AWS Cloud. It is mostly used to move backups to the cloud, using on-premises file shares backed by cloud storage, and providing low latency access to data in AWS for on-premises applications. 

### Benefits

1. Simple - It is very simple to use your applications will use your cloud environment storage same as your on premises data once its setup

1.  Efficient access - AWS Storage Gateway caches data in the local VM or gateway hardware appliance, providing low-latency disk and network performance for your most active data.

1. Scalable - Using the infinite scale of storage of S3 you can use any amount of storage you want.

1. Durable - All the data using AWS storage leverages same benefits of cloud storage for a very durable experience
Doppler: Truffle Security Recommends Doppler For Remediating Leaked Secrets
Tags: security
Published: 2021-09-08 01:54:05

---
title: Doppler: Truffle Security Recommends Doppler For Remediating Leaked Secrets
published: true
date: 2021-08-09 07:00:00 UTC
tags: security
canonical_url: https://www.doppler.com/blog/truffle-security-recommends-doppler-for-remediating-leaked-secrets
---

![](https://assets.website-files.com/5de9972f49103c9dc496402b/6110c87e6056a5db32bd5ac7_TruffleHog.jpg)

If an engineering leader asked you "How we are protecting ourselves against the accidental leakage of secrets?", what would you say?

It's not an easy question to answer, especially for those more on the Developer side of DevOps who often don't have a background or focus on security.

The answer we see emerging is a two-pronged offensive strategy:

1.  **Secure Secrets Management  
    ‍**Sensitive data such as API keys and database credentials must be stored in an encrypted, audited, and accessed controlled secrets manager.  
    ‍
2.  **Secrets Leakage Detection  
    **Continuous scanning of environments for leakage of credentials in places such as Slack channels, Git repositories, and other internal systems (e.g. task trackers and Wiki's)

While [Doppler](https://www.doppler.com/) addresses secrets management, [Truffle Security](https://trufflesecurity.com/), the company behind the [popular free and open source secrets scanner TruffleHog,](https://github.com/trufflesecurity) is on a mission to detect and prevent the accidental leakage of secrets and credentials.

Dylan Ayrey, Co-Founder of Truffle Security recently published a blog post explaining why [Doppler is their recommended for solution](https://trufflesecurity.com/blog/remediating-trufflehog-findings-with-doppler) for enterprise companies looking for an instant remediation strategy once secret leaks are detected and no secrets manager is present:

> There’s a lot of different secrets management solutions out there, but many of them aren’t very user friendly, and can be difficult to set up. One we’ve had our eye on recently is Doppler.

It's not just about mitigating the risks of secrets being leaked, as that will inadvertently happen, but what is critical, is how fast you can respond, revoke, and roll any leaked credentials. Again, from Dylan:

> The more approachable and usable your secrets management solution is, the quicker leaked keys can be rotated out, and the less exposure time they have to bad actors.

Truffle Security and Doppler are a formidable team in keeping your secrets secure, giving attackers the least possible chance of getting their hands on valid credentials before their leakage has been detected and credentials revoked.

---

[![Create your free Doppler account](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lcu1dmvld1wzmz3b0wl0.png)](https://dashboard.doppler.com/register?utm_source=dev&utm_medium=blog&utm_content=doppler-truffle-security-recommends-doppler-for-remediating-leaked-secrets-2fgn)
S3 types of storage - Hands on
Tags: aws, cloud, devops
Published: 2021-08-09 06:59:10


To check how to add files to different storage classes. 

* Open the bucket we have been working on 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jj5u8y4thc46qwa0oqu9.png)
* Upload a new file.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d71ykv5q1qtboaeuskfc.png)
* Scroll down and open properties. It will show you all the different storage classes in S3.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jwl4quej300uktjnkkba.png)![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l0rnuhpiygw1871vvmdt.png)
* Let us update the file in one zone IA.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i3h1wr3fzgb779njc95u.png)

We have uploaded the S3 object in a different storage class.

If you don't want to do this manually S3 also has an option of changing all this automatically.

* To do this open management tab in S3 bucket. Click on create lifecycle rule.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zn9g2qq6n5g6kfq40d4n.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wsyhr01r5st2mtsui2rk.png)
* Give a rule name. Select to which objects you want to apply this rule via prefix or you can select the entire bucket. I'll select the entire bucket
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r3088g5omrld9gh0nw5m.png)![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n95alkst25hsfzdb6p3n.png)
* Then we will have different lifecycle rule options. Like transitioning the current object into infrequent access after 30 days. And after 60 days added to glacier.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x6fq1hwc3tlt1lcfj36r.png)
* S3 will show you a time line summary.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zzjnqfocxb4txp9u6pjq.png)
* Click on create rule.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jreb1qrff9ardd3ozddn.png)
This way we can automate our object transitions into various tiers. 


With this we have completed our S3 series. Next I will work on databases.
The This Keyword in JavaScript
Tags: javascript, beginners, webdev, programming
Published: 2021-08-09 06:57:05

To understand this keyword let’s take an example of the word “this” in the English language with the help of the following images.

![this keyword example 1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nirdnjuu6iiygoy0d0jz.jpg)
![this keyword example 2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k1nghousx9vmqxby4ztx.jpg)

From the above two images what I’m trying to explain is that the This keyword refers to the object it belongs to. Its value depends on where it is used.

This keyword will take the value of the owner of the function and point to the owner of the function. The value of this keyword is not static, it depends on the way the function is called.

If we'll do a simple `console.log(this)` in the browser, the output will be the global object(window object) which shows that the this keyword will point to the object that called the function.

A function can be called commonly in 4 ways(there are other ways):

* As a method: In the following code example, the this keyword points to the detail object because it’s the detail object that is called the function and hence is the owner object.
```
'use strict'
const detail = {
  name: "samurai",
  year: "2020",
  calcAge: function () {
    return 2077 - this.year;
  },
};
detail.calcAge();//57
```

* As a simple function call in strict mode.

```
'use strict'
function sum() {
  let add = 2 + 2;
  console.log("sum of two numbers is" + add);
  console.log(this);
}
sum();
```

For a normal function, this keyword will point to the window object but if strict mode is used then it will be undefined.

* Arrow functions: They don't get their own this keyword. Instead, the surrounding or parent function is the one that gets pointed by the this keyword due to lexical scope.

* As an event listener: In this case, the this keyword points to 
the handler function attached to the event.

An important point we have to remember that this keyword will not point to the function we are using it in but to the object which called the function.

**Summary**
1.This refers to the owner object or the object that called the function.
2.The value of this keyword depends on where it is used.
3.If `'use strict'` is in the code then this will point to undefined else to the window object for a simple function call.