teleren/devto huggingface dataset:
Truthy and Falsy values in JS
Tags: javascript, webdev, codenewbie, beginners
Published: 2020-07-29 21:23:23

"Every value in JavaScript has an inherent boolean value. When that value is evaluated in the context of a boolean expression, the value will be transformed into that inherent boolean value."
The paragraph above is pretty dense with information. You should probably re-read it again.

####Falsy values
A value is **falsy** if it converts to `false` when evaluated in a boolean context. For example, an empty String `""` is falsy because, `""` evaluates to `false`. You already know if...else statements, so let's use them to test the truthy-ness of `""`.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/d3tnu0kwk28ldk4czv10.png)

####Here’s the list of all of the falsy values:
1. Boolean value `false`
2. number `0`
3. number negative `-0`
4. BigInt `0n`
5. empty string `""`
6. `null` type
7. `undefined` type
8. `NaN`(stands for **Not a Number**).


There are `eight` falsy values in all of JavaScript! [MDN](https://developer.mozilla.org/en-US/docs/Glossary/Falsy)
_(at the time of writing this article)_

####Truthy values
A value is **truthy** if it converts to `true` when evaluated in a boolean context. For example, the number `1` is truthy because, `1` evaluates to `true`. Let's use an if...else statement again to test this out:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/gupijaq2kqs48sd0j3y8.png)

Here are some other examples of truthy values:
* true
* 42
* "pizza"
* "0"
* "null"
* "undefined"
* {}
* []

Simply put: if it's not in the list of `falsy` values, then it's `truthy`.

Be a little extra careful when working with the same element value but different element type. For example, `0` is a number while `"0"` is a string. Similarly `null` is different(falsy) from string `"null"`(truthy) and `undefined`(falsy) is different from string `"undefined"`(truthy)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/xjl0hjg5lvkfdc5qi9v2.png)

####Comparison operator
Even though as mentioned above that `[]` is a truthy value but behaves differently when used in conjunction with a comparison operator like `==`, it evaluates to false. Likewise `null` is a falsy, but when used with a `==` operator evaluates to true. Similary for `undefined` and `NaN`.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/fvddiv5tbf34bevs3law.png)

That's all there is to this topic. For some people truthy & falsy values might be not of a big deal, but knowing how they behave can save you some real time instead of just scratching your head.Let me know if you guys have any questions. Happy Learning..
Type-safe routing with Typescript and Route Maps
Tags: javascript, webdev, typescript
Published: 2020-07-29 21:03:28

Routing in web apps can be a subtle, but persistent source of bugs. You think you've updated every reference to a route you're changing, and **BAM**. You've caused a bug in some unrelated part of your app.

This gets worse when you need to add path parameters (`/user/:id/edit`) and search parameters (`/auth?redirectPath=somewhere`). Usually, this leads to a ton of string concatenation clogging up your code, and a mess of routes that are hard to maintain.

That's why I built `make-route-map`, an [npm package](https://www.npmjs.com/package/make-route-map) which helps get your routing under control. It's 100% Typescript, and it lets you create a gorgeous, clean API for your routing which has type-safe routes, path parameters and search parameters.

I can't tell you how much stress it's saved me already. Refactoring or removing a route no longer takes dozens of find-in-files to remove the references. All that stress is Typescripted away.

## The Basics

```js
import { makeRouteMap } from 'make-route-map';
 
const routeMap = makeRouteMap({
  users: {
    path: '/users',
  },
  editUser: {
    path: '/users/:id/edit',
    params: {
      id: true,
    },
  },
  auth: {
    path: '/auth',
    search: {
      redirectPath: true,
    },
  },
});
 
console.log(routeMap.users());
// '/users'

console.log(routeMap.editUser({ params: { id: '240' } });
// '/users/240/edit'

console.log(
  routeMap.auth({
    search: { redirectPath: 'somewhere' },
  }),
);
// /auth?redirectPath=somewhere

```

The `makeRouteMap` function just creates a set of helpers which pull out the routes. You can pass in path parameters and search parameters.

## Navigating

`makeNavigate` can take in a `routeMap` and a function to send you to a route, and will navigate you there when it's called.

```js
const goToRoute = route => {
  window.location.href = route;
};
 
const navigate = makeNavigate(routeMap, goToRoute);
 
// This would take the user to '/users/240/edit'
navigate.editUser({
  params: {
    id: '240',
  },
});
```

This means you can plug in navigate into your current navigation implementation, like `history.push`.

## Try it out

[The repo](https://github.com/mattpocock/make-route-map)
[The package](https://www.npmjs.com/package/make-route-map)

Let me know how you get on, and if you have any requests for the API. I'm so excited to have a pattern that's been working wonders for us public available.
How to Iterate Through A List of Objects with Terraform's for_each function
Published: 2020-09-27 16:09:53

---
title: How to Iterate Through A List of Objects with Terraform's for_each function
published: true
date: 2020-07-29 21:00:00 UTC
tags: 
canonical_url: https://www.sheldonhull.com/how-to-iterate-through-a-list-of-objects-with-terraforms-for-each-function/
---

## What I want to do

```
# create file local.users.yml
user:
 - name: foobar1
 email: foobar1@foobar.com
 - name: foobar2
 email: foobar2@foobar.com
 - name: foobar3
 email: foobar3@foobar.com


locals {
 users_file = "local.users.yml"
 users_file_content = fileexists(local.users_file) ? file(local.users_file) : "NoSettingsFileFound: true"
 users_config = yamldecode(local.users_file_content)
}

```

What I want to work:

```
resource "something" {
for_each local.users_config
name = each.key # or even each.value.name
email = each.value.email
}

```

## What I’ve had to do

Now to iterate through this collection, I’ve had challenges, as the only way I’ve gotten this to work would be to ensure there was a designated key in the `yaml` structure.This provides a map object with a key/value format, instead of a collection of normal objects.

This would result in a yaml format like:

```
user:
 - 'foobar1':
 name: foobar1
 email: foobar1@foobar.com
 - 'foobar2':
 name: foobar2
 email: foobar2@foobar.com
 - 'foobar3':
 name: foobar3
 email: foobar3@foobar.com

```

This provides the “key” for each entry, allowing Terraform’s engine to correctly identify the unique entry.This is important, as without a unique key to determine the resource a plan couldn’t run in a deterministic manner by comparing correctly the previously created resource against the prospective plan.

## Another Way Using Expressions

Iterating through a map has been the main way I’ve handled this, I finally ironed out how to use expressions with Terraform to allow an object list to be the source of a `for_each` operation.This makes feeding Terraform plans from `yaml` or other input much easier to work with.

Most of the examples I’ve seen confused the issue by focusing on very complex flattening or other steps.From this stack overflow answer, I experimented and finally got my expression to work with only a single line.

```
resource "foobar" "this" {
 for_each = {for user in local.users_config.users: user.name => user}
 name = each.key
 email = each.value.email
}

```

This results in a simple yaml object list being correctly turned into something Terraform can work with, as it defines the unique key in the expression.
How to create a BMI calculator with Xamarin Forms.
Tags: csharp, xamarinforms
Published: 2020-07-29 20:53:54

{% youtube 91rJLa65p-E %}

Learn how to create a body mass index calculator using Xamarin Forms and C#.

More tutorials to come in the future.

Follow me on [Github](https://github.com/estyval)

Follow me on [Linkedin](https://www.linkedin.com/in/patrick-tshibanda-431017135/)
How to convert objects into arrays in Javascript
Tags: javascript, react, tutorial, beginners
Published: 2020-07-29 20:42:04

Gone are the days when transforming Javascript `objects` into `arrays` required complex logic. Starting with E2017(ES8), we can do just that pretty easily. Depending on our needs, we can convert an object into an array containing the `keys`, the `values` or the whole `key-value` pairs. Let's see how this works. We are going to use the `Object` class and some specific static methods found on this class. These are: `Object.keys()`, `Object.values()` and `Object.entries()`.

```javascript
// We have an object
const pairs = {
  Key1: "value1",
  Key2: "value2",
  Key3: "value3"
}

// Converting the object into an array holding the keys
const arrayOfKeys = Object.keys(pairs);
console.log(arrayOfKeys);// prints [Key1, Key2, Key3]

// Converting the object into an array holding the values
const arrayOfValues = Object.values(pairs);
console.log(arrayOfValues);// prints [value1, value2, value3]

// Converting the object into an array holding the key-value pairs
const arrayOfCompleteEntries = Object.entries(pairs);
console.log(arrayOfCompleteEntries);// prints [[Key1, value1], [Key2, value2], [Key3, value3]];
```
As we can see, in the last example where we are extracting the `key-value` pairs we end up with an array of arrays. If we want to work with each `key` or `value` from the original object, we can use `forEach` to loop through every `sub-array`:

```javascript
arrayOfCompleteEntries.forEach(([key, value]) => {
  console.log(key);
  console.log(value);
})

// prints 
Key1
value1
Key2
value2
Key3
value3
```

If for some reason we want to convert the newly created array back into an object, we can do that very easily like this:

```javascript
const backToObject = Object.fromEntries(arrayOfCompleteEntries);
console.log(backToObject);

// prints
{
Key1:"value1",
Key2:"value2",
Key3:"value3"
}
```
*Image source: Adeolu Eletu/ @adeolueletu on Unsplash*
ASOeShop
Tags: appmarketing, appmarketingservices, asoservices
Published: 2020-07-29 20:39:59

<a href="https://www.asoeshop.com">ASOeShop</a> is a Mobile Ad Network with an automated self-serve advertising platform for advertisers willing to promote and rank their Android & iOS apps for potential Keywords. If you have Android or iOS apps and you are looking to increase the visibility of your app then you can get Keyword Installs, App Installs, App Reviews, App Ratings. We also have a dedicated tool i.e Spy Keywords - Keyword Research Tool at our platform.
We support a variety of pricing models and you can promote your Mobile Apps on CPC, CPI, CPV, CPA... etc Basis.

Our services are trusted by thousands of app owners whose ROI increased due to our partnership.

Our Main Advantages (Overview):
•	We have an Automated Self-Serve Dashboard and you can start your campaign in a few minutes
•	We offer a Powerful dashboard and you would get statistics and detailed reports.
•	We have campaigns that are very cost-effective as low as $0.08 per review
•	You will get both iOS and Android services on the same dashboard.

Our Services:
•	App Keyword Installs – For Both iOS and Android.
•	App Installs – For Both iOS and Android.
•	App Ratings – For Both iOS and Android.
•	App Reviews – For Both iOS and Android.

Our USP (Unique Selling Points):
•	100% Real Services from Real Users/Devices – Fraud Detection, don’t pay for Fake/Bot Installs
•	Cost-effective Services – Starts at just $0.08 per review.
•	iOS and Android both Supported – Manage both OS from a single dashboard.
•	Easy & Quick Results - It takes a few days or weeks depending on traffic & competition to see the result.
•	24/7 Customer Support - You may reach the support team any time and get answers to your questions.
•	Boost Keyword Ranking - Rank your app Top for any keyword, country with our proprietary technology.
•	No SDK Required - Choose package or keyword installs and you are ready to go.
•	Affordable Price - We're proud to boast that our ASO Services are affordable & suit everyone's needs.

Campaign Types (Overview):
•	Package (High Retention) - Install + Open + Keep for 3-8 Days
•	Package (+Rate) - Install + Rate
•	Package (+Rate +Review) - Install + Rate + Review
•	Keyword (High Retention) - Search + Install + Open + Keep for 3-8 Days
•	Keyword (+Rate) - Search + Install + Rate
•	Keyword (+Rate +Review) - Search + Install + Rate + Review.

Ready to Get Started?
Register your FREE Account Now - https://asoeshop.com/register.php
Dev Life: Honest development struggle of mine.
Published: 2020-07-29 20:31:05

I'm not sure how to start this post but the main point that I want to get to is the fact that Me as a web developer I struggling with keeping up to that with all new technologies that popup up around development JavaScript apps.

There are times when I feel pretty confident about starting a project and then right before I start working on it I start with searching for the new greatest, best tech stack for it,  so I can at the same time learn new technology and have a product at the end.

And this never ends well. You end up stuck with some tutorial where you can't replicate the example that the tutorial mentor did, or you just end up more confused.

Also, some docs of these new technologies are never complete and they don't offer enough real-world examples - don't get me wrong they have working examples but they are just not applicable in a real-world application. 

And yes I know what you might be thinking "you need to work your way up" - yes but before I start I feel that imposter syndrome kicking and I get that feeling that I might not be good enough and I feel stupid even that I have 5+ year experience in web dev.

Whatever the scenario development it's not easy, as that is projected from more experienced devs on us. For example when you watch a tutorial on something and you see that dev writing like insane and everything is working just as intended, and there is no thinking on how to approach some given problem they just do it - when in reality they have practiced that before and they just executed that on video and you end up frustrated.  😅

It takes time to learn and get comfortable with new technology and then start using it with confidence.

And this is a never-ending cycle - I don't mind if - I have patience, but when I realize that it can take me for example 3 days to set up a production-ready project (not just with create react app) with workflows and what not it annoys me.

So I've decided to update my website and then I will set up production-ready starters/boilerplate projects with most common technologies that I think will need in the future, so I don't need to waste time setting up projects  from the start, because all of them are pretty much the same you need authentication, authorization, routing, some basic styles, maybe social login,

And I'm sorry for this depressing log 😃 but this is just a reality of mine and I just wanted to share it.
Save time and disk space for node projects
Tags: npm, node, pnpm
Published: 2020-07-29 20:20:37

---
title: Save time and disk space for node projects
published: true
description: 
tags: npm, node, pnpm
//cover_image: https://direct_url_to_image.jpg
---

Do you like saving time, and precious disk space when working on npm projects? If the answer is yes, then this post is for you.

Recently I have been learning electron, and react-electron. One huge problem when setting up these types of projects is the overhead of setting up a few files, and then waiting for tons of package installs. If you don't believe try this template https://github.com/electron-react-boilerplate/electron-react-boilerplate. Check your disk size prior to `npm install`, and afterwards. Also time how long it takes.

- Original size after git clone 4MB
- yarn (30seconds, I had to install yarn, above repo is really picky about npm)
- 635MB size after installing packages

## PNPM for installing packages

If you don't know about pnpm, it has a global store, then when you do `pnpm install lodash` it creates a linked directory in `node_modules`, but the package is not re-downloaded thirty million times. Only once, and then later on when you want to update it.

https://pnpm.js.org/

That along will save you tons of space, but wait there is more. 

## Creating projects with a shell function

On my `~/git` directory, I have two templates I use quite often. 

- electron-app-template
- cra-electron-template

You can make any project you'd like, set it up how you want it. Make sure it runs on dev, production, build, etc. When you are happy with your template, add a function to bash or in my case fish:

Fish create-electron-app.fish inside `~/.config/fish/functions`

```
function create-electron-app --argument dir
    mkdir $dir
    cp -RT ~/git/electron-template $dir
end
```

From the command line I can run the following to create a new project in a split second:

```
$ create-electron-app fab-project
```

Bash (Create this function whatever you put your functions):

```
create-electron-app(){
	mkdir $1
    cp -RT ~/git/electron-template $1
}
```

I hope you enjoyed this post, and let me know what other saving time, and disk space you have in your repertoire. Thanks for reading!
Things you may not know GitHub offers
Tags: github, learning
Published: 2020-07-29 20:02:00

# What do you think of when you hear the name GitHub? 

Not that long ago, I thought of one thing only - version control.

Now, I would think its pretty likely that this may be all that you think of when you hear GitHub too. 

And that's ok! 

GitHub does version control incredibly well, and for a lot of people GitHub is the only version control service they have ever used. 

And like I mentioned above, until recently I also had this viewpoint. 

## So what's changed?

Well, quite a few things have changed. 

First of all, on 29th May 2020 I became a GitHub Campus Expert. This has given me more of a reason to explore what GitHub has to offer.

Secondly, I became the web editor of my college at university, and subsequently had the ability to create a web committee that needs managing.

Finally, Covid happened, and there was a sudden need to have all my team organisation online. 

## What have I found?

- [Organisations](https://github.com/team) - Great for managing a team, provides communication, centralised repo ownership, kanban boards
- [The Explore tab](https://github.com/explore) - Helps you discover new and interesting repos from other users
- [The Blog](https://github.blog) - Interesting posts from the GH team 
- [Actions](https://github.com/features/actions) - for CI/CD
- [Online Learning Labs](https://lab.github.com) - amazing learning resources 
- [Campus Expert Program](https://education.github.com/students/experts) - I couldn't not plug this amazing scheme :laughing:
- [The Student Developer Pack](https://education.github.com/pack) - A must for any students

Of course, there are many other things GitHub has to offer, but these are the ones I have found the most interesting/useful so far.
### Is there anything you think I've missed? Leave it in the comments :grinning:
Google Search for Datasets
Tags: datascience, dataset, todayilearned, google
Published: 2020-07-29 20:01:20

---
description: "A colleague of mine showed me something today: a search engine 🔍 that returns a list of datasets 📚 available on the web!"
---

# 🔧 There's a tool for everything nowadays

A colleague of mine showed something to me today that I had never come across before and I was impressed 👍:

> ## ***[Google Dataset Search](https://datasetsearch.research.google.com) 🔍***

A search engine (powered by Google, who aren't too bad at that search thing) that returns results back as a semi-curated list of **datasets 📚** available on the web, regardless of where they are hosted!

*(It's been around for [quite a while](https://blog.google/products/search/discovering-millions-datasets-web/) now too!)*

## 🤷‍♂️ So what? 

One of the biggest problems with both learning and understanding topics like machine learning and big data analytics is getting access to large datasets.

Lots of sites (such as [Kaggle](https://kaggle.com)) have made awesome inroads into making datasets more accessible but they can't possibly host everything.

**And that's where properly indexing and search can help.**

Google has a good history in making popular search engines. But it's the approach behind dataset search that I'm more interested in: 

*Standardisation 📋* - it's up to dataset owners to make their dataset indexable in a specific format, so it can be found more easily and more precisely.

## Give me an example! 🧐

Okay, try searching for "programming":

*https://datasetsearch.research.google.com/search?query=Programming*

![Search Results](https://dev-to-uploads.s3.amazonaws.com/i/5golqcyfithm4bwqm3j2.png)

What do we see?

* 🗂️ Three different datasets.
* 💡 Three potential project ideas.
* **🌍 Three different data sources**.

It's that last one that works for me - I don't need to go through curated lists of data set sources or validate the security of a dataset found in a Reddit post. **I can just search.**

## Let me know what you think!

* Have you used dataset search?
* Where do you get your datasets?
* What do you use public datasets for?

---
🧡 Tom Anderson
[www.thomas-anderson.net](https://www.thomas-anderson.net/?utm_source=devto)
*Liked something I did and want to help me out?*
[![Buy me a coffee](https://img.shields.io/badge/Buy%20me%20a%20coffee-orange?logo=Buy%20Me%20A%20Coffee&logoColor=white)](https://www.buymeacoffee.com/ndsn)
Type vs Interface in Typescript 
Tags: typescript, javascript
Published: 2020-07-29 20:00:39

Typescript offers two ways to define types. Either Type-Aliases or Interfaces. The choice of which to use depends on the complexity of the type you want to define.

For most cases, a Type-Alias would get the job done. Most things offered by interfaces are also available in the Type-Alias API. Let's see an example

## Extending types
With interfaces, you could do this
```ts
interface Human {
  height: number,
  age: number,
  name: string
}

interface Woman extends Human {
  canConcieve: boolean
}
```
Applying the same logic using Type-Aliases would be
```ts
type Human = {
  height: number,
  age: number,
  hairColor: string
}

type Woman = {
  canConcieve: boolean
}

const Chisom: Human & Woman = {
  height: 1.5,
  age: 20,
  hairColor: 'brown',
  canConcieve: true
} 
```
People who prefer functional-style programming to Object-Oriented Programming may find Type-Aliases to be a better approach. Loosely defined types that can be combined.