teleren/devto huggingface dataset:
EJS tags snippets on vscode
Tags: javascript, node, ejs, express
Published: 2020-11-17 12:40:59

Visual studio code has been the favorite text editor or IDE for web developers in recent years, and for a good reason. It could make your life as a developer way easier if you know how to leverage it's power to customize it to your needs.
I recently started using ejs as my template engine in my node/express app. I got tired of the clunky syntax if I need to inject javascript in it. I installed a couple of extensions to help me with it but I still had the same issues. I found out about custom snippets on vscode and immediately started making my own snippets for ejs. It is surprisingly easy to make. I've been writing faster ejs code ever since. I figured this could be useful to other new developers like me who just started using ejs. This is how I did it:

# **STEPS**
* Open your vscode and hit the Ctrl + Shift + p
* In the search box, type "snippets"
* Click on "Preferences: Configure User Snippets"
* Click on "New Global Snippets file"
* Name the file whatever you want (but I named mine "ejs.code-snippets") and click the enter key on your keyboard
* Clear the file, copy and paste the code below

```json
   {
	"ejs=": {
		"prefix": "ej=",
		"body": "<%= $1 %>",
		"description": "evaluates ejs code"
	},

	"ej": {
		"prefix": "ej",
		"body": "<% $1 %>",
		"description": "'Scriptlet' tag, for control-flow, no output"
	},

	"ej-": {
		"prefix": "ej-",
		"body": "<%- $1 %>",
		"description": "Outputs the unescaped value into the template"
	},

	"ejfor": {
		"prefix": "ejfor",
		"body": [
		  "<% for (let $1 of $2){ %>",
		  "	$3",
		  "<% } %>"
		],
		"description": "creates ejs for of loop"
	}
}
```

# **TEST**
Create a new file and type "ej". You should see the snippets pop up. Click anyone of the ej snippets to see the use case. 
Now you can type "ej=" and click enter and "<%=  %>" will show up.

# **WRAPUP**
I only made snippets for the most used ejs tags but feel free to add more to it or even customize it however you like.
Now you know how to create custom snippets
Bubble Sort in JavaScript
Published: 2020-11-17 12:38:36

# :vhs: Explanation of Bubble Sort :</br>
{% youtube 6Gv8vg0kcHc %}
# :computer: CODE :

```javascript
function bubbleSort(array) {
  let isSorted = false;
  let arrayLength = array.length - 1;
  let temp;
  while (!isSorted) {
    isSorted = true;
    for (let i = 0; i < arrayLength; i++) {
      if (array[i] > array[i + 1]) {
        temp = array[i + 1];
        array[i + 1] = array[i];
        array[i] = temp;
        isSorted = false;
      }      
    }
    arrayLength--;
  }
}
```

## Time Complexity:</br>
- Best: Ω(N)</br>
- Average: Θ(N²)</br>
- Worst: Ο(N²)</br>

## Space Complexity:</br>
- Ο(1)
Does our ProductHunt launch work for you?
Tags: watercooler, news, discuss, showdev
Published: 2020-11-17 12:17:29

We went live on ProductHunt today. Take a minute to check it out and share your thoughts and reviews. 💛 Thanks!

[https://www.producthunt.com/posts/offen](https://www.producthunt.com/posts/offen)
What's your 1st programming language & What you use today?
Tags: discuss, webdev, programming, codenewbie
Published: 2020-11-17 12:08:25

Hey, Dev folks 👋

What was the first programming language you learned?

And what are you using today?

Let's discuss how far we have come ....

.
.

[Follow - Om Bharatiya on Twitter](https://twitter.com/ombharatiya)
Deploy your site on Netlify
Tags: netlify, hosting, static, free
Published: 2020-11-17 12:04:57

Netlify is a hosting provider to host static websites. That means that you can only can deploy sites that has no function (HTML, CSS, JS) you can't deploy a NodeJS or a PHP Web app.
You can start for free with 100 GB Bandwidth and 300 build minutes, this is enough for hosting your personal page.

### 1. Getting started

You can simply create an account at: https://app.netlify.com with your GitHub account etc. or with your personal email address.

### 2. Deploy page

Now click the site tab and simply drop your website folder into the field.

![screen](https://i.imgur.com/m0Ch5qB.png)

### 3. Connect your domain

In the site overview click "Domain settings" then "Add domain alias" and enter your domain name for example ["Tutorialwork.dev"](https://tutorialwork.dev)

Then you must connect your domain to the Netlify page using a simple CNAME entry:

```
YOURDOMAIN.COM CNAME X.netlify.app.
```

🎉 Congratulations your site has been deployed 🎉
Turn non-algebraic, imperative arrays into a monad transformer
Tags: functional, javascript, learning
Published: 2020-11-17 11:59:24

---
title: Turn non-algebraic, imperative arrays into a monad transformer
published: true
description: 
tags: #functional #javascript #learning
//cover_image: https://direct_url_to_image.jpg
---

Turns out that although JS arrays are not algebraic, you can implement a transformer-like type `ArrayT m a = m (Array (m a))`. It behaves like a transformer & adheres to the monad laws for many `m` but there are no guarantees that this holds for all `m`:

```javascript
// ARRAYT

const arrFoldT = chain => f => init => mmx =>
  chain(mmx) (mx => {
    const go = (acc, i) =>
      i === mx.length
        ? acc
        : chain(mx[i]) (x =>
            go(f(acc) (x), i + 1))

    return go(init, 0);
  });

const arrAppendT = ({chain, of}) => mmx => mmy =>
  arrFoldT(chain)
    (acc => x =>
      chain(acc) (acc_ =>
        of(arrSnoc(of(x)) (acc_)))) (mmx) (mmy);

const arrChainT = ({chain, of}) => mmx => fmm =>
  arrFoldT(chain)
    (acc => x =>
      arrAppendT({chain, of}) (acc) (fmm(x)))
        (of([]))
          (mmx);

const arrOfT = of => x => of([of(x)]);

// OPTION

const Option = union("Option");

const None = Option("None", {});

const Some = some => Option(Some, {some});

const optChain = mx => fm =>
  match(mx, {
    None: _ => None,
    Some: ({some: x}) => fm(x)
  });

const optOf = x => Some(x);

// OPTARR

const optArrChain = arrChainT({chain: optChain, of: optOf});

const optArrOf = arrOfT(optOf);

// MAIN

const mmw = Some([Some(1), Some(2), Some(3)]),
  mmx = Some([Some(1), None, Some(3)]),
  mmy = Some([Some(1), Some(0), Some(3)]),
  mmz = None;

const main = optArrChain(mmw) (x => optArrOf(x * x)),
  main2 = optArrChain(mmx) (x => optArrOf(x * x)),
  main3 = optArrChain(mmx) (x => x === 0 ? None : optArrOf(x * x)),
  main4 = optArrChain(mmz) (x => optArrOf(x * x));

main;  // Some([Some(1), Some(4), Some(9)])
main2; // None
main3; // None
main4; // None
```
You can find a running example on [repl](https://repl.it/@scriptum/HumiliatingUnacceptableExams#index.js).
Which of these phrases would YOU just not be able to resist clicking on?  What catches your eye?
Tags: help, advice, datascience, data
Published: 2020-11-17 11:37:03

1. Seize Your Data's Full Potential!

2. Start Your Data Journey Now!

3. Be Among the Leaders

4. The Podcast for Leaders

5. Secrets Are Better When Shared...

6. Are You Using Your Data, or is Your Data Using You?

7. Own Your Data Now!

8. Be On Top of Your Data Game!

9. Be Ahead of the Rest

10. Data is Everything, and So are You

11. Boo! Scared of Data?

Above are some CTAs (Calls-to-Action) I've whipped up for my company's data podcast page!  What are your thoughts? (: Which one catches your fancy?
"Just make something" is not the best advice
Tags: discuss, codenewbie
Published: 2020-11-17 11:23:41

Recently I bombed two interviews with system design, database, and scalability questions. My conclusion? If I want to get hired at these companies, I need to go out of my way to learn these concepts. I won't "learn along the way" if I'm only making hobby side projects with less than 5 users. Do you agree?
Learning Julia (5): array comprehension
Tags: julia, array, generator, mapreduce
Published: 2020-11-17 11:08:31

We can use `[expr(i) for i in somelist]` to obtain a list in *Python*, which is so called *List comprehension*. In *Julia*, we can generate arrays in a similar way. 

```julia
a = [i*i for i in 1:10]
println("a: ", a, ", typeof(a): ", typeof(a))

```
Execution output:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/k52cwvnw7c75pw47sfmg.PNG)

We see that we get an array using the same method as in Python.
Comprehensions can also be written without the enclosing square brackets, producing an object known as a generator (`Base.Generator` type). 

```julia
g = (1/n for n=1:100)
println("g: ", g)
```
Execution output:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/dbnfs1acwxvkui1leowh.png)

I tried some more complex array comprehensions and there are some slight differences from Python (ELSE-statement can be ignored but is highly recommended):
```julia
a1 = [i*i  for i in 1:10 if i%2==0]          # IF-condition filter at the end 
a2 = [if i%2==0 i*i else 0 end  for i in 1:10 ]   # IF-ELSE statements ahead of FOR-statement; "end" keyword is required, whichis main difference with Python
a3 = [if i%2==0 i*i  end  for i in 1:10 ]    # IF-statement without ELSE-condition definition, which yields 'nothing' in the result, "end" keyword is required
a4 = [i*j for i in 1:3 for j in 4:6]  
println("a1: ", a1) 
println("a2: ", a2) 
println("a3: ", a3) 
println("a4: ", a4) 
```
Execution output:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/xqnxgzr6tceco3hw91xb.PNG)


Same as in Python, `map()` is also implemented:

```julia

# map() with anonymous functions
a5 = map(x -> x*x, 1:5)          
a6 = map(x -> x%2==0 ? x*x : 0, 1:5)
g = (n+1 for n=1:10)
a7 = map(x -> x*x, g)   # takes a generator object
println("a5: ", a5) 
println("a6: ", a6) 
println("a7: ", a7) 
println(" ")

```
Execution output:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/fzra0q471ni8z7nh0uuq.PNG)

I tried `map()` and `reduce()` using given functions:

```julia
function func(x::Int)
    if x%2 == 0
    	return x
	else 
	    return 0
	end
end

a = map(func, 2:2:9)   #  supplies a one-argument function 

println("a: ", a)    # => [2, 4, 6, 8]

function foo(x::Int, y::Int)
    return x*10+y
end

b = reduce(foo, a)
println("b: ", b) 

c = mapreduce(func,foo, 2:2:9)
println("c: ", c) 
```
Execution output:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/rizi3gu0lk6b3b71ybfo.PNG)
Best jobs remotely for today - 17 of November
Tags: ux, devops, node, ruby
Published: 2020-11-17 10:47:06

See more on our [Telegram](https://t.me/remotely_jobs)

1. [UX Developer](https://www.remotely.jobs/remote-ux-developer-job-at-web4realty) (Web4Realty)

- Advanced in HTML5/CSS3/JQuery
- Highly Experienced in JavaScript 

2. [Full-Stack Developer(Python & Javascript)](https://www.remotely.jobs/remote-full-stack-developer-python-javascript-job-at-trio) (Trio)

- 3+ years of full-time professional React + Javascript  development experience — shipping business apps that are used in production
- 3+ years of professional Python Flask and/or Django Backend development experience

3. [Node JS Engineer @ CartKit](https://www.remotely.jobs/remote-node-js-engineer-cartkit-job-at-cartkit)(CartKit)

- Babel, ES6, and up to date with latest releases
- Vue, React, Svelte, or other modern frontend frameworks.

4. [C++ (Qt) Developer](https://www.remotely.jobs/remote-c-qt-developer-job-at-x-team) (X-Team)

- Expert knowledge (3+ years) of C++ and the Qt framework
- Solid knowledge/experience with Windows IPC, Pipes, WebSockets

5. [Lead / Senior Ruby on Rails Developer](https://www.remotely.jobs/remote-lead-senior-ruby-on-rails-developer-job-at-farmgirl-flowers) (Farmgirl Flowers)

- Five or more years of professional experience working with Ruby, Rails, Rspec
- Rotating on-call duties (there is no separate DevOps team)
Safer Authentication with TypeScript
Tags: typescript, serverless, security
Published: 2020-11-17 10:30:45

I’ve been going through the [Auth0 tutorial on Cloudflare Workers](https://developers.cloudflare.com/workers/tutorials/authorize-users-with-auth0) and integrating it with my own codebase. One of the first things I noticed was how loose the use of types was in the example code. This isn’t necessarily bad, it’s a tutorial, it’s not written in TypeScript, and the audience is just wanting to get something to work. But to me authentication is mission critical, which means I want to be confident about my types.

Let’s look at one of the first functions they have you implement:

![carbon-21](https://dev-to-uploads.s3.amazonaws.com/i/5wohkysscz3zm8tdncz1.png)

This piece of code is pretty neat. One thing I like about it is that it returns a tuple. The first thing in the tuple is whether it was authorized or not, and the second thing is either the authorization information or the redirect information. What this means is that we can guard against the first item in the tuple and then use the second item.

But, unfortunately, TypeScript gets something different when it infers types for this function:

```typescript
(boolean | {authorization:any})[] | (boolean | {redirectUrl:any})[]
```

Typescript thinks that this is an Array of either (`boolean` or an `authorization` object) OR it’s an Array of either (`boolean` or a `redirect` object). That’s messy! It means we can’t be confident that the implementation is correct. It would be valid to write it with the boolean flipped around, or with the object on either side. It also means we can’t use the types of this function to be confident that we’re only using the return type in the right way. For example to use the `authorization` object we will have to use a type assertion on it:

![carbon-23](https://dev-to-uploads.s3.amazonaws.com/i/5gcy4dcxn2i2lxklf4t9.png)

We have to do this because the type of data is:

```typescript
boolean | { authorization: any } | { redirectUrl: any }
```

If someone made a mistake with the if statement here the type assertion would prevent any type errors from being raised.

We can improve the situation by encoding information about the sorts of return values the `authorize` function can have within the return type.

---

The full text of this post is available on my Substack, where I go into how we can use the right types to make this safer.

[Safer Authentication with Typescript](https://taybenlor.substack.com/p/safer-authentication-with-typescript)

Thanks for reading!
Prototype Javascript Là Gì- Tại Sao Nên Sử Dụng Prototype
Published: 2020-11-17 10:20:10

Bạn muốn nắm vững được ngôn ngữ Javascript thì bạn cần phải biết được Prototype Javascript là gì? Đây là khái niệm cơ bản của ngôn ngữ lập trình Js này Xem chi tiết tại: http://laptrinhvacongnghe.com/prototype-javascript-la-gi/
Retrofitting .gitignore
Tags: git, gitignore
Published: 2020-11-17 10:19:12

I recently embarked on a green field application and in my haste to get things up and running I forgot to add a .gitignore to my solution. Not a big issue, until you factor in that I only realised this about a dozen commits in!

Thankfully, this was a fairly simple thing to fix and for those in the same boat; here's how I went about it...

## Step 1
First of all, add your .gitignore to your solution and commit it.

## Step 2
Next, remove everything from the repo (don't panic, your files won't be deleted!) by using the bash command `git rm -r --cached .`

* `rm` is the remove command
* `-r` will allow recursive removal
* `--cached` will only remove files from the index and **won't** delete your files.
* the `.` at the end means that all files will be untracked. If you want to untrack a specific file, use the command `git rm --cached filename.txt`.

## Step 3
Once you've removed and untracked your files, you can now add your files with `git add .` then re-commit everything with your .gitignore `git commit -m "added .gitignore"` and push.

And thats it, you will now have a clean repo 👍



Cover image from [Yancy Min](https://unsplash.com/@yancymin?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText) on [Unsplash](https://unsplash.com/s/photos/git?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText)
[Discuss] Enterprise security best practices for managing vulnerabilities at scale
Tags: cheatsheet, discuss, security, enterprise
Published: 2020-11-17 09:47:12

---
title: [Discuss] Enterprise security best practices for managing vulnerabilities at scale
published: true
description: 
tags: cheatsheet, discuss, security, enterprise
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/mf3aqxig4fjwu9zomsp1.png
---

![Enterprise security best practices for managing vulnerabilities at scale](https://dev-to-uploads.s3.amazonaws.com/i/mf3aqxig4fjwu9zomsp1.png)

We have yet another excellent cheat sheet, and this time focused on enterprise security at scale.

This cheat sheet is here to help address the following concerns:

• You experience an increased clutter of security issues, wasting time for developers and security engineers.
• Developers and security engineers don’t collaborate well due to a diminished sense of trust between them.
• Prolonged exposure windows of severe vulnerabilities, due to failure to prioritize the most significant and fixable security issues.

How do you ensure effective security compliance across several teams when they experience an overwhelming number of vulnerabilities that need to be addressed?

This is what this enterprise security best practices cheatsheet is all about!

- Check out the [Enterprise Security](https://snyk.co/enterprise-security-cheatsheet) blog post
- Download the [Enterprise Security best practices](https://snyk.co/enterprise-security-cheat-sheet-download) cheat sheet

And feel free to add your suggestions and comments below.
Diff suppressed as the expected and actual results have an equivalent serialization
Tags: qunit, testing, javascript
Published: 2020-11-17 09:41:45

Assume following qunit test:

```js
assert.equal({ foo: 'bar' }, { foo: 'bar' });
```

Those two object seem the same. So the assertion should pass. Right?

![Failing Qunit test](https://dev-to-uploads.s3.amazonaws.com/i/13tn8zhd74y984pd5tia.png)

Turns out this is not how it works. And even the follow up cryptic message does not really help:

> Diff suppressed as the expected and actual results have an equivalent serialization.

Well if we look into the documentation of [qunit.assert](https://api.qunitjs.com/assert/equal/) we will find that:

> The equal assertion uses the simple comparison operator (==) to compare the actual and expected arguments. When they are equal, the assertion passes; otherwise, it fails.

And the double equal symbol uses [referential equality](https://dmitripavlutin.com/how-to-compare-objects-in-javascript/) and since in the example above (and in most of my tests in general) I am **not** comparing **the same object**, but rather two objects of **the same shape and values**, it can never return `true`.

## The solution

The solution to this is really simple, just use [deepEqual](https://api.qunitjs.com/assert/deepEqual/):

```js
assert.deepEqual({ foo: 'bar' }, { foo: 'bar' });
```

Which gives me: 

![Happy qunit test](https://dev-to-uploads.s3.amazonaws.com/i/jd2yipgda3o4s7ffadj3.png)

-----

Photo by Andrea Piacquadio from Pexels
Top News In This Week.
Tags: javascript, devops, react, webdev
Published: 2020-11-17 09:38:58

51% of devs say they’re dealing with 100x more code than
 10 years Ago...
New research highlights the increasing demands being placed on developers—in volume, variety, and velocity.

The research, sponsored by Sourcegraph, is probably unsurprising for anyone working in the development industry. For others, it shows the uphill battle faced by developers.

500 developers across North America were surveyed by Dimensional Research for the report. All participants are responsible for software development at companies with more than 200 developers.

The main takeaway from the research is that 51 percent of the developers report having to deal with 100 times more code than a decade ago.


Developers are also being asked to deal with a greater variety of “development dimensions” than ever before. More than 60 percent report a significant increase in dimensions including architecture, supported devices, use of open source, number of platforms, and more.


Along with the increased volume and variety of code, developers are being asked to provide it faster than ever. 92 percent report that pressure to release code more rapidly has increased over the past decade.


Generally speaking, most developers (77%) say that development is “dramatically more complex” than it was 10 years.
Tester Leader Là Gì- Làm Sao Để Trở Thành Một Tester Leader
Published: 2020-11-17 09:37:28

Tester Leader là gì, làm sao để trở thành trưởng nhóm kiểm thử? Cùng theo dõi thông tin mà ITNavi chia sẻ để hiểu rõ hơn về vấn đề trên nhé! Xem chi tiết tại: https://blog.itnavi.com.vn/tester-leader-la-gi-nhiem-vu-chinh-cua-mot-tester-leader/
𝗛𝗼𝘄 𝘁𝗼 𝗮𝗰𝗰𝗲𝗽𝘁 𝗺𝘂𝗹𝘁𝗶𝗽𝗹𝗲 𝗟𝗶𝗻𝗸𝗲𝗱𝗶𝗻 𝗜𝗻𝘃𝗶𝘁𝗮𝘁𝗶𝗼𝗻𝘀 at once❓
Tags: lifehacks, linkedin, programming, happyhacking
Published: 2020-11-17 09:37:00

Visit Linkedin

open the `mynetwork/invitation-manager/` page and past this code in the console.

```
let buttons = document.getElementsByClassName('artdeco-button--secondary');

for(i = 0; i < buttons.length; i++){
buttons[i].click();
}
```
And that's how we can accept multiple Invitations.
You can use the same Idea to send multiple invites at once. I will suggest a delay between actions to be safe from algorithms.

Have a nice day fellows 😃
Faster dev server with(out) xDebug 
Tags: docker, php
Published: 2020-11-17 09:33:28

It has been said before, to make xDebug faster, just disable it.
But one still needs xDebug for how helpful it is!
Well, there is a good solution which is to only enable xDebug when we intend to debug the request.

The idea is to create two php containers (`php` and `php_xdebug`) and enable xDebug on only one of these two containers.
Then we can instruct `apache` to use the `php_xdebug` container only when a certain cookie is set.

`php` container
![php container info](https://i.imgur.com/AYQnxe7.png)

`php_xdebug` container
![php_xdebug container info](https://i.imgur.com/Q6JU7eg.png)

`apache` config
``` ini
<If "%{HTTP_COOKIE} =~ /XDEBUG_SESSION=PHPSTORM/">
  SetHandler "proxy:fcgi://php_xdebug:9000"
</If>
<Else>
  SetHandler "proxy:fcgi://php:9000"
</Else>
```
So in this case, we only use php_xdebug when the `XDEBUG_SESSION` cookie is set to `PHPSTORM`.
The `PHPSTORM` value itself can be changed in the env file and in the xDebug helper browser extension.

The rest is very simple, we just need to configure xDebug to always start remote debugging when it's invoked.
The `profiler` and `log` output will be sent to a `/tmp` folder inside the server root.

``` ini
zend_extension=xdebug.so
[xdebug]
xdebug.remote_autostart = 1
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_connect_back=1
xdebug.profiler_enable_trigger = 1
xdebug.profiler_output_dir = /var/www/html/tmp
xdebug.idekey=${XDEBUG_COOKIE_VALUE}
xdebug.remote_log=/var/www/html/tmp/xdebug.log
```

You can find the docker-compose file in this github repo
https://github.com/unlocomqx/conditional-xdebug-fpm-docker

After cloning the repo, you can rename the file `sample.env` to `.env` and change `DOCUMENT_ROOT`, `MYSQL_DATA_DIR` and `XDEBUG_COOKIE_VALUE` if necessary.

This solution was totally inspired by this blog post https://jtreminio.com/blog/developing-at-full-speed-with-xdebug/
Framework Là Gì- Top 5 Framework Nổi Bật Nhất Hiện Nay
Published: 2020-11-17 09:24:14

Framework là gì- Đây là một khái niệm hết sức quen thuộc trong giới lập trình, đặc biệt là các Framework Java.Vậy chúng có những đặc điểm gì? Xem chi tiết tại: https://blog.itnavi.com.vn/framework-java/
❎❓Quiz: Web Performance #17
Tags: challenge, webperf, webdev, quiz
Published: 2020-11-17 09:20:32

Quiz time: What is the TTFB?

- Time to First Bit
- Time to First Byte
- Time to First Base64
- Time to First Browser

---
<center>[Answer the question](https://marcradziwill.com/web-performance-quiz/what-is-the-ttfb/)</center>
---
Exclusive demo Gravitee.io 3.4
Published: 2020-11-17 09:16:20

Join Gravitee.io CTO David Brassely and team for an exclusive insight into the new features of our API Platform. 

We will be showing you our new API Policy Studio, the biometric (passwordless) login features introduced in Access Management, and much more.

Register Now: https://bit.ly/2H6J4rl