teleren/devto huggingface dataset:
Multiple functions for single eventListener
Tags: javascript, babel, webpack, mithriljs
Published: 2019-07-08 22:57:39

---
title: Multiple functions for single eventListener
published: true
description: window.eventListener, module management, and a neat hack to bind multiple functions to a single eventListener.
tags: javascript, babel, webpack, mithriljs
---

So, recently I ran into a challenge of managing my `keydown` listening functions. One of my components needs a straight connection/hook with the original `window.keyDown` event. 

At first I had something like this:

```javascript
//... other component stuff
if( firstUpdate === 0 ){
window.addEventListener("keydown", function(event){
	//... function stuff
});
```

This code will only bind the function once the module has been updated once (one from render, Mithril.js).

The problem is that as soon as this component appears later, without reloading the page, it will bind the function again, and it will either rewrite, or fire both.

so I found a better solution to this, by putting all the `window.keyDown` events into one module, and then exporting the `array` of functions that have to be fired.

```javascript
// initiating the array
let keyDown = [];
window.addEventListener( "keydown", function(event){
	keyDown.forEach( func => { func(event) } );
}

export { keyDown };
```

The function above will just run the functions in the array, and pass the event data into them. At the end of the file, i just export the array to be modified later by my components.

Example Mithril.js component:

```javascript
import { keyDown } from 'WindowEvents.js'

const Component = {
	oninit(vnode){
		this.open = false;
		this.keyDownFunction = function(e){ this.open = !this.open };
		// add function to the array
		keyDown.push ( this.keyDownFunction )
	},
	onremove(vnode){
		// remove function from the array
		keyDown.splice( keyDown.indexOf(this.keyDownFunction), 1);
	}
}
```

You can see I can remove the function from the array, to not make it fire twice when I have rendered the component again later.

It's not a good idea to use window events if you have an MVC library, just use their events. But in certain cases you have to access the window, and this was a solution for me.
Predict the future of programming
Tags: discuss, productivity, machinelearning
Published: 2019-07-08 22:44:17

Let's play a little game, I'm going to try to predict the future of code, 

I believe that that in 50 - 100 years:

1. code will not be written solely by hand, most languages will be written closely with AI intertwined, like a linter or steroids, the experience will be sort of like pair programming with somebody much smarter who knows your intent by the direction your code is heading.

2. Code will be self healing

3. Quantum computers will be the size of smart phones and people won't think twice.

4. No optical displays. From machine to brain, who needs screens.

5. Programming will primarily be achieved through dancing. (Okay it's an art, but I took that to far) 💃🕺

Was I right? what do you think about the future of programming?
Create a Azure virtual network
Tags: azure, azuresecurity
Published: 2019-07-08 22:31:45

---
title: Create a Azure virtual network
published: true
description: Create a virtual network
tags: Azure, Azure Security
---
A virtual network can be created by using the Azure portal, the Azure CLI 1.0, or Azure PowerShell.

**Using the Azure portal**

1.Sign in to the Azure portal.
2.In the upper-left corner of the screen, select Create a resource > Networking > Virtual network.
3.In Create virtual network, enter or select the information in the following table.

Setting	Action
Name: myVirtualNetwork
Address space: 10.1.0.0/16.
Subscription: Select your subscription
Resource group: Select Create new, enter myResourceGroup, and then select OK.
Location: Select a location near you.
Subnet Name: myVirtualSubnet.
Subnet Address range: 10.1.0/24.

4.Leave the rest of the defaults, and then select Create. Notice these settings. Point to the information icon to review the description of each setting:

- DDoS protection
- Service Endpoints
- Firewall

5.Select the notifications icon, which displays a highlighted number, and then review your new virtual network by selecting Go to resource.

To add two VMs to your virtual network, follow the steps detailed here.
https://docs.microsoft.com/en-us/azure/virtual-network/quick-create-portal
I'm a Dad spying on Mumsnet thanks to Google feed
Tags: devjournal
Published: 2019-07-08 22:09:10

It's not sinister I promise, just fascinating.

So I find this question pops up alot in my head. Programming is so normal, it's a massive part of my life, When I comute, I try to work out who is heading off to do some development and who is off to do something else and what must that be like?

I couldn't imagine doing anything else anymore, but I'm getting older and starting to see youngsters juniors and find myself mentoring something. It's fascinating to hear how we are the same and how we differ, my past self would have agreed with the junior I'm sure.

Today my son is coming up to 2 years old and I am coming up to 33.333333% of my estimated lifespan, it's making me such a soppy git. Anyway on to the point, Google seems to have my persona down to a T, the feed recomend this interesting perspective about a 22 DS (dear son) it's code (Mumsnet has code) (I don't know why)anyway I digress, take a little read some of the replies are spot on and you can see a non programming perspective from the OP. https://www.mumsnet.com/Talk/am_i_being_unreasonable/3632442-Aibu-to-worry-about-Coding?pg=1&order=
There's never just one way of achieving something
Tags: beginners, discuss
Published: 2019-07-08 21:07:55

---
title: There's never just one way of achieving something
published: true
description: Everything can be done multiple ways
tags: beginner, discuss
cover_image: https://thepracticaldev.s3.amazonaws.com/i/jd8tdavzuwpf1cfq6bj5.jpg
---

I just want to make a point to all the beginner's out there who may be feeling a little lost or overwhelmed. 

If you ever feel like you have to learn X, even though you prefer Y, stick with Y. Developing for the web is one of those beautiful things where anything can be achieved in a number of different ways. The most important thing is your passion. Don't lose it because you feel like you were forced to do something a certain way.

This is especially true today with the sheer number of javascript frameworks; for example, if you're finding Angular a bit overwhelming, try Vue. 

Just take a look at the new dev.to offline page. Already there are three posts explaining how to achieve it using different tools!

{% link https://dev.to/aspittel/how-to-create-the-drawing-interaction-on-dev-s-offline-page-1mbe %}

{% link https://dev.to/sendilkumarn/create-dev-s-offline-page-with-rust-and-webassembly-21gn %}

{% link https://dev.to/azure/creating-dev-s-offline-page-using-blazor-29dl %}

**You do you. Keep your passion alive.**
How to Make a Cross-platform Image Classifying App with Flutter and Fastai
Tags: deeplearning, machinelearning, android, programming
Published: 2019-07-11 14:23:17

---
title: How to Make a Cross-platform Image Classifying App with Flutter and Fastai
published: true
tags: deep-learning,machine-learning,android,programming
canonical_url: 
---

[![](https://cdn-images-1.medium.com/max/1249/1*sNNHtFJLI41fzaiG_InclA.jpeg)](https://medium.com/better-programming/how-to-make-a-cross-platform-image-classifying-app-with-flutter-and-fastai-2a6af6701535?source=rss-65edcdb268ba------2)

In this article, I’ll be explaining how to use an API to build a cross-platform mobile app that uses a neural network to classify images…

[Continue reading on Better Programming »](https://medium.com/better-programming/how-to-make-a-cross-platform-image-classifying-app-with-flutter-and-fastai-2a6af6701535?source=rss-65edcdb268ba------2)
There is no perfect system, it’s all about the tradeoffs
Tags: letterstoanewdev, perfection, systems, tradeoffs
Published: 2019-10-27 23:26:55

---
title: There is no perfect system, it’s all about the tradeoffs
published: true
tags: letters to a new dev,perfection,systems,tradeoffs
canonical_url: https://letterstoanewdeveloper.com/2019/07/08/there-is-no-perfect-system-its-all-about-the-tradeoffs/
---

Dear new developer,

I want to build perfect systems. There’s something so beautiful about a perfect bit of code that solves a problem elegantly and succinctly. Especially if it comes with a set of unit tests and great documentation.

But, every time I start to work on any real world problems, tradeoffs come into play. Let’s take the example of a simple website that is going to display some information about a business and will occasionally be updated. Some tech tradeoffs to consider when thinking about what to build:

- how prominent is the business?
- what is the brand of the business?
- how often will updates occur?
- how large does the website need to be?
- what is the business trying to achieve (a simple online presence? leads/future customers? lowering customer service request frequency? some other business goals?)
- who is going to be doing the updates? how savvy are they?
- what is the budget?
- what is the timeline?
- who is available to do the work?

Every one of these has an effect on the kind of system that you build. A website for a local jeweler that just wants to have a web presence, show store hours and highlight occasional sales is going to be built one way. A website for a newspaper that needs to be updated regularly and stand up to occasional large spikes of traffic. They both might be pretty simple sites, however. You need to find out what the goals are and that will inform the tradeoffs that you have to make.

The point is not that one site or technology is better than the other, it is to acknowledge and make sure everyone is on the same page regarding the choices. (These choices can evolve over time. I have worked on several sites recently that were implemented in perfectly good technologies for their time, but now are aged.)

This letter was inspired by [this twitter post](https://twitter.com/Der_Pesse/status/1106278405035692033) (thanks [Samuel](https://twitter.com/Der_Pesse)).

Sincerely,

Dan
Lets see your office shenanigans
Tags: webdev, discuss, office
Published: 2019-07-08 20:17:55

---
title: Lets see your office shenanigans
published: true
description: What fun shenanigans do you do at your office?
tags: webdev, discuss, office
cover_image: https://i.imgflip.com/16eqfl.jpg
---

One of ours is the good ol "hotdogged". It's when someone leaves their computer unlocked, we will open their email and send out an email from their account. It talks about how much they love hotdogs.

Then they get the hotdog stuffed toy.

We also have a company wide capture the flag nerf battle. Cali has come to phoenix multiple times and takes the flag home, so we have to go up there and get it.
Invalidating ASP.NET Forms Authentication tickets server-side
Tags: dotnet, aspnet, authentication
Published: 2019-07-08 19:55:39

---
title: Invalidating ASP.NET Forms Authentication tickets server-side
published: true
description: How can you "log out other sessions" in ASP.NET?
tags: #dotnet #aspnet #authentication
canonical_url: https://www.jitbit.com/alexblog/282-invalidating-aspnet-forms-authentication-tickets-server-side/
---

Sometimes you need to "log out other user sessions". To prevent cookie replay attacks or - a very common use case - log out other sessions when a user changes their password. ASP.NET does not have a built-in way of doing this, but there's a simple solution.

A `FormsAuthenticationTicket` object has a built-in property called `IssueDate`. So you can easily invalidate all forms-auth tickets "older than date X". In our case, it would be "older than last password change"

You can, for example, read the `IssueDate` property inside `Application_AcquireRequestState` (in "global.asax") and if the date is "too old" (i.e. older that the user's last password change) log the user out.

Here's some code for you:

```csharp
protected void Application_AcquireRequestState(object sender, EventArgs e)
{
	//check if token should be invalidated
	if (User.Identity.IsAuthenticated)
	{
		var lastPswChange = GetPswChangeDate(User.Identity.Name);
		HttpCookie authCookie = Request.Cookies[FormsAuthentication.FormsCookieName];
		FormsAuthenticationTicket authTicket = FormsAuthentication.Decrypt(authCookie.Value);

		//psw changed since this auth-token has been issued
		if(authTicket.IssueDate < lastPswChange)
		{
			//log him out
			Logout();
			Response.Redirect("~/User/Login");
			return;
		}
	}
}

private void Logout()
{
	Session.Abandon();
	Session.Clear();
	FormsAuthentication.SignOut();
}
```

You will have to implement the GetPswChangeDate method yourself.

"Password change date" is just one example. You can have and other date saved in your database next to every user and set it explicitly to whatever value you'd like.
Web Component as Good as Direct HTML for SEO?
Tags: question
Published: 2019-07-08 19:24:35

---
title: Web Component as Good as Direct HTML for SEO?
published: true
description: 
tags: question
---

I have been thinking about web components, light dom vs shadow dom, server side rendering, and SEO. The question that comes to mind is whether or not using web components as a way to encapsulate design and functionality with no asynchronous requests actually has worse SEO than having that data directly in the light dom. I.e Is either of these better or worse for SEO:

```html
<my-component title="Example"
              description="Some more content"
              button-text="Do something">
</my-component>
```

or

```html
<div class="my-component">
  <h4>Example</div>
  <p>Some more content</p>
  <button>Do something</button>
</div>
```

Assuming that the web component implementing `<my-component>` synchronously creates the same html as the second example, just inside of the shadow DOM?

Do we have any _real evidence_ for the first option being not as good for SEO as the second option?

Or has the idea been to play conservative since we can't be sure that whatever service is crawling our page will actually run JavaScript, and therefor the useful content of the page would be hidden inside of attributes instead of in semantic HTML elements?
Is your Visual Studio using hardware graphics acceleration in Visual Studio?
Tags: visualstudio
Published: 2019-07-08 19:11:32

Recent versions Visual Studio can support hardware graphics acceleration. In normally, that is automatically enabled it in your computer if your computer can support GPU. However some situation doesn't enabled it automatically when has enabled Hyper-V in your computer.

![Fig.1](https://thepracticaldev.s3.amazonaws.com/i/hf2zlttjwmowe32u47dz.png)

Fig.1: Automatically option is enable, but Visual Studio using software rendering.

If your computer can use GPU and enabled Hyper-V, you should checked off  "Automatically adjust visual experience based on client performance", and checked on "Use hardware graphics acceleration if available".

![Fig.2](https://thepracticaldev.s3.amazonaws.com/i/hmx61m5f1dl3iifh8sgc.png)

This issue is known issue in VSteam. I'm looking forward to fix it. :)

[Visual Studio developer community](https://developercommunity.visualstudio.com/content/problem/583517/use-hardware-graphics-acceleration-if-available-op.html)
What gives you a false sense of certainty/security/...?
Tags: discuss
Published: 2019-07-08 18:53:01

---
title: What gives you a false sense of certainty/security/...?
published: true
description: 
tags: discuss
cover_image: https://upload.wikimedia.org/wikipedia/commons/thumb/e/eb/Fietsstrook_Herenweg_Oudorp.jpg/2880px-Fietsstrook_Herenweg_Oudorp.jpg
---

While driving on a small family trip this Sunday, my father remarked that advisory bike lanes (see image above) give people a **false sense of safety**. Advisory bike lanes similar to normal bike lanes, but they're painted on a road that would normally be too narrow to have them. The idea is that cars in both directions use the space between the lanes, but may move into the bike lanes to pass cars going in the opposite direction.

Anything that looks like a bike lane makes a cyclist feel like it's a separate lane on the road, so they're safe. They don't think about the possibility of a car moving into their lane.

This got me thinking, are they other things, especially in the tech industry at large, that *feel* like they have a positive impact on security, productivity, company culture, .. but **don't**? I think these things can often even do damage, because we just assume their benefit is there.
The 7 Most Popular DEV Posts from the Past Week
Tags: top7
Published: 2019-07-08 18:33:04

---
title: The 7 Most Popular DEV Posts from the Past Week
published: true
description: A round up of the most-read and most-loved contributions from the community this past week.
tags: icymi
cover_image: https://thepracticaldev.s3.amazonaws.com/i/sfwcvweirpf2qka2lg2b.png
---
Every Monday we round up the previous week's top posts based on traffic, engagement, and a hint of editorial curation. The typical week starts on Monday and ends on Sunday, but don't worry, we take into account posts that are published later in the week. ❤️

#1. Inside the Machine

A straightforward and digestible book about the software/hardware relationship for anyone who's interested in looking under the hood.

{% link https://dev.to/taillogs/the-best-book-to-read-as-a-developer-1h4m %}

#2. We're Agile

Theodore is sick of the buzzword and believes Agile no longer carries the same meaning because everyone seems to have their own pre-conceived notion of what Agile is.

{% link https://dev.to/theobendixson/agile-is-literally-meaningless-22d5 %}

#3. Adopt A Tool

A list of tools to enhance your development kit. Not all are actually exclusive to JS devs.

{% link https://dev.to/jsmanifest/26-miraculous-vs-code-tools-for-javascript-developers-in-2019-50gg %}

#4. Just submit a PR!

Ever wanted to fix a typo in a DEV post? Now you can if the author uses this cool new community-built tool for managing DEV posts.

{% link https://dev.to/maxime1992/manage-your-dev-to-blog-posts-from-a-git-repo-and-use-continuous-deployment-to-auto-publish-update-them-143j %}

#5. Ultimate Guide

Jorge shares their knowledge of how Node.js works -- from describing the world before Node.js to understanding the problem with CPU intensive tasks to explaining worker threads.

{% link https://dev.to/jorge_rockr/everything-you-need-to-know-about-node-js-lnc %}

#6. Art with Code!

Ali walks us through how she created the DEV offline page. In case you haven't seen it, it's an interactive drawing board.

{% link https://dev.to/aspittel/how-to-create-the-drawing-interaction-on-dev-s-offline-page-1mbe %}

#7. Step-by-Step


Elliot is two months into a Google internship and these are their essential resources and tips for people walking a similar path.

{% link https://dev.to/elliot/my-google-technical-interview-cheat-sheet-1lbd %}

_That's it for our weekly wrap up! Keep an eye on dev.to this week for daily content and discussions...and if you miss anything, we'll be sure to recap it next Monday!_
Daily Challenge #11 - Cubic Numbers
Tags: challenge
Published: 2019-07-08 18:12:14

---
title: Daily Challenge #11 - Cubic Numbers
published: true
series: Daily Challenge
description: Our eleventh daily challenge, easy-medium difficulty. 
tags: challenge
---
Welcome to day 11 of our Daily Challenge series, hope you're having a wonderful Monday. 

In this challenge, we’ll be looking at a modified version of [g964’s “Hidden ‘Cubic’ Numbers” kata on CodeWars](https://www.codewars.com/kata/55031bba8cba40ada90011c4). 

####Primary Objective
> The first part of this challenge is to create a method that can determine whether a number is a cubic number or not. If the number has been determined to not be cubic, the output should be either `null` or the string "Unlucky."

>**Cubic numbers** are numbers with _at most three digits_, such that the sum of the cubes of their digits is the number itself. 

> For example: 153 is a cubic number, because `1^3 + 5^3 + 3^3 = 153`. 

####Secondary Objective
>If you are looking for more of a challenge, you can attempt to create a function that can find cubic numbers in a string. In the output, the numbers should be returned in the order in which they are encountered in the input string. 

>Example: 
`s = “aqdf& 0 1 xyz 153 777.777"` should return `“0 1 153 154”`
`s = “QK29 45[&erui”` should return “Unlucky” or `null.`

**Note:** In a string where three digits or more follow each other, the function should examine the numbers in sets of three digits starting from the left. In string  “001234”, the function should see 001, then 234, evaluate each, then return any cubic numbers it found (e.g. “24172410” becomes “241”, “724”, and “10”).  

Good luck, happy coding!

***
_Thank you to [CodeWars](<https://codewars.com/>), who has licensed redistribution of this challenge under the [2-Clause BSD License](<https://opensource.org/licenses/BSD-2-Clause>)!_

_Want to propose a challenge for a future post?  Email **yo+challenge@dev.to** with your suggestions!_
Waste GUIDs Even Faster with Waste Some GUIDs!
Tags: showdev, jokes, vue
Published: 2019-07-09 01:18:14

---
title: Waste GUIDs Even Faster with Waste Some GUIDs!
published: true
cover_image: https://thepracticaldev.s3.amazonaws.com/i/n1eqqpk67f9s4vuxs2yg.jpg
tags: showdev,jokes,vue.js
canonical_url: https://blog.neverendingqs.com/2019/07/08/waste-some-guids.html
---

What can be better than being able to indulge in your deepest and most base desire of [wasting GUIDs one at a time](https://wasteaguid.info/)? The ability to waste multiple GUIDs at a time of course!

With the magic of Vue.js, I have created the **ultimate** GUID wasting machine: [Waste Some GUIDs](https://wastesomeguids.neverendingqs.com/)! Go ahead, start wasting those GUIDs. You deserve it!

_Because everything is better in Vue.js._

_Many GUIDs were wasted in the making of this post._
Angular 8 - Employee Management CRUD App 
Tags: angular, javascript, tutorial, webdev
Published: 2019-07-08 17:56:35

---
title: Angular 8 - Employee Management CRUD App 
published: true
description: 
tags: #angular #javascript #tutorial #webdev
---


Just found a nice read on creating an employee management CRUD app in angular 8 - https://overflowjs.com/posts/Angular-8-Understanding-Directory-Structure-and-Creating-CRUD-App

and the code GitHub repo - https://github.com/overflowjs-com/Angular8-CRUD-employee-management

The article explains the directory structure first and then get into creating the CRUD app. It also explains the routing stuff. 

Hope it helps someone starting with it.

Happy coding
What Values You And Your Team Hold Dear?
Tags: discuss, career, productivity, agile
Published: 2019-07-08 17:50:27

---
title: What Values You And Your Team Hold Dear?
published: true
description: Software professional, development teams and organizations each have various (and sometimes) different values that they care about the most. These crucially affect how persons and teams function.
tags: discuss, career, productivity, agile
---

Software professional, development teams and organizations each have various (and sometimes) different values that they care about the most. 

These crucially affect how persons and teams function.

**What are your values in software development? What are the values of your team and organization?**

**How do they manifest?**

Cheers,
ilonacodes

---

_Ilona helps women developers to succeed in their careers without stress via her weekly newsletter. Sign up and [grab her networking cheat sheet as a bonus here](https://www.ilonacodes.com/networking-cheat-sheet)._