teleren/devto huggingface dataset:
Weak Validate an Email Address Using Node to Check if an MX Record Exists
Tags: node
Published: 2020-02-17 06:55:18

For the web application I'm working on, having a valid email address for each user is important because the application allows users to contact each other, but retain some privacy, by using double-blind emails. To ensure the user has submitted a working email address, the application sends a verification code to the address entered at sign-up. However, to avoid unnecessary bounces I wanted a way to filter out obviously fake addresses that still passed validation using regular expressions.

I learned that Node includes a DNS module that can be used to look up a host and return an MX record, if it exists. Therefore, if the DNS module fails to return an MX record, the email address entered by the user is not valid. 

The code below uses the dnsPromises API to check if an MX record exists for an arbitrary email address. To use, just pass the mxExists function an email address and it will return a promise. If the domain doesn't exist or no MX record is found, the promise will reject or resolve as false. If an MX record is found, the promise will resolve as true. Individual mailboxes are not validated, so bounces are still possible. The intent of the weak validation is to catch typos and obvious fake addresses to reduce the bounce rate.

```javascript
const dnsPromises = require("dns").promises;

const mxExists = email => {
  return new Promise ((res, rej) => {
    const hostname = email.split("@")[1];

    try {
      dnsPromises.resolveMx(hostname).then(addresses => {
        if (addresses && addresses.length > 0) {
          addresses[0].exchange ? res(true) : res(false);
        }
      })
      .catch(err => {
        // TODO: Deal with the error
        console.log("mx-check.js - resolveMx ERROR:\n" + err);
        res(false);        
      });
    } catch (err) {
      // TODO: Deal with the error
      console.log("mx-check.js ERROR:\n" + err);
      rej(false);
    }
  });
}

module.exports = {
  mxExists
}
```
Is there anything I should know about cookies as both webdev and end-user?
Tags: webdev, security, discuss, help
Published: 2020-02-17 06:28:45

So, what do I need help for? -- this -- [auth0-spa-js](https://auth0.com/docs/libraries/auth0-spa-js) with backend -- in [aloud-comments](https://github.com/patarapolw/aloud). I am not sure if I could use cookies without by own backend, such as Now.sh or Netlify?

I also know that cookies can be edited on user-side as well, which is made easy by [js-cookie](https://github.com/js-cookie/js-cookie).

- Not sure if even HTTPS cookies are secure, but it should be more secure than localStorage.
- Can it be intercepted and edited, just like HTTP?
- Cookies have expiry date. I love that.

About localStorage

- Can I use localStorage to save tokens for SPA? Will it be any better if I use cookies?

As an end-user...

- Should I block cookie requests on most website? What will happen if I block cookies on all website? And vice versa?
Frontend Collective - Week #2
Tags: weeklyui, webdev, javascript, css
Published: 2020-02-17 06:27:06

It's the curated collection of awesome work that is done by awesome people and community.

Highlights 

- Neumorphism.io
- Glitch Art Generator
- Dot Matrix
- Guide Chimp
- Learn CSS Positioning
- Avatar Library

------------ 

![Neumorphism Generator](https://dev-to-uploads.s3.amazonaws.com/i/jlk3ibl4ir2kcgpo3b2l.png)

### **Neumorphism.io**
It's a tool for generating Soft - UI CSS code

Visit the site **[here](https://neumorphism.io/#55b9f3)**

------------

![Glitch Art Generator](https://dev-to-uploads.s3.amazonaws.com/i/rrdfug9nhnc96kjm1gv8.jpg)

### **Glitch Art Generator**
This is the online tool to create compelling glitch effects for your projects.

Visit the site **[here](https://glitchart.io/)**

------------

![Dot Matrix](https://dev-to-uploads.s3.amazonaws.com/i/mqnn2abfpk42qvy0j401.png)

### **Dot Matrix**
It generates a dot matrix screen with animated movements based on mouse/touch events.

Visit the site **[here](https://mmason33.github.io/dot-matrix/)**

------------

![Guide Chimp Gif](https://dev-to-uploads.s3.amazonaws.com/i/x61tmuholldqyok7lcoh.gif)

### **Guide Chimp**
It creates an interactive guided product tours in minutes with the most non-technical friendly, lightweight and extendable library. It also delivers the perfect product experience, improves digital product adoption, boosts the adoption of new features and simplifies user onboarding with step by step interactive walkthroughs.

Visit the site **[here](https://github.com/Labs64/GuideChimp)**

------------

![Learn CSS Positioning Interactive Demo](https://dev-to-uploads.s3.amazonaws.com/i/q83lukzyliz6y8g0czxy.png)

### **Learn CSS Positioning**
An interactive article to help you learn how to position elements.

Visit the site **[here](https://ishadeed.com/article/learn-css-positioning/)**

------------

![Avatar Library](https://dev-to-uploads.s3.amazonaws.com/i/n61v1melrkfr8lj9g79f.png)

### **Avatar Library**
It creates a unique avatar illustration using a free Sketch App or Figma library. Avatar Library is a Sketch & Figma library to create character illustrations. You can use it for your Landing Page, Mobile App, Website, Webflow Template, Presentation or just for fun!

Visit the site **[here](https://drawer.design/products/avatar-library/)**

------------

If you have found this blog very helpful then please feel free to share your thoughts and opinions and leave me a comment if you have any problems or questions.

Till then,
**Keep on Hacking, Cheers**
How do you find your favorite emojis? 🦄
Tags: discuss, watercooler, emoji
Published: 2020-02-17 06:17:05

I know it is possible to add Emoji to Dev.to and [GitHub commits](https://gitmoji.carloscuesta.me/), but how can you be so artistic?

So, I created this website <https://learn-unicode.now.sh/?q=%2Btype%3Aemoji%20-circle>, which can also find [minuscule 'f'](https://dev.to/calin92540842/minuscule-f-markup-in-html-20d9) as well, even if it isn't strictly Emoji. (Type in 'function'.)

The website also sorted by the frequencies of Emoji [scraped from Reddit API](https://github.com/patarapolw/redditjs/blob/master/src/index.ts). (I failed at trying to scrape Twitter via API.)

I have also recently found this, but I think mine is gooder.

{% post yamadashy/emoji-cheatsheet-of-githubslackdiscordqiita-4d2f %}

There is also [kaomoji](http://kaomoji.ru/en/). I might do a project on that later...
"work smarter not harder" requires us to say no
Tags: leadershipdevelopment, agile, burnout, techdebt
Published: 2020-02-17 05:57:49

*"Our web app has to support a browser. We know it usually takes a month, but can you do it in two weeks."* This was the paraphrased message I received after I returned from a much-needed vacation. I had dealt with my fair share of stressful situations before as an ex-fast food worker(shoutout to all service industry workers!) This request had my team and I working long nights and weekends however causing burnout and unnecessary stress while also creating a lot of tech debt. Even worse, this caused my organization to miss our financial goals for the year.

I blamed myself for this unfortunate outcome. After sitting with my thoughts and confiding with my mentor, my boss , and a few close colleagues, I realized I was asking the wrong questions and looking at this situation from the wrong angle. 

Newer devs such as myself are not taught the business side of tech in college. Nor are we taught to hone our emotional or communication skills. These are skills that I have had to learn on the job (quite painfully I might add). From this situation, I learned how to manage unattainable requirements and avoid disaster. These are the steps I use now when I get new requirements in project,and maybe they will be helpful to other young devs


1) I ask any and every question about what is required. I do not take anything for granted , and I ask any question no matter how silly or simple it might be. There are sometimes silly questions, but I would rather ask a silly question then work nights and weekends.

2) I ask about the feature's value. "What is the value of this feature to the client and how does it further our team's/org's goals as well?" "Why is this valuable?" 

3) Saying "no" outright has not worked out in my favor in the past which is why this is the last point. Asking questions and learning as much information I can, helps lead my team and me to logical and concrete steps as to how feasible a feature is and what the ramifications to adding it to our sprint are.


Thanks for reading my first blog post ever! My goal for blogging is to mainly keep track of what I am learning in my, measure my growth, and connect with other devs/product owners/designers/teach people in the community. Feel free to send feedback, comment, or add anything that contributes to this topic.
Callback function() in JavaScript
Tags: javascript, webdev, beginners, career
Published: 2020-02-17 05:40:39

A callback is A reference to executable code, or a piece of executable code, that is passed as an argument to other code or function that is to be executed after another function has finished executing.



In computer programming, a callback, also known as a "call-after" function, is any executable code that is passed as an argument to other code that is expected to call back (execute) the argument at a given time. This execution may be immediate as in a synchronous callback, or it might happen at a later time as in an asynchronous callback. Programming languages support callbacks in different ways, often implementing them with subroutines, lambda expressions, blocks, or function pointers.

Let take an example of Callback function() examples.



{% runkit %}
function addition(a,b) {
console.log("Addition of a+b=", a + b);
}
function numberAddtion(callback) {
    
    a = 10;
    b=20;
    callback(a,b);
}
numberAddtion(addition); //output 30
{%endrunkit%}
Nikema's 100 Days of Code
Tags: 100daysofcode
Published: 2020-02-17 05:24:47

## [Day 1](https://github.com/prophen/100-days-of-code/blob/master/Day-1.md)

I've had more than a couple starts and stops to this challenge. I am determined to get to day 100 this round. 

I've got my accountability partner, Dani on deck...

{% twitter 1229195430455468032 %}
{% twitter 1229195432061886465 %}

...and I'm already coding. I was coding on day zero 😃

{% twitter 1229185346178441216  %}

****

Follow along with me on GitHub

{% github prophen/100-days-of-code no-readme %}


<p style='text-align:center'> <a href="https://www.buymeacoffee.com/nikema" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" width="150px"></a></center></p>
Looking for contributors with python 3 tensorflow experience for a cool chatbot!
Published: 2020-02-17 05:19:01

## What the project is
**Facebook-Messenger-bot** is a chatbot you can train to talk like you! Check the repo [here](https://github.com/adeshpande3/Facebook-Messenger-Bot)!

## What we need help with

We're looking for someone experienced with **python 3** `tensorflow` and the `seq2seq` model. We need to upgrade our codebase to `python3` but since we used `legacy_seq2seq` in our **python 2** code, we're having trouble replacing it with a **python 3** equivalent. More details on the issue [here!](https://github.com/adeshpande3/Facebook-Messenger-Bot/issues/55)
CICD working!
Tags: devops, angular, github, git
Published: 2020-02-17 05:04:04

I've done it!  I was able to get it done earlier this week, but I wasn't able to write about it until now.  I ended up using some information from this post (https://dev.to/thisdotmedia/continuously-integrating-angular-with-azure-devops-2k9l) and I mixed in the angular cli deploy gh-pages addin (https://www.npmjs.com/package/angular-cli-ghpages).

Now when I push to master in my devops git repo, a pipeline will kick off, run the build, lint it, test it, publish the tests and if everything succeeds, push up to my github pages.  

Here's how I got to where I'm at:
1) Upload newly created angular app to devops git repo.
2) Create a branch for the pipeline work
3) In that branch in devops, go to pipelines and add the following YAML file:

```yaml
# Node.js with Angular
# Build a Node.js project that uses Angular.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript
variables:
  buildConfiguration: 'Release'

trigger:
- master

pool:
  vmImage: 'ubuntu-latest'

steps:
- task: NodeTool@0
  inputs:
    versionSpec: '10.x'
  displayName: 'Setup Environment'

- script: |
    npm install -g @angular/cli
    npm install
  displayName: 'npm install'

- script: ng lint
  displayName: 'Code Analysis'

- script: ng test --watch=false --codeCoverage=true
  displayName: 'Tests'

- task: PublishTestResults@2
  condition: succeededOrFailed()
  inputs:
    testResultsFormat: 'JUnit'
    testResultsFiles: '**/TESTS-*.xml'
  displayName: "Publish Test Results"

- task: PublishCodeCoverageResults@1
  condition: succeededOrFailed()
  inputs:
    codeCoverageTool: 'Cobertura'
    summaryFileLocation: '$(Build.SourceDirectory)/coverage/$(Angular_Project_Name)/cobertura-coverage.xml'
  displayName: 'Publish Code Coverage Results'

- script: ng deploy --repo=https://$(Github_Username):$(GITHUB_TOKEN)@github.com/$(Github_Username)/$(Github_Repo_Location)
  condition: succeeded()
  displayName: 'Build Production and Deploy to github.io'

- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: 'dist/$(Angular_Project_Name)'
    ArtifactName: 'web-app'
    publishLocation: 'Container'
  displayName: 'Publish Artifacts'
```
I really like that devops allows me to store secure variables!

I really didn't need that publish artifacts at the end, but I figured I'd try it out. I do have one bug currently, the linting results publish can't find the output file to publish at the moment, so there is probably something wrong with my pathing. 

Once I am able to finish the linting issue, it's on to the fun: Making the website work!
Collab Lab - That's a Wrap
Tags: collablab
Published: 2020-02-17 05:02:09

The last few weeks of The Collab Lab were super busy for me and I fell off of my documenting the journey. TLDR; It was a great experience that gave me a confidence boost as a developer. I know I can work on a distributed software engineering team because I've done it!

{% twitter 1226549534941036545 %}

I took the lead for the design of our app. I think it turned out pretty ok. 

![screenshot of smart shopping list app](https://dev-to-uploads.s3.amazonaws.com/i/5xe90skreym1wqcdpk25.png)

Taking the lead on this actually meant I did it on my own. The rest of the team was working on the last pieces of logic to make the smart shopping list work.  

You can see the deployed app here - https://tcl-3-smart-shopping-list.netlify.com/ 

{% github the-collab-lab/tcl-3-smart-shopping-list %}

I didn't make it through the last retro without crying. I have a lot going on in my life right now and not many of those things are putting much-needed money in my pocket. It always touches me to hear that people see how hard I'm working and appreciate my contributions.

{% youtube hIsQCaDj8I4 %}

The greatest thing I'm taking away from this experience is the sense of what kinds of work feels the most energizing and enjoyable for me.

I got to practice a lot of written communication in PRs, wikis, and commit messages. Turns out I love that and it's a needed skill as a professional developer.

I also really enjoy working on the UI and UX. It feels good to make something *look* good. It's another kind of problem-solving and the problem-solving aspect of programming is an intrinsic motivation for me to do it. I have a lot of fun with it.

{% twitter 1201551660029366272 %} 

👆🏾 Past Nikema was not so sure about React and web development.

I came in not feeling like I knew I wanted to work in software development at all. I know now, I love this stuff. I guess this community is stuck with me.

<a href="https://www.buymeacoffee.com/nikema" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" width="150px"></a>
Python: Logging Overview
Tags: python, oop, beginners, logging
Published: 2020-02-13 11:21:59

The first question popping up with every developer noob is my print function is working perfectly fine, and why the hell do I need a _log file_?

Well your 50 line code's debugging can be easily managed by the simplest of all functions - print() but when it comes to debugging those 1000 lines of code-work, most of which is a result of many sleepless night efforts, surely you need something more than print() to suffice your needs. **Drum-rolls**: enter **Log Files**. 

Python has an inbuilt logging module that fulfills all the logging needs of any program.

##First Things First:##
There are basically 5 log levels in Python associated with numeric values which are incremented in multiples of 10.
Critical(50) - Highest Priority which needs immediate attention.
Error(40)    - Minute errors which can be resolved and program can re-run.
Warning(30)  - Note of caution like space issues.
Info(20)     - Confirmation that something is working as expected.
Debug(10)    - Detailed information, mostly used while debugging any issue.

##logging.basicConfig():##
The function takes a keyword of arguments as parameters like filename, level,format.
The default level in logging is Warning or 30, however that can be changed as passing the level as:
level=logging.DEBUG or level=logging.INFO 
The format would specify what format of message do we want to store in the logfile.

The Default logger is the root logger.

However when a new file is imported and it has its own logger, the root logger of the parent file gets replaced by that of the child logger and all the logging info for the parent file gets lost.

This problem can be resolved by creating separate loggers for each file and then configuring them according to our needs.

##Creating a Logger:##
logger = logging.getLogger(__name__)

After creating a logger, we need to create a filehandler.
fileHandler = logging.FileHandler('employee.log')

logger.addHandler(fileHandler)

sample formatting can be added to the filehandler and can be set by passing on the formatter parameter to fileHandler.setFormatter()

There are also handlers like StreamHandler,NullHandler etc.
Learning Markdown, Finally
Tags: todayilearned, markdown
Published: 2020-02-17 04:27:52

I decided to make time to learn markdown, since too much time has passed since it first crossed my mind to do so.

[Here](https://www.markdowntutorial.com/) is where I am picking it up. I hope it is as helpful to you as it is to me.

Here's to learning new things!

P.S.

Right after creating this post, I found the DEV Community's [Editor Guide](https://dev.to/p/editor_guide), which is great.
One thing you must keep in mind when refactoring code.
Tags: javascript, webdev, beginners, tutorial
Published: 2020-02-17 04:24:30

Recently, I found myself building a JavaScript-based animation within a front-end project I was working on. Here's a simplified version of the code:
```js
const animate = () => {
  // some sort of DOM update here
  requestAnimationFrame(animate);
}

animate();
```
After a short while, I decided I wanted an FPS counter -- just something presentational that shows inside the browser. My first thought was to write a similar function, but for updating an FPS value shown on the page:
```js
const ONE_SECOND = 1000;
let fps = 0;

const getFPS = startTime => {
  window.requestAnimationFrame(() => {
    const currentTime = performance.now();
    if (currentTime - startTime < ONE_SECOND) {
      fps++;
      getFPS(startTime);
    } else {
      fpsDisplay.innerText = `${fps} FPS`;
      fps = 0;
      getFPS(currentTime);
    }
  });
};

getFPS(performance.now());
```

There is nothing seriously wrong with this approach. It updates properly and produces the correct value.

However, I quickly realised this solution was far from ideal: a second use of `requestAnimationFrame` would make no sense if my project had animation-heavy code.

In fact, it was superfluous given that `animate()` already included a `requestAnimationFrame` call. I could achieve the same functionality by refactoring my `getFPS()` function so that it shared the same call:
```js
const ONE_SECOND = 1000;
let fps = 0;

const animate = () => {
  // some sort of DOM update here
  fps++;
  requestAnimationFrame(animate);
}

const  getFPS = () => {
  setInterval(() => {
    fpsDisplay.innerText = `${fps} FPS`;
    fps = 0;
  }, ONE_SECOND);
};

animate();
getFPS();
```
This is what's called **colocating**. The principle of colocation is simple: *group like code with one another*.

A good analogy for the above example is measuring the speed of a car. It would be an absurd waste of time and money to purchase a second car, match its speed with the first, and use a radar gun on the second. In comparison, the colocated code would be like installing a speedometer in the first car.

Colocating, in addition to decreasing code length and increasing readability, boasts significant computational savings. By refactoring the bulk of `getFPS()` inside of `animate()`, only a single instance of `requestAnimationFrame()` was needed.

There are a myriad of benefits to colocation, including but not limited to easier readability and maintainability, better predictability, improved performance, and closer adherence to DRY principles.
Handle async operations in parallel in Nodejs
Published: 2020-02-17 04:18:35

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/87gprqqz4jqvv3s15qxz.jpg)

This is the best example to handle async operations parallel in Nodejs. In this example, we have used the promises primitive datatype of javascript to parallel call while async operation. If you execute this script then output come after 3 seconds. 

if check-in script apifirst take 2 seconds in execution and apiSecond take 3 seconds if you use the computer language like synchronized operation process to execute then it takes 2 + 3 = 5 seconds to execute output but in the case of NodeJs it only takes 3 seconds.
Menampilkan file dan folder yang tersembunyi di Windows
Tags: windows, cmd, batch
Published: 2020-02-17 04:01:07

---
title: Menampilkan file dan folder yang tersembunyi di Windows
published: true
description: Menampilkan file-file dan folder-folder yang tersembunyi di Windows
tags: windows, cmd, batch
series: Lifehack
---

Coba jalankan ini di Command Prompt:

```bash
attrib -s -h /s /d
```
Your experiences debugging on serverless/micro-service architectures?
Tags: discuss
Published: 2020-02-17 03:55:29

I've written about this topic in my most recent article.

{% link https://dev.to/rolfstreefkerk/serverless-tracing-with-aws-x-ray-3119 %}

Now I'm keen to know your experience with debugging on AWS Serverless or micro service architectures. The best practices, dos and don'ts, tooling you have used etc.
Auto-magically log all output of your script to syslog
Tags: bash, linux, logging, syslog
Published: 2020-02-17 03:43:41

Not long ago I stumbled upon this solution to automatically send all output of a `bash` script to `syslog`.

All you have to do is add the command at the beginning of the script and all following output will be written to `syslog` along with the script name.

The solution uses the [logger](https://linux.die.net/man/1/logger) interface to `syslog`.

The line is

```
exec 1> >(logger -s -t $(basename $0)) 2>&1
```

For example, say we have this executable `bash` script and we name it `autolog.sh`:

```bash
#/bin/env bash

exec 1> >(logger -s -t $(basename $0)) 2>&1

echo 'Hello World'
```

If we execute it and then see `syslog` we get:

```bash
$ ./autolog.sh
<13>Feb 16 22:30:30 autolog.sh: Hello World

# tail /var/log/syslog
...
Feb nn nn:nn:nn ip-nnn-nn-n-nnn autolog.sh: Hello World
```

I took this solution from here: `http://urbanautomaton.com/blog/2014/09/09/redirecting-bash-script-output-to-syslog/`, but the URL is currently broken.

<hr />

Do you have any tips for logging on `bash`? Let me know!