teleren/devto huggingface dataset:
Kotlin - "Lazy" initialization
Tags: kotlin, lazy, tutorial
Published: 2020-09-18 12:05:59

One of the most interesting features of the Kotlin syntax is Lazy initialization but it is also a concept that can be a little tricky to understand. The concept of Lazy initialization was designed to prevent the unnecessary initialization of objects. Lets imagine that you have a are running a program and you want to print out a string. That’s pretty easy to do right?
![1-SYjvlFCUlNVrK7tctOMQWA](https://dev-to-uploads.s3.amazonaws.com/i/gopj8bs289id2pjcidqx.png)

But what if getting this string was from an expensive operation? Well this is where we can use Lazy initialization.![1-4pCZ2RVPLTENyCcJmj9eZA](https://dev-to-uploads.s3.amazonaws.com/i/5h9ps6oiu00ffnat7haj.png)

If we run this it looks very similar but as we dig further something very interesting begins to happen. In order to illustrate this we will print the name multiple times and also add another print statement withing the lazy block.
![1-WnS0CweLt-bAhdab5rxNkA](https://dev-to-uploads.s3.amazonaws.com/i/bza35u22jncn7o4ahihe.png)

Once we run this code we can see that “processing” was printed once while the name was printed multiple times. Why is this? Well, the reason is that when the first println(name) function was called, Kotlin evaluated, executed the code in the Lazy block and saved the computed value. This computed value was then returned each subsequent time without having to evaluate and execute the code in the lazy block again.

Now, let imagine that we are performing some sort of network call or long running operation. To simulate this we will add a sleep function in our code.
![Screen Shot 2020-09-18 at 5.02.41 AM](https://dev-to-uploads.s3.amazonaws.com/i/sdw1ponh83zo4be1mzpp.png)
![Screen Shot 2020-09-18 at 5.02.56 AM](https://dev-to-uploads.s3.amazonaws.com/i/q8roqd1fg6n8vx2ya7zs.png)

As you can see, “processing…” was printed to the console and a few seconds later “Paul” was printed out three times almost simultaneously. This is because when the first println(name) function was called, the lazy block was evaluated and executed, the computed value was then saved by Kotlin and when the second and third println(name) function was called the computed value of the name variable only needed to be returned. With Lazy initialization, the value gets computed ONLY upon first access.
Express.js Async + Sync Global Exception Handler
Tags: webdev, javascript, node
Published: 2020-09-18 12:05:19

Hi everyone, hope you all are doing ok in the COVID-19 world.
Recently I've been playing around with Express, and I needed to setup an error handler for my project.

I have been searching for a way to catch all exceptions in my project, something that will work both for sync and async routes.

To my surprise, I couldn't find an easy solution for it, so I had to come up with something of my own.

Let's walk it through: 

first define your error handler
errorHandler.js:

```javascript
const handleErrors = (err, req, res, next) => {
	if (res.headersSent) return next(err);

	// more handle error logic should be inserted here.

	res.status(500).json({
		msg: "Server Error",
	});

module.exports = handleErrors;
```

register your error handler (after all your routes)
server.js:
```javascript
// Middlewares
app.use(cors());
app.use(express.json());
app.use(fileupload());
app.use(cookies());

// Routes
app.use("/", routes);
app.use(handleErrors); <------
```
Now we are going to do some javascript magic, we are going to leverage "express-async-handler" and write some of our own magic, to make the global exception handler work.

now we are going to hook express.Router which will return a new router that will have error handling for both async/sync routes

hookRouter.js
```javascript
const express = require("express");
const originalRouterFunc = express.Router;
const asyncHandler = require("express-async-handler");

export function hookRouter() {
	function hookAllRouteMethods(router) {
		const methods = ["get", "post", "put", "delete", "options", "head", "all", "use"]; // all router methods
		methods.forEach(method => {
			const originalRouterFunc = router[method];
			const hookedRouterMethod = async function (path, ...routeHandlers) {
				routeHandlers = routeHandlers.map(f =>
					asyncHandler(function (req, res, next) { // async error handler
						// sync error handler start
						try {
							return f(req, res, next); // original route handler
						} catch (e) {
							console.log("hahah I caught you =)");
							next(e, req, res); // pass exception to our error handler.
						}
						// sync error handler end
					})
				);
				originalRouterFunc.apply(router, [path, ...routeHandlers]);
			};
			router[method] = hookedRouterMethod;
		});
	}

	function hookRouterCreation() {
		express.Router = function () {
			const router = originalRouterFunc.apply(this, arguments);
			hookAllRouteMethods(router);
			return router;
		};
	}
	hookRouterCreation();
}
```

next, we just have to hook our router at the top of server.js (or before you use routes):

```javascript
const { hookRouter } = require("./hookRouter");
hookRouter();
```
That's it! now everytime you will use express.Router() it will have your error handler !

Hope this was helpful for you, Also this solution is still not 'battle tested' so I would like to hear what you guys think =).
Daily Developer Jokes - Friday, Sep 18, 2020
Tags: jokes, dailydeveloperjokes
Published: 2020-09-18 12:00:04

---
title: "Daily Developer Jokes - Friday, Sep 18, 2020"
description: "Check out today's daily developer joke! (a project by Fred Adams at xtrp.io)"
series: "Daily Developer Jokes"
cover_image: "https://private.xtrp.io/projects/DailyDeveloperJokes/thumbnail_generator/?date=Friday%2C%20Sep%2018%2C%202020"
published: true
tags: #jokes, #dailydeveloperjokes
---

Generated by Daily Developer Jokes, a project by [Fred Adams](https://xtrp.io/) ([@xtrp](https://dev.to/xtrp) on DEV)

___Read about Daily Developer Jokes on [this blog post](https://xtrp.io/blog/2020/01/12/daily-jokes-bot-release/), and check out the [Daily Developer Jokes Website](https://dailydeveloperjokes.github.io/).___
### Today's Joke is...
![Joke Image](https://private.xtrp.io/projects/DailyDeveloperJokes/public_image_server/images/5e1259ab8700f.png)

---
*Have a joke idea for a future post? Email ___[xtrp@xtrp.io](mailto:xtrp@xtrp.io)___ with your suggestions!*

*This joke comes from [Dad-Jokes GitHub Repo by Wes Bos](https://github.com/wesbos/dad-jokes) (thank you!), whose owner has given me permission to use this joke with credit.*

<!-- 
Joke text:
___Q___: Why was nobody given food at the developer conference?

___A___: It was a serverless function!
 -->
LINK YOUR GITHUB PROFILE AND GET HIRED
Tags: github, job, career, freelance
Published: 2020-09-18 11:51:12


<a href="bit.ly/2NbSVLS">CodersRank</a> is a platform made to help developers in job-seeking and professional growth. Find a developer job on <a href="bit.ly/2NbSVLS">CodersRank</a>: Your CodersRank profile serves as a proven track record of your coding knowledge. Just connect your private and public repositories to generate your true profile.

If you are looking for a #remote 🌴 developer job, check this out:

<a href="bit.ly/2NbSVLS">CodersRank</a> can help you get matched with a relevant job: just add your job preferences to your profile! 👨💻👩💻

Login/register here: <a href="bit.ly/2NbSVLS">Coders Rank</a>
#codersrank101 #jobsearch #remote


#codersrank101: The more info you provide on your profile, the better your chances of finding your dream job! 💼

Add YOUR Tech Stack today! <a href="bit.ly/2NbSVLS">Add Your Stack</a>

Create your always up-to-date 360-degree coder profile and let your work speak for itself!
Join CodersRank now!  <a href="bit.ly/2NbSVLS">Coders Rank</a>
Sidegig project: Art Prints 
Tags: showdev, watercooler, javascript, opensource
Published: 2020-09-18 11:46:08

After hours of tweaking and experimenting I'm proud to present "The Champions Pub" Art Print - squeezed almost 2000 unique DMD screenshots from my emulator, check it out at:
https://www.concealed-art.com/product-page/the-champion-pub
What is the best linux distros?
Tags: windows, linux
Published: 2020-09-18 11:42:54

My windows machine sucks after updating.
So I am in a decision to change to linux. But there are number of linux distributions out there.
Which one to use?
Which is the best?

Yeah I know, there is no such thing as **THE BEST**. But there must be one which is good in its own way, right?

Suggest me some linux distros of your choice.
Comment down your linux and it pros.
I will choose one😂.

(Edited) Overall alternative of windows.

Thank you.
How is Salesforce a platform to improve customer relationships?
Tags: crm
Published: 2020-09-18 11:42:11


It is inevitable that most organizations will use effective Salesforce techniques, as well as custom tools, that are built on the Salesforce platform to provide better sales opportunities and stay ahead of the market. This certainly makes Salesforce an invaluable and enduring tool for any business to increase sales, and this is the main reason that Salesforce certification is incredibly necessary to make the most of the IT opportunities that present themselves.

As everyone already knows, Salesforce is a platform to improve [customer relationships](https://www.cloudanalogy.com/) and present your brand as a reputable brand in the market. A business using Salesforce services is already rated as one of the most loved industries with enhanced CRM, and not everyone is aware of the other vital areas in which you can help the business, which is obviously the media. social and software implementation, which is cloud-oriented. The sales cloud in Salesforce is one of the best services available, helping the company have secure access to its data. Another exchange of this data becomes easier and more convenient.

Today, Salesforce is not just limited to CRM, it helps customers have better content, better workflow, mobile apps, and all the technical support they need, making it a must-have for any business looking to become big on the market in no time. of time.

Salesforce Certification: -

By now, you've probably understood the value of implementing Salesforce in your organization, so here are some areas where Salesforce certification can literally help you.

-> Administrators: - Installation and configuration of Salesforce and its software can follow a basic and advanced administrator registration.

-> Deployment Experts: - Deploying cloud-based solutions can improve application design and construction, increasing productivity while effectively managing data and designing analytics to continue metrics. Helps distinguish between cloud sales consultant credentials and cloud services consultant credentials, the latter used in case, portal, and information design solutions.

-> Developers: - Building client applications with ADE platforms to create data models, logic, security, user interface, reports, and dashboards can track basic and advanced developer credentials.

-> Architects: - Can help identify system architects evaluating the [Salesforce](https://www.cloudanalogy.com/) customer environment and design a secure, high-performance platform. They can provide technical solutions to the needs of each business and have the ability to lead design and implementation through to completion.
Logistic Regression using R
Published: 2020-09-18 10:27:11

Logistic Regression is one among the machine learning algorithms used for solving classification problems. it’s wont to estimate probability whether an instance belongs to a category or not. If the estimated probability is bigger than threshold, then the model predicts that the instance belongs thereto class, alternatively it predicts that it doesn’t belong to the category as shown in fig 1. This makes it a binary classifier. Logistic regression is employed where the worth of the variable is 0/1, true/false or yes/no.
Image for post
2. Why Logistic Regression, Not rectilinear regression
Linear Regression models the connection between variable and independent variables by fitting a line as shown in Fig 4.
Image for post
In rectilinear regression , the worth of predicted Y exceeds from 0 and 1 range. As discussed earlier, Logistic Regression gives us the probability and therefore the value of probability always lies between 0 and 1. Therefore, Logistic Regression uses sigmoid function or logistic function to convert the output between [0,1]. The logistic function is defined as:
1 / (1 + e^-value)
Where e is that the base of the natural logarithms and value is that the actual numerical value that you simply want to rework . The output of this function is usually 0 to 1.
The equation of rectilinear regression is
Y=B0+B1X1+…+BpXp
Logistic function is applied to convert the output to 0 to 1 range
P(Y=1)=1/(1+exp(?(B0+B1X1+…+BpXp)))
We need to reformulate the equation in order that the linear term is on the proper side of the formula.
log(P(Y=1)/1?P(Y=1))= B0+B1X1+…+BpXp
where log(P(Y=1)/1?P(Y=1)) is named odds ratio.
Resources Box:- This article is inspired by Logistic Regression explained (https://www.excelr.com/blog/data-science/regression/understanding-logistic-regression-using-r)of Excelr Solutions.
Please help with the below software testing scenario
Published: 2020-09-18 11:29:26

The workflow of an ATM is defined by the following rules:

The ATM goes into the WORKING state with the TURN ON action.
When in the WORKING state, the ATM can:
ACCEPT CARD which switches it to the CARD ACCEPTED state.
Start the AUTOMATIC TESTING action which switches it to the SELF TESTING state.

Within CARD ACCEPTED the ATM can:
CALL POLICE which switches it to the WAITING POLICE state.
PROCESS TRANSACTION which switches it to the TRANSACTION PROCESSED state.

From the TRANSACTION PROCESSED state the ATM goes into the SELF TESTING state with the PULL CARD action.

When in the SELF TESTING state, the ATM can either:
PASS, which switches it to the WORKING state.
FAIL, which switches it to the WAITING SERVICE state.

From the WAITING SERVICE state, the ATM can either:
Be SERVICED, which puts the ATM into the WORKING state.
Be RETESTED, which returns the ATM to the SELF TESTING state.

Prepare the optimal (effective and efficient) set of test cases required to test this workflow.

Below is the link to the question:
https://www.testdome.com/questions/quality-assurance/atm-workflow/44614?visibility=3&skillId=83&topicId=146

With identifying the test cases as my results reflect:
Test suite effectiveness : 100%
Test suite efficiency : 75%
Overall score : 75%
IN XAMPP Error: MySQL shutdown unexpectedly.

Tags: help, php, server, mysql
Published: 2020-09-18 11:22:28

again nd again after solving this problem it bounce back,nd this time i am facing too much problem ,already watch soo many youtube videos still error is not solved!

its showing error i.es
This may be due to a blocked port, missing dependencies, 
04:43:58 PM  [mysql] 	improper privileges, a crash, or a shutdown by another method.
04:43:58 PM  [mysql] 	Press the Logs button to view error logs and check
04:43:58 PM  [mysql] 	the Windows Event Viewer for more clues
04:43:58 PM  [mysql] 	If you need more help, copy and post this
04:43:58 PM  [mysql] 	entire log window on the forums

plz help me
Branching Strategies
Tags: git, devops, linux, developers
Published: 2020-09-18 10:55:58

Have new ideas but directly implementing them won’t bring the expected results always!!! Bugs , vulnerabilities can be anywhere so here BRANCHING STRATEGIES comes in the picture where different ideas and concepts are widely accepted and when all are tested and implemented on other environments then are finally merged to the master and released  for production.

GIT FLOW : Firstly Designed by Vincent Driessen. In Driessen model ,there are 2 permanent branches :

· Master Branch : From where software is released for production

· Develop/Dev Branch : Branch where developers works on

Other Non-Permanent branches :

· Feature : Branch to develop new features

· Release : Branch support preparation of new production release

· Hotfix/Patch : Production issues branch that need immediate fix 
  before planned release.

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

So the workflow initially starts from the single develop branch. Developers create feature branches for each new feature and group of features. We can name feature branches based on the feature we are working on. These branches are merged with the develop branch. Once a mass or set of related features are built and merged , a new release branch is created. Release branch is now tested and defects are logged which are fixed over here itself and merged back to the develop branch. Once the team is confirmed with the quality of the release is good, a new master branch is created from the release branch. The master branch is tagged with the version and deployed to production. If any defect or bug comes then a hotfix branch is created from master to fix all those issues and merged back into master and released.

I hope this makes a bit of clear understanding. Feel free to connect and correct if wrong anywhere.
Laravel Clear Cache Using Artisan
Tags: laravel, css
Published: 2020-09-18 10:37:34

In This tutorial Simply clear cache from the command line (CLI). we will discuss how to clear cache from blade (views), routes, config, etc using the (CLI) and artisan command.

we need to make cache in laravel projects for better completion. But if our application is development mode then what we want to get cured due to the cache. Then this time we need to clear the cache.

List of the cache clear commands

[Laravel Clear Cache Using Artisan Command (CLI)](https://www.phpcodingstuff.com/blog/laravel-clear-cache.html)
What do you use for video calls?
Tags: webdev, discuss, productivity
Published: 2020-09-18 10:35:40

---
title: What do you use for video calls?
published: true
description: 
tags: webdev, discuss, productivity
cover_image: https://assets.mofoprod.net/network/images/02-PNI2x.original.jpg
---
When it comes to video call apps, there are lots of options like Zoom, WhatsApp, Google Dou, Apple Facetime, Messanger, Skype, etc.
Which one do you use and why would you recommend it?
Pragmatic Programming Understanding
Tags: programming
Published: 2020-09-18 10:28:33

I’m taking a break from my usual articles to write something for beginners starting to program: Brief, simple explanations of various concepts and programming terms. These came from explaining some concepts to my friend who was completing a curriculum in computer science.

## Features vs Design vs Implementation

- Features: What the program can do
- Implementation: How the program does it
- Design: Planning features and implementations.

## Programming paradigms

In programming we have logic (how), and data (what). Do note that these paradigms can be mixed.

Functional paradigm: It’s when you pass in data into logic, and have a new data as a result. E.g. Clojure.

Object Oriented paradigm: It’s when you place logic in data, and data uses signals to communicate between each other on what logic to trigger. E.g. Ruby

There are also paradigms that focus on what to control, the logical command or the logical result.

Imperative paradigm: You make logical commands that describe logic to change your data. E.g. C.

Declarative paradigm: You explain the final data result to program and it solves the commands to do it for you.

## Types

Untyped languages are like maths. You focus on getting the algorithms right. Here we use schemas to restrict the range of data that can be correct. E.g. square root, but following schema of positive integers. This includes Python and Ruby.

Typed languages are like physics, you focus on getting the results right. Here types perform basic checking on intermixed values. For more complex checking to the level of schemas you need dependent types. This includes C and Haskell.

## Mutability

Mutable means “can be changed. Immutability, the opposite, can prevent more human errors by making sure data can only be copied, but not changed. However, the trade off is that your program takes more space and is slower.

On the other hand, programs using mutable data structures can be very fast and use less memory but programmers will make more mistakes.

## Project management

Scope: How much will you complete

Resources: How much can you use (including human resources)

Time: How long will you take

This brings us to the development styles:

Waterfall: Fixed scope, but flexible resources and time.

Agile: Fixed resources and time but flexible scope.

## Spectrum of development

All of these require algorithm and data structure knowledge.

Front-end: User-facing application where you have less control over the environment. Can be web based, like HTML/JS/CSS, or native, like C++ or Java.

Back-end: Non-user-facing application where you have more control over the environment. Any language can be a backend language.

Infrastructure and Operations: Applications that host the front-end or back-end applications, and how to transfer the front-end application to the user etc

Data engineering: Applications that gather and clean data for use in other applications like AI applications.
DevOPS team code review notifications
Tags: devops, gitflow, chatops, sre
Published: 2020-09-18 10:25:36

The *code review process* is a good point. Developers do it every day, but operation team processes are not the same as devs. Waiting for config approve is *time wasted* for the whole operation team. Work in different branches is not suitable for terraform with single state file. 
My teammates are trying to faster MR approving and write a lot of messages to slack. The MR notifications channel becomes too noisy and everyone thinks that this MRs already approved :). 
There is a good point for automatisation. 

Let's try to develop that I want. 
The bot should write a message to Slack channel for every new MR and edit the same message then MR is approved and merged. 
What we have finally:
![Merge request notify](https://dev-to-uploads.s3.amazonaws.com/i/o8jzzsj7ldvntjq7hujg.png)
Glance view allows me to detect which MR is waiting my approve :) 

I will appreciate any advice or ideas to improve my process. Next step is to write diff for one-line change MR to IM with the button "Approve". Just to increase the approval process for very simple changes.

The code for this bot: https://github.com/artemsre/gitlabMRNotify
Web Scraping Don'ts
Published: 2020-09-18 10:25:04

Web scraping projects are known to fail a lot. So we thought it is more appropriate to have a list of DON'Ts rather than a list of DO's. So here goes.

If the crawler depends on any external data or event to happen in a particular way, Don't assume it will happen like that. It won't MORE often than it does. For example: when fetching a URL, it could break because of timeouts, redirects, CAPTCHA challenges, IP blocks, etc.
DON'T build custom code. Use a framework like scrapy.
DON'T be too aggressive on a website. Check the response time of the website first. In fact, at crawltohell.com, our crawlers adjust their concurrency depending on the response time of the domain, so we don't burden their servers too much.
DON'T write linear code. Don't write code that crawls, scrapes data, processes it, and stores it all in one linear process. If one breaks, so will the others, and also, you would be able to measure and optimize the performance of each process. Batch them instead.
DON'T depends on your IP's. They will eventually get blocked. Always build in the ability to proxy your requests through a Rotating Proxy Service like Proxies API.