teleren/devto huggingface dataset:
Rest Parameters in TypeScript
Tags: typescript, rest, ts
Published: 2020-03-24 13:52:50

TypeScript introduced rest parameters to accommodate n number of parameters easily.

When the number of parameters that a function will receive is not known or can vary, we can use rest parameters. In JavaScript, this is achieved with the "arguments" variable. However, with TypeScript, we can use the rest parameter denoted by ellipsis `...`

We can pass zero or more arguments to the rest parameter. The compiler will create an array of arguments with the rest parameter name provided by us.

```typescript
function Greet(greeting: string, ...names: string[]) {
    return greeting + " " + names.join(", ") + "!";
}

Greet("Hello", "Steve", "Bill"); // returns "Hello Steve, Bill!"

Greet("Hello");// returns "Hello !"
```

In the above example, we have a function with two parameters: `greeting` and `names`. Here, `names` is a rest parameter denoted by ellipses `...`. While calling the function, we first pass "Steve", "Bill" as the rest parameters. These are combined into a string array by joining the elements of the `names` array. Hence, it returns "Hello Steve, Bill!". During the second function call, we do not pass any arguments as the rest parameters. This is accepted by the compiler and hence the output is "Hello !"

The rest parameters can be used in functions, arrow functions or classes.

```typescript
let Greet = (greeting: string, ...names: string[]) => {
    return greeting + " " + names.join(", ") + "!";
}

Greet("Hello", "Steve", "Bill"); // returns "Hello Steve, Bill!"

Greet("Hello");// returns "Hello !"
```

Remember, rest parameters must come last in the function definition, otherwise, the TypeScript compiler will show an error. The following is not valid.

```typescript
function Greet(...names: string[], greeting: string) {  // Compiler Error
    return greeting + " " + names.join(", ") + "!";
}
```
Readonly properties in TypeScript
Tags: typescript, readonly, ts
Published: 2020-03-24 13:48:46

TypeScript introduced the keyword `readonly`, which makes a property as read-only in the class, type or interface.

Prefix `readonly` is used to make a property as read-only. Read-only members can be accessed outside the class, but their value cannot be changed. Since read-only members cannot be changed outside the class, they either need to be initialized at the declaration or initialized inside the class constructor.

```typescript
class Employee {
    readonly empCode: number;
    empName: string;
    
    constructor(code: number, name: string)     {
        this.empCode = code;
        this.empName = name;
    }
}
let emp = new Employee(10, "John");
emp.empCode = 20; //Compiler Error
emp.empName = 'Bill'; //Compiler Error
```

In the above example, we have the `Employee` class with two properties- `empName` and `empCode`. Since `empCode` is read only, it can be initialized at the time of declaration or in the constructor.

If we try to change the value of `empCode` after the object has been initialized, the compiler shows the following compilation error:

> error TS2540: Cannot assign to empCode' because it is a constant or a read-only property.

An interface can also have `readonly` member properties.

```typescript
interface IEmployee {
    readonly empCode: number;
    empName: string;
}

let empObj:IEmployee = {
    empCode:1,
    empName:"Steve"
}

empObj.empCode = 100; // Compiler Error: Cannot change readonly 'empCode'
```

As you can see above, `empCode` is `readonly`, so we can assign a value at the time of creating an object but not afterward.

In the same way, you can use `Readonly<T>` to create a `readonly` type, as shown below.

```typescript
interface IEmployee {
    empCode: number;
    empName: string;
}

let emp1: Readonly<IEmployee> = {
    empCode:1,
    empName:"Steve"
}

emp1.empCode = 100; // Compiler Error: Cannot change readonly 'empCode'
emp1.empName = 'Bill'; // Compiler Error: Cannot change readonly 'empName'

let emp2: IEmployee = {
    empCode:1,
    empName:"Steve"
}

emp2.empCode = 100; // OK
emp2.empName = 'Bill'; // OK
```

In the above example, `emp1` is declared as `Readonly<IEmployee>` and so values cannot be changed once initialized.
Pencil.js quick-start
Tags: javascript, showdev, webdev, opensource
Published: 2020-03-24 13:24:45

I recently spent some time putting together a new way to discover the [Pencil.js library](https://pencil.js.org/). In 9 steps, I show how to create this nice interactive scene form scratch.

{% codepen https://codepen.io/GMartigny/pen/dyoKGoP %}

Go check it out on [the Pencil.js website](https://pencil.js.org/quick-start/).

It was a fun exercise to find the most straightforwards way to present a handful of modules. I also tried to keep it short in order to not make it boring.

I really hope you like it and this help new people discover all Pencil.js can offer. If you followed the tutorial to the end, I would love to hear what you think about it.

Peace 😎
Blogger needed
Tags: webdev, javascript
Published: 2020-03-24 13:19:57

Hey 

I am reaching out to the wider developer community.  I am looking for a guest blogger to write an article for my website.  I am a niche tech recruiter specialising in web/app developers.  The site is due to launch in a few days and I would like some tech focused content.  To be more specific, advice on how to work in the current climate, info on latest trends, etc.  I am more than happy to link your blog post back to your own site.  

On a side note I am trying to do recruitment in the right way... i.e. no BS, no false promises, no shady sales techniques, etc.  I have a geniune passion for tech and if I'm honest I never cut the mustard to be a developer myself  😪 .  I felt recruiting developers would be the next best thing as it keeps me closely connected to the community.  

I am based in the UK so I'm sure there are plenty of devs that will share horror stories of working with agencies over here. I am working extremely hard to change this perception... one placement at a time.  

Please be gentle with me 😬
Peacetime productivity, wartime productivity
Tags: todayilearned, career, beginners
Published: 2020-03-24 13:00:20

*TL;DR notes from articles I read today.*

### [Peacetime productivity, wartime productivity](https://bit.ly/2WztWbg)

- In business terms, in ‘peacetime’, your company has a large advantage over the competition in its core market and its market share is growing. You focus on expanding your market and reinforcing strengths.
- In ‘wartime’, your company is fending off an existential threat: competition, dramatic macroeconomic change, market changes, supply chain issues, etc.
- This distinction impacts your productivity (at an individual level) and strategy (at a team level). 
- In wartime, you may have a website down, a product malfunctioning, a furious customer or a new piece of information that requires overhauling your strategy. You either know what to do but lack time/resources, or you don’t know what to do, and are making important decisions under time pressure (hours or minutes) while being constantly ‘available’. 
- Some strategies for wartime:
    1. Star emails that need urgent responses and get to them asap.
    2. Use an incident command protocol or similar best practices.
    3. If you can help in a specific way/area, pitch in. If you don’t know where to start, start anywhere.
    4. Ignore your usual task manager app and start an essentials-only task list.
    5. Skip weekly reviews or call for an abbreviated version that is fast and focused.
    6. Leave complicated work till peacetime. Focus on controlling the chaos. 

*[Full post here](https://bit.ly/2WztWbg), 6 mins read*

--- 

### [How to discover your unknown knowns](https://bit.ly/39eULny)

- Unknown knowns are the things you don’t know you know - matters of instinct, intuition or other factors you consider too trivial to notice. 
- Ignoring unknown knowns can lead to dissonance: imposter syndrome, comprehension gaps when you use jargon or fail to provide context, and underestimating your growth curve because you ignore soft skills or trickier, smaller ‘hard skills’.
- To explore your unknown knowns, expand the implicit into explicit awareness.
- Write more about the decisions you make till you can see your seemingly simple ideas contain something more profound.
- Pursue public speaking and share what you have learned. Don’t assume what you say is too brief or basic, it needn’t even be a big event - it could be just your team and a few minutes on a ‘trivial’ topic. 
- Mentor others, show them how you analyze situations or think around an obstacle, and you will find proof that you don’t give yourself enough credit.
- Track what you learn every week or month in writing, even if it initially appears trivial. In fact, pay attention to smaller accomplishments (a new shortcut, or a strategy to write better emails).

*[Full post here](https://bit.ly/39eULny), 12 mins read*

---

*[Get these notes directly in your inbox every weekday by signing up for my newsletter, in.snippets().](https://mailchi.mp/appsmith/insnippets?utm_source=devto&utm_medium=post08&utm_campaign=is)*
Daily Developer Jokes - Tuesday, Mar 24, 2020
Tags: jokes, dailydeveloperjokes
Published: 2020-03-24 13:00:07

---
title: "Daily Developer Jokes - Tuesday, Mar 24, 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=Tuesday%2C%20Mar%2024%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/5e1259d077252.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:___ Which programming language is the shortest?

___A:___ HTML. Because it doesn't have a neck between its `<head>` and `<body>`.
 -->
The Impact of COVID-19 On Tourism Industry 
Published: 2020-03-24 12:58:05

The worldwide panic of the Corona Virus is making tourism enter a great crisis. The duration of this kind of crisis is unknown. It is obvious that the impact of COVID-19 will be unmeasurable. If we compare this situation with similar crises such as that of SARS or H1N1 it becomes clear that the impact will be unquestionable. 

This crisis will mostly affect China as tourism represents 11% of its GDP in recent years. According to the World Travel and Tourism Council (WTTC)  Closing borders, prohibiting travel in general and more extreme government policies will not stop the spread. 

It is announced by The International Air Transport Association (IATA) that global air transport revenues will be reduced by five percent this year, which means twenty-nine billion dollars less (about twenty-seven million Euros), while OPEC has lowered global demand of oil to nineteen percent, one hundred million barrels per day. 

Tourism officials say that the novel coronavirus pandemic impacts the economy. The president of the Lake Lanier Convention Stacey Dickson claims “Our hotels, attractions, retailers, and restaurants are all feeling the impact.”

“Some have had to temporarily close, lay off workers, and hope they are able to sustain their basic operational costs — rent, utilities. — until this event passes.

“Things are changing daily, sometimes hourly, we are hopeful that people will take the advisories to stay home seriously so that we can all get back to normal sooner rather than later.”

The tourism sector surely will be affected and the only thing that depends on us is the need to stay at home in order to stop the spread of COVID-19. We hope this virus will recede soon and we will be able to travel again.
COVID-19 -  A helping hand
Tags: cloud, infrastructure, credits
Published: 2020-03-24 12:33:32

We are SWAZM and during the last period we developed a decentralized cloud computing solution (https://swazm.com/)

It's tough out there, but we'll get over this together.

Being an infrastructure startup we understand how hard it is to have remote policies with your team.

We are offering:
- 200 USD per month (FREE) in infrastructure credits for at least 3 months.
- FREE help in creating DevOps/continuous integration pipelines for your existing projects

Remote, but together!

For more details, contact us following https://swazm.com/launchpad
Supporting the Developer Community – Our response to COVID-19
Tags: learning, coding, development
Published: 2020-03-26 12:12:31

---
title: Supporting the Developer Community – Our response to COVID-19
published: true
date: 2020-03-24 12:07:08 UTC
tags: learning, coding, development
canonical_url: https://www.syncfusion.com/blogs/post/supporting-the-developer-community.aspx
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/4arjhrt7yze6n5u9hsvv.jpg
---

We understand that many of you have been severely impacted by the COVID-19 crisis and will continue to feel the impact for some time to come. We want to do our part to make things a little easier for you so we have put in place four measures that we hope will bring you some relief during these extraordinary times:  

- Our [Community License](https://www.syncfusion.com/products/communitylicense) continues to be available at no cost to companies with 5 or fewer developers and less than $1M in annual revenue. 
- For those that exceed this threshold, we are offering 40% discount on any single developer Syncfusion product (valid only on a single license; for additional licenses please [contact us](https://www.syncfusion.com/company/contact-us) directly for custom pricing). Use 40% discount coupon code:  **2020MARDISCOUNT**
- If you would like to license your entire team, [contact us](https://www.syncfusion.com/company/contact-us) directly and we can work with you to meet your needs. 
- Learning new technologies will make you and your company more valuable. Take advantage of our collection of 170+ [eBooks](https://www.syncfusion.com/ebooks).  

We understand that this is but a small cog in your day-to-day lives, but it is our hope that it can provide some form of relief as you grapple with staffing and budgetary needs. 

We’ll offer this discount as long as we can and update this page as the situation progresses. 

The post [Supporting the Developer Community – Our response to COVID-19](https://www.syncfusion.com/blogs/post/supporting-the-developer-community.aspx) appeared first on [Syncfusion Blogs](https://www.syncfusion.com/blogs).
Undefinend response with axios
Tags: react, functional, help
Published: 2020-03-24 11:52:31

Hi I have a question about the following code, this code makes a rest call with axios to a server, the value returns correctly from the node.js server, that is, if I test the call with postman I have a response with the integer value however in this case the value is undefined what is it due to?  

 axios.post(apiBaseUrl+'/utente/login', payload,header).then(function (response) {
     
     console.log("\n Valore di response.data:"+response.data); //Undefinend?

     
    }
What is Version Control System?
Tags: git, githunt, beginners, github
Published: 2020-03-24 11:37:07

## Version Control System

Version Control System's are the software which is continuously seeing in your code and whenever you made a single change in your code they report it and took a snapshot and save it in their memory.
So the basic work of VCS(version control system) is the management of our code over time. 
VCS keeps track of each modification you made it in your code. If you want to revert back in the code.
+ example
  + If you add some code in your project and that code gives you an error in 
your project and you need to go back to the previous position so you can 
compare your code with the help of VCS so that you will know what you 
add and delete in your project and revert back to the previous position.

## USES 
+ VCS protects your source code from unattended access in your projects. 
+ VCS helps developers to work simultaneously on the same project. If VCS is not there then it is almost impossible to collaborate on the same project until and unless the person is sitting next to you.
+ VCS follows a tree data structure so the software made one node per participant and the changes made by the participant goes downside of the participant node as a child node that will help us to track the changes made by each participant in the project.
+ VCS take backups of our project if by chance we delete anything which is mandatory to run our project so we can download or pull that from the repository(project folder on the server of VCS).


## Top 10 Version Control System

1. Git
2. GitLab
3. BeanStalk
4. PerForce
5. Apache Subversion
6. AWS CodeCommit
7. Microsoft Team Foundation Server
8. Mercurial
9. CVS Version Control (Concurrent Versions System)
10. BitBukcet

Each has its own advantages and disadvantages but the most preferred by the community is Git.

## How to install Git?

Follow the instruction [here](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
Joke of the year / Century
Tags: jokes
Published: 2020-03-24 11:25:26


Dear God, 
Could we please uninstall 2020 and re-install it????  It has a virus!!!

Guys, If you're quarantined or have time to join a open source project on Human Race Health (OSINT-HRH) Please let me know at manishfoodtechs@gmail.com

A raw wiki is here:
https://github.com/Manishfoodtechs/OSINTHRH/wiki
Call me maybe - an explanations of Python callables
Tags: python
Published: 2020-03-24 11:24:45

If you have some experience with Python, you must have already seen a `TypeError: 'T' object is not callable`.

In this article we will try to demystify this kind of errors.

# What is a callable?

A `callable` is anything that can be called, from a function, to a class constructor.

For example, `len` is a callable because we can write `len(object)`.

# Creating a callable

The easiest way is to write a function or a lambda:

```python
def foo(*args):
    pass

bar = lambda *args: 0
```

But here we won't cover those things as they are basic Python knowledge.

```python
class Foo:
    def __call__(self, *args):
        print("hello world!")

bar = Foo()  # instanciating a Foo object, creating a callable
bar()  # calling it!
```

We created a basic callable by giving it a `__call__` method, and we can check if an object is callable (useful when debugging) by using:

```python
# homemade method to explain EAFP
def is_callable(obj, *args, **kwargs, ***okwargs):
    try:
        obj(*args, **kwargs, ***okwargs)
    except TypeError as e:
        return 'object is not callable' not in str(e)
    return True

# built-in way to check if an object is callable (thanks rhymes for pointing it out): using callable(obj)
>>> callable(foo), callable(bar), callable(Foo), callable(Foo()), callable(3)
(True, True, True, True, False)
```

Because we can't use `hasattr(obj, '__call__')`, since Python is skipping `__getattribute__` and `__getattr__` when *calling* something, thus we can only do what's called **EAFP**: **E**asier to **a**sk for **f**orgiveness than **p**ermission.

------

Hopefully this article has helped you, if you have anything to add feel free to leave a comment!
Singleton in Python
Tags: python
Published: 2020-03-24 11:21:58

This will be the easiest of all creational patterns. The concept is to create an instance of a class only once (regardless of how many times we call the class) and use that instance whenever we want. Let’s implement is fast on Python —

```python
class SingletonMeta(type):

    _instance = None

    def __call__(self):
        if self._instance is None:
            self._instance = super().__call__()
        return self._instance


class Singleton(metaclass=SingletonMeta):
    # Now implement your singleton class
    def some_business_logic(self):
        pass


if __name__ == "__main__":

    s1 = Singleton()
    s2 = Singleton()

    # You can check they are both same instance
    assert(id(s1) == id(s2))
```


This is so easy! We made a metaclass `SingletonMeta` and then use that to build our class `Singleton` . Ok, now the question may arise "**What is a metaclass?**". The answer is really simple, "**Metaclasses are the 'stuff' that creates classes**". In Python, everything is object, right? So metaclasses are the classes that are used to create these objects. [Here](https://stackoverflow.com/questions/100003/what-are-metaclasses-in-python/6581949#6581949) is an elaborate answer about metaclass.

In our case, our `SingletonMeta` class is the creator of our `Singleton` class. And in this metaclass, we can define custom logic on how a class should behave or what it will be its property. In `SingletonMeta` class, we took an `_instance` and every time the class get `__call__` to initiate itself, it tries to find the `_instance` , if not yet instantiated, creates the instance of the class and save it to `_instance`. So in the runtime, when it gets called again, it supplies the same instance.

Now the question may arise "**Why would we need such a pattern?**". Well, the easiest example can be a REST/RPC client. In web applications, we need to call other services/API's. So we make a client that normally does the communication and returns the result to us. This client can be used in several places in the same application, do we really need to make this same instance every time, to make a call? Here we can use the singleton. Also, the DB client, are we creating the client every time when we need some data from DB? Rather make a client when the application starts and use that connection to call DB. In case of concurrency, DB calls may use a connection pool to support parallel communication, but that's a very different topic for now.

Hope this helps you :)
How to use Ant Design’s Icons in Your React Application
Tags: antd, antdicon, antdesignicon, react
Published: 2020-03-24 11:15:33

---
title: How to use Ant Design’s Icons in Your React Application
published: true
description: 
tags: antd, antd icon, ant design icon, react js
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/lmi416oeu9je8vi3dhb1.jpg
---

Ant Design is an amazing React UI library of flexible high-quality reusable components. However, if you’re not familiar with the library trying to use the icons in a react application can take you a minute or two to figure out.

So here’s what I figured out.

To include ant’s design Icon’s in your application, first, you need to have installed the library using 

                 `npm install antd` or `yarn add antd`

Once you’ve installed the library, you also need to install this 

                   `npm install @ant-design/icons`
Once this is installed successfully, you’ll have access to the library icons

On the library documentation, you can find the list of applications available to you here. You can find icons in three categories, outlined, filled and two-toned.
You select an Icon you wish to use copy and include it in your code but you need to also import the icons into code where you want to use it.
you can import the code by using this 

       `import { CaretDownFilled } from '@ant-design/icons'` 

you can now use this icon as a component changing the colour as you wish or two colours if you chose a two-toned icon, e.t.c.

![Sample code snippet using an icon component](https://dev-to-uploads.s3.amazonaws.com/i/lixtf7o8tqwz0tukq5y8.png)
*Here's an example of how I used the caret-down icon*

The library's documentation provides information on properties that you can use with the icons and is easy to read and understand. Hope you found this article useful. Leave a comment if you wish to. Cheers!!!