teleren/devto huggingface dataset:
Late variables in dart and lazy initialization | dart learning series #1
Tags: flutter, dart, variables, programming
Published: 2021-04-03 16:10:54

Dart 2.12 added late modifier in variables.
That can be used in following two cases.

- In migrating your project to null safety.
- Lazily initializing a variable.


## 1. In Migrating your project to null safety
`late` modifier can be used while declaring a non-nullable variable that’s initialized after its declaration.

Declaration of variables that will be initialize later is done using late modifier.
### Example -
```dart
late String title;
void getTitle(){
title = 'Default';
print('Title is $title');
}
```
### Note:
> while using late before variables make sure that, variable must be initialized later. Otherwise you can encounter a runtime error when the variable is used.


## 2. Lazily initializing a variable
This lazy initialization is handy in following cases.

- The variable might not be needed, and initializing it, is costly.
- You’re initializing an instance variable, and its initializer needs access to this.

```dart
// This is the program's only call to _getResult().
late String result = _getResult(); // Lazily initialized.
```

In the above example, if the result variable is never used, then the expensive _getResult() function is never called.

Let say `_getResult()` is very heavy function that is calculating that result.
But if we assign this to any variable without late then every time `_getResult()` will be executed even if we are not using this.

### Without late
```dart
//START
String result = _getResult();
//END
```
In the above code result is never used still `_getResult()` is executed.

### With late
```dart
//START
late String result = _getResult();
//END
```
In the above code `_getResult()` is not executed as the variable result is never used and it is declared using late modifier.
Great Esolangs
Tags: github, esolang, showdev
Published: 2021-04-03 16:04:54

Sometimes, esolangs can just be amazing. In this article, I will showcase 5 esolangs that I think are stupendous. ***NONE OF THESE ARE MINE***

### 5. Jellyscript
Those of you who have seen my article *A beginner's guide to the thulium esolang* will know about this language as well. It is the language that inspired me to create thulium.

{% github nguyenphuminh/Jellyscript %}

### 4. VNC
Ok so this is going to be a theme but nguyenphuminh created 3 of these languages. VNC is basically Vietnamese batchfile.

{% github nguyenphuminh/VNC %}

### 3. Bf
I cannot talk about esoteric programming languages without mentioning the most well-known. It doesn't have an official github page yet but it is worth putting here.

### 2. Long
Long is a language based on ASCII and perfect for minimalists.

{% github pranavbaburaj/long %}

### 1. FreakC
FreakC is by far one of the best custom-made esolangs I know of. It is useful in many ways and is one of the few languages that can self-recreate.

{% github nguyenphuminh/FreakC%}
Ensure No Product Tenants Are Opened During Maintenance Mode
Tags: aws, route53, devops, cloudopz
Published: 2021-04-03 16:03:38

<p align="center">
  <a href="https://dev.to/vumdao">
    <img alt="Ensure No Product Tenants Are Opened During Maintenance Mode" src="https://github.com/vumdao/route53-records-set/blob/master/cover.png?raw=true" width="700" />
  </a>
</p>
<h1 align="center">
  <div><b>Ensure No Product Tenants Are Opened During Maintenance Mode</b></div>
</h1>


### 🚀 **How to set maintenance mode for thoudsands of tenants**
- Create a record set call `alb-tunnel.cloudopz.com` as a CNAME point to the ALB
- Set aLL Tenant records point to `alb-tunnel.cloudopz.com` with type CNAME
- So when it needs to set maintainance mode, we just need to set `alb-tunnel.cloudopz.com` point to our maitainance page


### 🚀 **Why need to Ensure No Product Tenants Are Opened During Maintenance Mode**
- During maintainance mode, the database might be running migrated so customer should not access the site
- We need to ensure no tenant product point to ALB directly except test/demo sites. Here is the way to manually check (free feel to automate it)

```
aws route53  list-resource-record-sets --hosted-zone-id Z39FXXXXXXXXXX --query "ResourceRecordSets[?Type == 'CNAME']" | jq -r '.[] | [([.Name, .ResourceRecords[].Value] | join(", "))] | @csv' | 
grep "alb-.*..amazonaws.com" | grep -Ev "test|demo" 
```

---

<h3 align="center">
  <a href="https://dev.to/vumdao">:stars: Blog</a>
  <span> · </span>
  <a href="https://github.com/vumdao/">Github</a>
  <span> · </span>
  <a href="https://vumdao.hashnode.dev/">Web</a>
  <span> · </span>
  <a href="https://www.linkedin.com/in/vu-dao-9280ab43/">Linkedin</a>
  <span> · </span>
  <a href="https://www.linkedin.com/groups/12488649/">Group</a>
  <span> · </span>
  <a href="https://www.facebook.com/CloudOpz-104917804863956">Page</a>
  <span> · </span>
  <a href="https://twitter.com/VuDao81124667">Twitter :stars:</a>
</h3>
How to Make Full-Stack Project with Nuxt and ExpressJs
Tags: vue, node, codenewbie, beginners
Published: 2021-04-03 16:00:47




### Introduction
Before I knew this I was making the backend and the front-end separately and the  cors handle all the cross-origin requests,
But here is the problem cause I am broke I can't afford to pay for a good server then I went with Heroku,
 and the free plan has a sleeping time when the server isn't used they shut it down and rerun it when somebody uses it then the whole npm run this is a lot of time to wait for the user,
  so I decided to go with the same origin to cut this downtime to half then I made my research and I didn't found  a lot so I decided to make one for me and the people beginners like me 
let's start 
If you wanna make the backend and the frontend of the same origin you can do it in two ways

### From Nuxt Docs

here basically you write a regular express app
```  
const app = require('express')() 
```
then identify your port the server will run on
```
const port = process.env.PORT || 3000
```
then you load nuxt and write a line of code to check are you in development or not
```
const { loadNuxt, build } = require('nuxt');
const isDev = process.env.NODE_ENV !== 'production'
```
then we make async function then use nuxt.render middleware

```
async function start(){

 // Render every route with Nuxt.js
 const nuxt = await loadNuxt(isDev ? 'dev' : 'start')
 
 //render Routes with nuxt render
 app.use(nuxt.render)

//build on dev mode because of hot reloading (reload the page when any change happens)
 if(isDev){
 build(nuxt)
 }
 
 //listen to port
 app.listen(port, '0.0.0.0')
 console.log("loading on "+ port)
}
start();
```
then go to nuxt.config.js
```
middleware:['name of your middleware']
```
if you are interested to use this method 
you can read more on 
[Nuxt Docs](https://nuxtjs.org/docs/release-notes#-features)

### Server Middleware
this is the simpler way to do it you have to do three things
1- Make api file and put all your express code on it
2- add this to the end of your index.js code
```
module.exports = app

// Start standalone server if directly running

if (require.main === module) {

const port = process.env.PORT || 3001

app.listen(port, () => {

// eslint-disable-next-line no-console

console.log(`API server listening on port ${port}`)

})

}
```
3- add serverMiddleware to nuxt.config.js
```
serverMiddleware: {

'/api': '~/api'

},
```
if you wanna use it directly without doing anything there is a ready to use the template on [GitHub](https://github.com/nuxt-community/express-template)

in the last thanks for reading, I hope you found this helpful for you,
 if you want me for work you can DM me on any of my social media on my profile 

Check my new Startup [Dremor](www.dremor.tk)
Java 9 CompletableFuture API Improvements - Delay and Timeout Support
Tags: java9, completablefuture
Published: 2021-04-03 14:56:36

Java 9 CompletableFuture API Improvements - Delay and Timeout Support

https://grokonez.com/java/java-9/java-9-completablefuture-api-improvements-delay-timeout-support

To improve <a href="https://grokonez.com/java/java-core/java-future">Java Future</a>, Java 8 provides <a href="https://grokonez.com/java/java-advanced/java-8-completablefutures">CompletableFuture</a> which can execute some code whenever its ready. In this article, we're gonna take a look at new <a href="https://grokonez.com/category/java/java-9">Java 9</a> CompletableFuture API that supports delay and timeout.

<!--more-->
<div id="tuttoc" class="jsa-toc"></div>

<div id="tutcontents">
<h2>I. Delay</h2>
<pre><code class="language-java">
static Executor delayedExecutor(long delay, TimeUnit unit);
static Executor delayedExecutor(long delay, TimeUnit unit, Executor executor);
</code></pre>
- The first method, not specify <code>Executor</code>, returns a new <code>Executor</code> that submits a task to the default executor (general purpose pool <code>ForkJoinPool.commonPool()</code>) after <strong>delay</strong> time.
- The second method, with an <code>Executor</code> as parameter, returns a new <code>Executor</code> that submits a task to that input executor after <strong>delay</strong> time.

Now see an example to illustrate how the method works. We have a <code>CompletableFuture</code> that will delay its completion by 3 seconds. The code could be:
<pre><code class="language-java">
future.completeAsync(supplier, CompletableFuture.delayedExecutor(3, TimeUnit.SECONDS))
		.thenAccept(result -> System.out.println("accept: " + result));

// other statements
</code></pre>
The program runs <em>'other statements'</em> first. 3 seconds later, it call <code>get()</code> method of <code>supplier</code> and pass the result to <code>thenAccept()</code>.
<h2>II. Timeout</h2>
<h3>1. orTimeout()</h3>
<pre><code class="language-java">
CompletableFuture<T> orTimeout(long timeout, TimeUnit unit);
</code></pre>
The method exceptionally completes current <code>CompletableFuture</code> by throwing a <code>TimeoutException</code> if not otherwise completed before the <strong>timeout</strong>.

For example, we have a <code>doWork()</code> method that takes 5 seconds to return a <code>CompletableFuture</code>. But we set <strong>TIMEOUT</strong> only 3 seconds.
<pre><code class="language-java">
// TIMEOUT = 3;
// doWork() takes 5 seconds to finish

CompletableFuture<String> future = 
		doWork("JavaSampleApproach")
		.orTimeout(TIMEOUT, TimeUnit.SECONDS)
		.whenComplete((result, error) -> {
			if (error == null) {
				System.out.println("The result is: " + result);
			} else {
				System.out.println("Sorry, timeout in " + TIMEOUT + " seconds");
			}
		});
</code></pre>

More at: https://grokonez.com/java/java-9/java-9-completablefuture-api-improvements-delay-timeout-support
Spring Boot Tutorial
Tags: springboot
Published: 2021-04-03 15:48:51

https://grokonez.com/spring-framework-tutorial/spring-boot

Spring Boot helps us build stand-alone, production Spring Applications easily, less configuration then rapidly start new projects.

Features:

Stand-alone Spring applications
Embedded Serverlet Container: Tomcat, Jetty or Undertow.
Support ‘Starter’ POMs to make your Maven configuration easily ways.
Automatically configure Spring.
Provide production-ready features such as metrics, health checks and externalized configuration
No code generation, No requirement for XML configuration



https://grokonez.com/spring-framework-tutorial/spring-boot
Day 95 Of 100DaysOfCode: Collected Data For Second Project
Tags: 100daysofcode, codenewbie, womenintech, wecoded
Published: 2021-04-03 15:36:24

This is my 95th day of #100daysofcode and #python learning journey.  Talking about today's progress, I collected interest rates of some banks of Nepal using BeautifulSoup and Python. I needed to scrape approximately 25 bank's interest rate for agriculture loan, student loan, unsecured personal loans, home equity loans etc. And my goal is to make a platform to compare different interest rates of different rate. I have to learn Streamlit for that.

Like usual days, I also keep learning from DataCamp. I also completed some assignments.
<blockquote class="twitter-tweet"><p lang="en" dir="ltr">Day 95 Of <a href="https://twitter.com/hashtag/100DaysOfCode?src=hash&amp;ref_src=twsrc%5Etfw">#100DaysOfCode</a> and <a href="https://twitter.com/hashtag/Python?src=hash&amp;ref_src=twsrc%5Etfw">#Python</a> <br>Collected Bank&#39;s Interest Data For My Second Project<a href="https://twitter.com/hashtag/100DaysOfCode?src=hash&amp;ref_src=twsrc%5Etfw">#100DaysOfCode</a> <a href="https://twitter.com/hashtag/womenintech?src=hash&amp;ref_src=twsrc%5Etfw">#womenintech</a> <a href="https://twitter.com/hashtag/CodeNewbie?src=hash&amp;ref_src=twsrc%5Etfw">#CodeNewbie</a> <a href="https://twitter.com/hashtag/DEVCommunity?src=hash&amp;ref_src=twsrc%5Etfw">#DEVCommunity</a> <a href="https://t.co/nIGHl1EyVp">pic.twitter.com/nIGHl1EyVp</a></p>&mdash; Durga Pokharel (@durgacodes) <a href="https://twitter.com/durgacodes/status/1378366962271539204?ref_src=twsrc%5Etfw">April 3, 2021</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
Eslint vs Performance
Tags: javascript, eslint, performance
Published: 2021-04-03 15:33:30

Nowadays, [eslint](https://eslint.org/) is a very popular tool in the frontend world. It helps you to enforce different code style rules, prevent bugs, and encourage your team to use best practices as you write code. 

Eslint is completely pluggable and you can add as many rules as you wish, and of course, write your own rules. As you start seeing the benefits eslint gives you, it is become very tempting to use each and every rule that you can reach out to.

But beware! Keep in mind, that with every rule you accumulate the amount of work that needs to get done whenever you lint your code, be it a local development or a part of a CI.

To get some insights about time spent on every rule you can use a special environment variable `TIMING=1`. It will trigger the display of the ten longest-running rules, along with their individual running time and relative performance impact ([docs](https://eslint.org/docs/developer-guide/working-with-rules-deprecated#per-rule-performance)).

Take a look at the timing information on one of the projects I'm working on:
```
Rule                                    | Time (ms) | Relative
:---------------------------------------|----------:|--------:
import/no-restricted-paths              | 94633.358 |    72.2%
@typescript-eslint/no-floating-promises | 18576.419 |    14.2%
react/no-multi-comp                     |  4629.594 |     3.5%
@typescript-eslint/no-redeclare         |  2634.454 |     2.0%
lodash/callback-binding                 |  1272.849 |     1.0%
@typescript-eslint/naming-convention    |  1209.871 |     0.9%
lodash/collection-return                |   885.415 |     0.7%
lodash/no-unbound-this                  |   669.923 |     0.5%
lodash/collection-method-value          |   668.716 |     0.5%
lodash/no-extra-args                    |   569.119 |     0.4%
```

More than 90 seconds spent on checking a single rule... A little bit too much, isn't it? :)

In this particular example, the `TIMING` report revealed a performance bottleneck and pushed us to contribute to a third-party eslint plugin we used and [fix it](https://github.com/benmosher/eslint-plugin-import/pull/2022) eventually.

In addition to obvious performance issues, you might notice that a significant amount of time is wasted on rules that you can live without. For example, most of the code-style-related rules could be replaced with [prettier](https://prettier.io/). Some rules just don't give you that much to use them, e.g. `react/no-multi-comp` in our case.
As for me, I prefer to follow [this advice](https://twitter.com/dan_abramov/status/1086215771401920512?s=20):

> Look at every linting rule and think: “Does this rule ~~bring  me joy~~ help me find bugs?” If not, TURN IT OFF.

But I would add: start with ten the longest-running rules if your goal is to speed up linting.
Looking for a solution and code in PHP or python?
Published: 2021-04-03 15:31:31

Hello, 
My question is How to scrape emails from input text when visitors on the website click on the button. 

I am a beginner in scarping so I don't have much idea how to scrape data from the input text field from the website when a visitor clicks a button and submits a form.
Functionality is like "We want the email data from people that bought products or joined a newsletter"
Please Suggest a solution for code and guidance
Thanks in advance.
Tips for making an esolang
Tags: esolang, esoteric
Published: 2021-04-03 15:30:30

An esoteric programming language (esolang for short) can be made for many reasons:
- Fun
- Proof of concept
- Learning
And many others.

Here are some tips on 1 thing you should and one thing you should not do when making an esolang.

# What you ***SHOULD*** use

If you are making a language that has commands, you should use string split functions.

String split functions are very useful when creating an esolang. Normally, they are used with some kind of delimiter. That delimiter can be what separates the commands of your esolang.

String split functions exist in many languages and can be used in many different ways. Here are some examples:

- Python
```python
a: str = "string with spaces"
arr: list = a.split(" ")
```

- JavaScript
```js
const a = "string with spaces";
const arr = a.split(" ");
```

- Ruby
```ruby
a = "string with spaces"
arr = a.split(" ")
```
String split functions exist in many languages and are useful when making an esolang with commands.


# What you ***SHOULDN'T*** do

I know that this sounds kind of rude but try not to come up with the syntax for the language yourself. There are many websites out there that you can use to get syntax ideas for your esolang. There is esolangs.org, libhunt and even github can be used for esoteric syntax ideas.
Now supporting Deno v1.8.3
Tags: deno, drash, rhum
Published: 2021-04-03 15:30:25

Hi y'all! It's been a while. So we noticed a flaw in our development workflow. Basically, whenever Deno updated its versions, we felt we didn't need to keep up to date with them as our modules "just worked" without issues. It wasn't until we noticed that you could be using the latest Deno version and have our modules import older versions of the Deno Std library (yeah... you can see where this could be prone to issues). This being said, we're now keeping up to date with Deno. As a result, every time Deno updates, we update.

All Drash Land modules now support Deno v1.8.3 and use Deno Std 0.92.0.

Get them while they're hot at https://drash.land!

-Eric
Deploy your react app on netlify for free
Tags: react, netlify, hosting
Published: 2021-04-03 15:29:09

In this post i will show you how to deploy your react app on netlify 
It is  simple :)

# 1 install netlify cli using npm
```
npm install netlify-cli -g
```
# 2 run:- npm run build
Open your project folder in terminal and run this command
```
npm run build
```
it will generate a build directory 


# 3 run:- netlify deploy
Continue the further process like name your website whatever you want but care fully choose the **./build** directory for deploy
![the_terminal_image](https://i.imgur.com/0TJBafH.png)


then you will get a *website_draft_url* check the link and if you see your website all content and functionality is ok then proceed to further step .

now if you want to view your actual webaddress you will find the page not found message so then you have to do,

#4 deploy it on your actual domain which you chose 

now your website is live but web address looks horrible so 
run
```
netlify deploy --prod
```
Then you will finally see your app on  web address like
yourwebsitename.netlify.app
Discord notifications on Google form submission
Tags: discord, googleforms, integration, webhook
Published: 2021-04-03 15:17:18

###Step #1

Get discord webhook. https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks will help you understand how to get a webhook for your channel in Discord.

###Step #2

Go to the Google form with which you want to integrate Discord. Click on the 3 dot menu on the top right and then click on **Script Editor**![Screenshot 2021-04-03 at 8.14.42 PM](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gul9e067genqedx41clh.png)
 
###Step #3

Code...

```javascript
var POST_URL = "YOUR_DISCORD_WEBHOOK_HERE";

  function onSubmit(e) {
  var discordPayload = {
    content: "New Form Submitted",
    embeds: [
      {
        type: "rich",
        title: "Form Entry",
        color: 307506,
        fields: []
      }
    ]
  };

  e.response.getItemResponses().forEach(function (i) {
    var v = i.getResponse() || "None";

    if (!Array.isArray(v))
      discordPayload.embeds[0].fields.push({
        name: i.getItem().getTitle(),
        value: v
      });
    else
      discordPayload.embeds[0].fields.push({
        name: i.getItem().getTitle(),
        value: v.toString()
      });
  });

  UrlFetchApp.fetch(POST_URL, {
    method: "post",
    payload: JSON.stringify(discordPayload),
    contentType: "application/json"
  });
}

```


###Step #4

Click on **Edit -> Current project's triggers** in Script Editor.
![Screenshot 2021-04-03 at 8.19.01 PM](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d6288al783eolkbkegz4.png)
 
###Step #5

Create a new trigger for `onSubmit` event
![Screenshot 2021-04-03 at 8.23.25 PM](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1jewj2upl7gunqceazcf.png)


###Step #6

There is no step 6! Go ahead and submit the form and test it. you'll see something like this in your Discord channel 👾 👾 👾
![Screenshot 2021-04-03 at 8.37.59 PM](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zapm5pjjina3ycdsy7ex.png)
Java 8 CompletableFutures
Tags: java8, completablefutures
Published: 2021-04-03 15:15:51

https://grokonez.com/java/java-8/java-8-completablefutures

Java 8 CompletableFutures

Java 8 multithreading programming has an important feature named <strong>CompletableFuture</strong>.
In previous post about <a href="https://grokonez.com/java/java-core/java-future">Java Future</a>, we have the concept of a <strong>Future</strong> object, which can help us make something done while waiting for other things. However, although we can inspect <strong>Future</strong> objects to see if they’re done, what if we wanna execute some code whenever its ready? We still have to wait until the result is available.

<strong>CompletableFuture</strong> meets the requirement, and more than that.

Related articles:
- <a href="https://grokonez.com/java/java-core/java-future">Java Future</a>
- <a href="https://grokonez.com/java/java-8-completablefuture-handle-exception">CompletableFuture Handle Exception</a>
- <a href="https://grokonez.com/java/java-8-multiple-completablefutures">Java 8 Multiple CompletableFutures</a>

<!--more-->
<div id="tuttoc" class="jsa-toc"></div>

<div id="tutcontents">
<h2>I. Create CompletableFuture</h2>
We use one of those factory methods to create a <strong>CompletableFuture</strong> object:
<pre><code class="language-java">static &lt;U&gt; CompletableFuture&lt;U&gt; supplyAsync(Supplier&lt;U&gt; supplier);
static &lt;U&gt; CompletableFuture&lt;U&gt; supplyAsync(Supplier&lt;U&gt; supplier, Executor executor);
static CompletableFuture&lt;Void&gt; runAsync(Runnable runnable);
static CompletableFuture&lt;Void&gt; runAsync(Runnable runnable, Executor executor);</code></pre>

If we don't provide any Executor object as input parameter, the method will use <code>ForkJoinPool.commonPool()</code>

https://grokonez.com/java/java-8/java-8-completablefutures