teleren/devto huggingface dataset:
JsDoc to TypeScript declaration.
Tags: howto, jsdoc, typescript, javascript
Published: 2020-12-04 10:54:51

A small "how to" create d.ts files from javascript JsDoc annotations.

### JsDoc

I'm using nvim with a tsserver (within the [CoC extension](https://github.com/neoclide/coc-tsserver)) editing vanilla javascript. I.m.o properly added JsDoc descriptions/annotations completely removes the urge from using TypeScript, omitting a compile step (keep is simple) so I can test/use these scripts directly in Nodejs and the browser.

Now, wouldn't it be nice to create "types.d.ts" files from plain javascript with JsDoc annotations. 

*However be aware that JsDoc does not support any @import tag/declaration so this only works with 'in' module jsdoc anotation*

For that we need: 

* [JsDoc](https://github.com/jsdoc/jsdoc)

I have installed it globally (-g) because I use JsDoc in most of my projects.

```
npm install -g jsdoc
```
We need a template to convert the generated documentation to a 'Typescript definition' file.

For that we use:

* [tsd-jsdoc](https://github.com/englercj/tsd-jsdoc)

```
npm install tsd-jsdoc --save-dev
```
Time to create definition files from javascript by running the following command. Where 'lib' is the folder where my javascript files live and 'types' is the folder where i want to place the types.d.ts file.

* -t is the template folder
* -r is the 'source' folder
* -d is the destination folder
```
jsdoc -t node_modules/tsd-jsdoc/dist -r lib/. -d types
``` 
And now we have to edit the 'package.json' file to point out where the Typescript definition file can be found.
Add the following and you 'r good to go. 
```
"types": "./types/types.d.ts"
"scripts": {
  "types": "jsdoc -t node_modules/tsd-jsdoc/dist -r lib/. -d types"
}
```
When executing:
```
npm run types
```
the types are being generated.

That's it
Why Flutter??
Tags: flutter
Published: 2020-12-04 10:45:17

So you are curious why you should use flutter instead of other languages out there. 
Here are 5 reasons why you should learn and use flutter for your app development dreams. 

1. The same rant. ONE CODEBASE
With Flutter 
you just need to MAINTAIN one codebase.
You just need to DEBUG one codebase.
you just need to UPDATE  one codebase.
You just need to learn ONE LANGUAGE - Dart.
If you have any background with programming you can pick up dart like a magnet picking up iron shreds. 
We can build ios web desktop android. 

2. Mobile, Web, Desktop.
But you are a programmer who doesn't only want to focus on app development but also web, desktop, and also obviously app development.
Well then, Flutter is that go to language for you. 
In addition to mobile apps, Flutter supports Web development AND you can compile Flutter code to native Windows, macOS, and Linux desktop app.s.
![all devices support](https://dev-to-uploads.s3.amazonaws.com/i/2jeuo8v1nmyjeuba0b2o.png)
If this already hasn't hooked you yet, here are more reasons.

3. Beautiful Layout widgets.
With so many screen sizes in the world right now, you might think that making an app for each of them is impossible and you want to stick with web development. 

BUT,
Until flutter, app developers were using constraints that were only for small-scale applications and non-complex apps.
so it becomes harder to make good UIs for larger projects.
so
Flutter takes inspiration from the web which is responsive design and implements it within its widgets and layouts.

So flutter has widgets like Row, Columns, Stacks, Paddings, Center to keep the layout building really easy and well structured.
![layouts](https://dev-to-uploads.s3.amazonaws.com/i/1o477pan5p2xkzvy8pzj.png)
If even that wasn't enough.

4. HOT RELOAD!
Flutter has hot reload!
normally in java and swift, it takes around 20 to 30 seconds on a fast computer to compile and download the apk on the emulator or mobile.
For that flutter has Hot reload and hot restart which takes less than a second to show the differences.  It becomes amazing to develop UI's with that feature, the second you wanna make a change you just press ctrl s, and it hot reloads it on the app, and you can see the changes real-time. 
So, therefore it becomes even easier to change and build your app the way you want it to look.

5. ITS OPEN SOURCE! 
U can see the backend code for every single line of code that you writing for every widget, every button every single thing in your dart file. 
and it just takes a click or a shortcut according to ur editor to access that.
and If you want to customize it you can do it according to the way you want it to function.
It's that simple. 
Unlike other languages **cough apple** 

So that's it for this one! Hope you got more clarity on why flutter is really a good framework to learn and build with! 
And also Thanks for reading!
JavaScript Code Daily Challenge #12
Tags: javascript, challenge, codenewbie, beginners
Published: 2020-12-04 10:44:02

# **About**

This is a series of JavaScript Code Daily Challenge. Each day I show a few solutions written in JavaScript. The questions are from coding practice/contest sites such as HackerRank, LeetCode, Codeforces, Atcoder and etc.

> Day of the Programmer
> [https://www.hackerrank.com/challenges/day-of-the-programmer/problem](https://www.hackerrank.com/challenges/day-of-the-programmer/problem)

```javascript
'use strict';

const fs = require('fs');

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', function(inputStdin) {
    inputString += inputStdin;
});

process.stdin.on('end', function() {
    inputString = inputString.split('\n');

    main();
});

function readLine() {
    return inputString[currentLine++];
}
```
> Complete the function in comment
```javascript
function dayOfProgrammer(year) {


}
```
```javascript
function main() {
    const ws = fs.createWriteStream(process.env.OUTPUT_PATH);

    const year = parseInt(readLine().trim(), 10);

    const result = dayOfProgrammer(year);

    ws.write(result + '\n');

    ws.end();
}
```
Terraform for Java developers video series
Tags: terraform, java, azure, spring
Published: 2020-12-04 10:37:32

---
title: Terraform for Java developers video series
published: true
description: Learn to use Terraform, from a Java developer's perspective
tags: terraform, java, azure, spring
---

[Terraform](https://www.terraform.io/) is one of those tools that many people talk about, but which can be a bit frightening for a Java developer.
There are several reasons for this, but mainly it's because Terraform is an infrastructure tool: this is going to create cloud resources for you, which isn't something most Java developers are used to do, and while doing so it's going to cost you some money.
And obviously, you are afraid that doing a wrong configuration is going to cost you a lot!
This series of videos is made exactly with this issue in mind: using a classical Java project, the [Spring Petclinic](https://github.com/spring-projects/spring-petclinic), we'll gently introduce the most important Terraform concepts, so that at the end you'll be able to deploy with confidence a Spring Boot and MySQL infrastructure to the cloud.

Each video is about 10 minutes long, so they are easy to consume, and they all have subtitles: if you have any issue following them, don't forget to turn those subtitles on!

The final project is avaible on [https://github.com/jdubois/spring-petclinic/tree/deploy-to-azure/terraform](https://github.com/jdubois/spring-petclinic/tree/deploy-to-azure/terraform).

## Terraform for Java developers, part (1/4)

In this first video, we describe what Terraform is, and we fork the Spring Petclinic project (available at [https://github.com/spring-projects/spring-petclinic](https://github.com/spring-projects/spring-petclinic)) to add a Terraform configuration.

{% youtube b0APzGlBWMA %}

## Terraform for Java developers, part (2/4)

In this second video, we create a MySQL server and configure it using Terraform, learning how Terraform manages state, and how it can create or update resources.

{% youtube mYZJqBVfACM %}

## Terraform for Java developers, part (3/4)

In this third video, we talk about best practices to improve your Terraform code, as well as tooling to facilitate understanding your code.

{% youtube lCMhpqE4h3c %}

## Terraform for Java developers, part (4/4)

In this fourth video, we complete our Terraform configuration and add a Java application service, configure our Spring Boot project to be deployed on Azure, run everything in the cloud, and finish by destroying our infrastructure.

{% youtube GBY_MvAF3Vg %}

Don't forget to subscribe to the [Java on Azure YouTube channel](https://www.youtube.com/channel/UCySRyO_0qCXxnHb6p7vMFnQ) for more Java tutorials and content!
Journey to writing better code - #1
Tags: programming, ddd, architecture
Published: 2020-12-04 10:36:17

### Have you ever worked on a project where you'd be insanely productive in the beginning but your productivity would take a hit as more features were added?

> I used to find myself wondering what was I doing wrong which would lead to thoughts like *maybe i'm not talented enough* or *my problem solving skills are not up to par*. I know, sounds depressing right? 

My first instinct was to read up on **Design Patterns**. I started with the **Head First Design Patterns** along with this [Youtube Series](https://www.youtube.com/watch?v=v9ejT8FO-7I&list=PLMygBPoOe_IV_42YFkuAECr3g7HhBXBTN) on the same and they  helped me out a lot. I would think about my code a lot and I would find myself thinking of ways to refactor my code to make it more acceptable by my standards at that time. I also read up on principles like  [DRY](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself#:~:text=The%20DRY%20principle%20is%20stated,authoritative%20representation%20within%20a%20system%22.&text=When%20the%20DRY%20principle%20is,in%20other%20logically%20unrelated%20elements.)  , [KISS](https://en.wikipedia.org/wiki/KISS_principle)  and  [YAGNI](https://en.wikipedia.org/wiki/You_aren%27t_gonna_need_it) . But, something still did not feel right
as I would almost always end up adding code complexity; primarily because I did not properly understand the design patterns I implemented and hence did not realize when I should not have used a specific design pattern but part of it was something entirely else which I would later come to know is called **Transaction Script**

**_The Click Moment_** for me was when I heard about Domain Driven Design or DDD. By this point, I had already read [Clean Code by Uncle Bob](https://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882) and  [Refactoring by Martin Fowler](https://martinfowler.com/books/refactoring.html). I parsed through Eric Evan's  [Domain-Driven Design: Tackling Complexity in the Heart of Software](https://www.amazon.com/Domain-Driven-Design-Tackling-Complexity-Software/dp/0321125215) and the concepts/ideas he presented just made a lot of sense to me. This was the beginning of my journey of learning to use Domain Driven Design to map any given problem domain to maintainable and scalable code that I wouldn't hate two months after I wrote it.  More on this later..

This is a crosspost from [my blog](https://blog.hannanhamza.com/journey-to-writing-better-code-1)
Java 8 Streams. 
Tags: java, streams, api
Published: 2020-12-04 10:25:03

I prepared every thing you need know about **Java 8 Streams** . Examples; I prepared with source code in **Github**. You can click link below to get more.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/5257fmvphxrkd66x9960.jpg)

https://bit.ly/36Gmcsy
Hello world!
Tags: csharp
Published: 2020-12-04 10:23:36

Func<bool> Time = delegate() 
{ 
//TODO Implement this as soon as possible!
return false; 
};

if (Me.Found(Time))
{
while (true)
{
Array.ForEach(Me.Travel().GetDestinations(), destination =>
{
destination.TakePhotos();
});
}
}
IT Staff Augmentation: How It Can Benefit Your Tech Startup?
Tags: discuss, technology, staffing
Published: 2020-12-04 10:18:37

This was blog was originally published on [Medium] (https://medium.com/).

Imagine you already have an outstanding idea and a perfect plan ready to shape as a startup. But, you don’t have an outstanding team to turn your Idea into Reality. Thus, your outstanding idea will only remain a concept that could have had a massive impact.

Now, this is one of the major challenges startups face, where they don’t have an idea of how to commence things with hiring the right talent. This is where the need for IT staff augmentation arises for productivity as well as for measuring the software development metrics.

In most of the successful tech startups, people are the factor that can make or break your business. Thus, IT staff augmentation plays an important role when handled wisely. Let us understand it briefly, before understanding How IT staff augmentation can benefit your TECH startup.

#What is staff augmentation?
Staff augmentation is a popular outsourcing strategy wherein you can hire highly skilled & experienced talent on a contract rather than permanently.

Simply, you will get highly skilled and qualified employees from software development companies offering IT staff augmentation services that help you in meeting all your project objectives.

IT staff augmentation is emerging as a popular outsourcing strategy, especially in this Covid-19 pandemic situation for employing a dedicated workforce. The reason is that many startups are looking to hire expert talent with the help of IT staff augmentation to fulfill their deadlines & aggressive project requirements.

###Now, Let’s see [how IT staff augmentation can benefit your TECH startup] (https://www.bacancytechnology.com/it-staff-augmentation-services).
Here, I’ve outlined some fantastic benefits of staff augmentation that will help to boost your tech startup;
- Highly Flexible and Cost-Effective
- Simplifies IT Recruitment
- Top-notch quality with exceptional skills
- Faster time to hit the market
- Increased Output and Team Size

Read the entire blog; 
[IT Staff Augmentation: How It Can Benefit Your Tech Startup] (https://medium.com/devtechtoday/it-staff-augmentation-how-it-can-benefit-your-tech-startup-721ec9d2ad9b)
How to Run Stripe Webhooks Locally
Tags: tutorial, webdev
Published: 2020-12-04 10:18:17

Today's article is going to be a bit niche, but nevertheless it's an issue I have run into on multiple projects and have finally reached a solid solution.

**Note: This solution can be applied to PayPal, and any other platform that requires you to listen to webhooks.**

## The Problem
Stripe (and other payment solutions like PayPal) allows your application to listen to webhooks for all kinds of payment events (subscription updated, invoice creation, etc).

When trying to test payment events locally, we have to use our "live" test endpoints, since Stripe can only send events to a real server, not localhost.

This is a huge pain when debugging payments, since you have to deploy your test environment for every single change.

Also, Stripe only gives you two environments: test mode, and live mode. This ends up being pretty limiting for the common "local, dev, qa, prod" environment setup.

## The Solution
We need a way to funnel webhook events to our locally running API. Luckily, some people smarter than I have created free tools for us to do this.

### Install Ultrahook

What is [ultrahook](https://www.ultrahook.com/)? It's an awesome, free tool that allows you to receive webhook events on localhost by funneling requests from the Ultrahook cloud (via your unique url), to your private endpoint (ex. localhost:8080). Once you try it, you won't ever go back.

1. If you haven't already, [create an Ultrahook account](https://www.ultrahook.com/register) to receive your API key.

2. Next, run `gem install ultrahook` on the command line. You may have to install `ruby` first by running `brew install ruby` on Mac, or perhaps  [this easy-installer](https://rubyinstaller.org/) for Windows.

3. Run `echo "api_key: INSERT_API_KEY_HERE" > ~/.ultrahook` so you don't have to pass in your API key on every ultrahook command

4. Run `ultrahook stripe INSERT_DESTINATION_HERE`, where the destination is your local endpoint (ex. localhost:8080/webhooks/stripe)

And that's it! Thank you [Vinay Sahni](https://twitter.com/veesahni) for creating this!

### Note for Teams
There are two approaches (that I've thought at least) you can take to get this setup for a team:
1. Let each member create their own ultrahook account, and as part of the onboarding process, they add their listeners to Stripe.
2. Use a master ultrahook account and share it with your team.

I think option 1 is the safer choice, although more tedious.

### Create a New Stripe Account
This might seem a bit annoying, but it really makes your dev life easier.

I usually organize it as follows:
* Main Stripe Account -> live -> production
* Main Stripe Account -> test mode -> QA
* Test Stripe Account -> test mode -> local

### Enjoy the fruits of your labor
It takes a hot minute to set this up, but once you do, you will be *so* happy you did. At least I was.

If anyone goes with this setup, I'd love to hear about your experience! Any ideas for improvements? Let me know.
First time using Map in Go
Tags: go, tutorial
Published: 2020-12-04 10:03:15

> Every single person has their clean code, but not for team

Everything changes. I was changed my programming language from PHP to Go and I found many differences. 

There are things that I interest, one of them is map

``` golang
var student map[string]string
```
In PHP we know map as array associative 
``` php
$student["name"] = "Brian"
``` 
## Create Map
To create map is simple, in go just use key var
or ":=" it will create var and set type value as data type

``` golang
// Just declare variable
var student map[string]string
var champion map[int]string

// OR 
student2 := map[string]string{}
champion2 := map[int]string{}

// map[datatype_key]datatype_value
```
the value can assign as map to, so you can write
``` golang
var student map[string]map[string]string
```
in PHP is equal with
``` php
$student = [
    "key" => []
]
```
## Assign data to map
To assign data to map just write like below
``` golang
student := map[string]string{
	"name"    : "Shellrean",
	"address" : "Jakarta",
}
```
don't forget to add comma (,) at last map item or you cant get error compiler.

## Accessing data map
You can use variable[key] to access data from map 
``` golang
fmt.Printf("%s", student["name"]) // Output: shellrean
```

Map is iterable type so you can make loop.
``` golang
for key, value := range student {
  fmt.Printf("%s => %s\n", key, value)
}
```

One thing that you have to remember is map is unorderable so maybe property name at second or address at first in map order.

## Deleting data from map
Delete map is simple use delete function 
``` golang
delete(student, "name")
// delete(map_name, key)
```

Yeah Go is beautiful language, I was used Java, C++, PHP, JavaScript, Dart. Each language have their benefit and have their strong use in. Go is Strong Typing but have interface{} data type for dynamic data type like use in dart language.

Don't stop to learn
[Tutorial] State-of-the-art NLP  with single line of code 🤗
Tags: deeplearning, nlp, python, machinelearning
Published: 2020-12-04 09:59:28

In the past deep learning has become very easy for common people to use and train; with just a few lines of code you can teach a computer to differentiate between cat and dog photos.

After the introduction of transformers, deep learning models are achieving state of the art results at most of the Natural Language processing tasks, and with Huggingface's 🤗 Pypi library `transformers` you can now use these deep learning models with a few line of codes.


Below jupyter notebook has the instructions for it -
[Jupyter Notebook](https://colab.research.google.com/github/huggingface/transformers/blob/master/notebooks/03-pipelines.ipynb)

### My first reaction to it.
#### Sentiment Analysis
```
>>> from transformers import pipeline
>>> s = pipeline("sentiment-analysis")
>>> s("Obama is not a bad person")
[{'label': 'POSITIVE', 'score': 0.9990673065185547}]
```
 A tradition model that works on Bag-of-Words would look at the word `bad` and say the statement is Negative, but this model can understand the meaning of `not a bad`.


#### Text Generation
```
>>> g = pipeline("text-generation")
>>> result  = g("How frustrating it is trying to organize your work using")
>>> print(result[0]['generated_text'])
How frustrating it is trying to organize your work using a calendar

If your plan is to use any calendar at all, you might have one or more of those issues which you can add to your calendar. You can use your calendar to organize activities
>>>
```

Although this just generates random text, you can add more context in the initial sentence and it is much better than hidden markov chain model.

This can be used for writing articles, captions for your social media posts etc.

#### Summarization
I summarized first 3 paragraphs of [this](https://dev.to/techmagic/how-to-design-a-scalable-serverless-application-on-aws-4k9j) dev.to article and this was the output
```
Auto-scaling instances are supposed to handle traffic fluctuation regardless of the number of users and requests.

The unnecessary resources should be eliminated, and the required ones should be triggered following the demand.

Amazon Auto Scaling solves the problem by automatically keeping the currently important instances active and removing the ones that are no longer needed
```

I can save so much of my time now, summarizing Youtube video's subtitle, and articles in my daily news feed.



### Thank you for reading
There is a lot you can do with this library, I'll be writing some tutorials on this in near future, follow me for updates.
Importance Of Online Business Presence In 2021
Published: 2020-12-04 09:59:00

The year 2020 has been full of surprises and unpredictability. Who knew we would be hit by a pandemic in our lifetimes! Covid-19 has caused a lot of stir in our lives. Apart from making us confined to our homes for months, it has harmed economy big time and caused numerous businesses to shut down.

**Drastic Times Call For Drastic Measures!**
When life throws something unexpected at your face, especially if it is pandemic, you need to adapt accordingly and evolve. Similarly, businesses were forced to renew their outdated strategic planning that would have worked in the per-COVID era and come up with a plan of action relevant to the current circumstance to sustain themselves.

**Need For Your Digital Debut**
Online businesses had already been gaining momentum, however, with mandatory social distance, they have been flourishing at a rapid pace. You need to take your business operations online to stay relevant with your customers if you haven't already! Hire the top website designing company in Delhi to give a fitting online representation to your brand and let your potential customers discover your business online.

**Here is a list of reasons why your business should have a digital presence.**

Everything is going to be online. IT revolution is going head-on and there is no going back. In 2021, people expect businesses to be online for both convenience and safety and traditional businesses cannot avoid this move for long.

COVID-19 calls for it. Being hit by COVID-19, your current customers are looking for businesses that have online stores to get home delivery. If you want to retain them, then, your business needs to be online. 

Increased customer outreach. The Internet knows no bounds. Your business will be available online 24 x 7 with many of your prospective customers flooding your inbox with queries and orders.

Being online is the definite move your business should be making. Collaborate with CyberWorx Technologies, the best Web Designing Company in Delhi to get your business website designed and scale up your revenue even in these trying times.


[**CyberWorx Technologies**](https://www.cyberworx.in/) is a leading web development company in Delhi that designs bespoke, robust websites with flawless development and has helped numerous businesses make their digital debut. If you are still on a fence about getting online, let me help you in gaining some clarity.