teleren/devto huggingface dataset:
Saving unique data in firebase using sub-collection
Tags: dart, flutter, firebase
Published: 2020-10-23 13:12:43

###In this post i will tell you how you can save unique data for each user which can be saved only once a day. 

So i had this requirement where user wants to save their data but only once a day. If user tries to save the data again, they will get an error saying 'You can only save data once per day'. The meaning of doing this was so that we can get the average data of a week or a month and then display it as a graph for the user. 

There are often user scenarios where you don't want to overwrite the data and need to set some business rule around how often the user can log the data or not. 

The key is in the hierarchy of the data and how that is structured.

So let's say just for the sake of argument the user wants to log when they get to work in the morning and once this is logged, it should not be edited.

It is very easy, first of all you have to create a collection, say 'arrival'. Then you have to give its document id, in my case the document id is the uid of the current user who is logged in.

``` 
 _firestore
                        .collection('arrival')
                        .doc(_auth.currentUser.uid)
                        .collection('userarrival')
                        .doc(current1)
```

in above code, `_auth.currentUser.uid` is giving me the unique id of each user as doc id. Then i have created a sub-collection named 'userarrival'. And then for its document-id i am giving the current date in the format(YYYY-MM-DD).

So whenever user enters data on a new day it will be added in the cloud firestore. For checking if data document already exists in the database, i am checking it with a method which returns a bool.
```
Future<bool> checkIfDocExists(id) async {
    try {
      var collectionRef = _firestore
          .collection('arrival')
          .doc(_auth.currentUser.uid)
          .collection('userarrival');
      var doc = await collectionRef.doc(id).get();
      return doc.exists;
    } catch (e) {
      throw e;
    }
  }
```
So in the above code, i am giving id as current date in the format(YYYY-MM-DD), it will check if todays date document is already present or not. If exists, it will return true, else false.
and if document is present, it will give an error using `showDialog()` in flutter. Else, add the data in the database.
```
_firestore
                        .collection('arrival')
                        .doc(_auth.currentUser.uid)
                        .collection('userarrival')
                        .doc(current1)
                        .set({
                      //data
                    });
                    Navigator.pop(context);
                    print('pain value saved in db');
                  }
```

Thats, it. Thats all you have to do to save unique user data for each day.
UI & product design for a blockchain platform
Tags: uiweekly, blockchain, startup, design
Published: 2020-10-23 13:07:19

Tardix is a blockchain platform built for the next generation of traders and investors. Its open, clear, and serious style is a reference to the finance industry and the future. The flexible visual system is displayed in different forms such as physical objects, 3D space, outdoor advertising, digital environment, and animation.

The inverted T wraps up two themes — firstly, a turn, as an image of the novelty, and secondly, the axes of coordinates as a symbol of evolving financial markets. A series of dynamic abstract illustrations refer to the financial reports, while the cosmic gradient complements the strict graphics and brings on the futuristic spirit.

Full case study: https://evrone.com/tardis-fund
What’s New In Node.js 15?
Tags: node, nodejsdevelopment
Published: 2020-10-23 12:48:30

Modern web applications are developed with many popular frameworks like Angular JS,  bootstrap and so on. These frameworks are based on popular Javascript frameworks. But when it comes to developing server-based applications, Node.js comes into the focus. It is also based on the JavaScript framework but used for developing server-based applications. In 2020, Node.js turned 11 years old, and the number of packages available on npm crossed one million. Downloads for Node.js itself continue to rise, growing 40% year over year. A lot has happened in a relatively short amount of time! Each year the Node.js community has gained momentum, and 2020 shows no signs of slowing down. There are lots of interesting features being explored for the next major releases of Node.js 15. Here we will see some major features in node.js 15.

#New Features In Node.js 15-
**1. N-API Version 7-**
Node.js 15 eases the creation, build and support native modules.  It comes with N-API version 7 which includes some extra methods to work with array buffers-

napi_status napi_detach_arraybuffer(napi_env env, napi_value arraybuffer)
napi_status napi_is_detached_arraybuffer(napi_env env, napi_value arraybuffer, bool* result)

**2. npm 7-**
It is a major release that comes with new features including workspaces and a new package-lock.json format. Npm 7 also includes yarn.lock file support. There is a new change in the latest version with npm 7 – peer dependencies are installed by default. Npm team has worked to minimize potential disruption to existing projects because of the switch to automatically installing peer dependencies, if you face any problem, you can sue the –legacy-peer-deps flag at install time as a workaround to revert to the previous behavior. You can set it in the environment or npm config files.

**3. AbortController-**
Know more at- [https://solaceinfotech.com/blog/whats-new-in-node-js-15/]
Show your files and folders with `tree`
Tags: linux, bash, productivity
Published: 2020-10-23 12:48:22

The `tree` command is an easy way to print files and folder structures. Like you see in a lot of tutorials. 

Running it without arguments will print your files and folders.

```
~/code-like-the-90s ❯❯❯ tree
.
├── css
│ └── main.css
├── img
│ └── bkg.png
├── index.html
└── script.js

2 directories, 4 files
```

### Ignoring

You can tell it to ignore directories with `tree -I [DirectoryName]`. In most web scenarios, you’ll want to ignore your npm packages, so `tree -I node_modules`.

You can exclude more than one folder by separating them with a pipe character.

```
tree -I 'node_modules|.cache|test_*|public'
```

This is a must to ignore cache folders, build directories, etc.

### Restricting output

The `-d` flag restricts it to _only_ show your folders and hide files.

```
~/c/nextjs-app ❯❯❯ tree -d
.
├── pages
│ └── api
├── public
└── styles

4 directories
```

The `-P` flag allows you to only show a certain type of files. For example, if you want to list your JavaScript files while ignoring npm packages.

```
~/my-app ❯❯❯ tree -P '*.js' -I 'node_modules'
.
├── public
└── src
    ├── App.js
    ├── App.test.js
    ├── index.js
    ├── serviceWorker.js
    └── setupTests.js

2 directories, 5 files
```

Finally, you can restrict how deep in the folder structure you want to crawl using the `-L` flag. `tree -L 2` will only go 2 levels deep.

As usual, install it with Homebrew or apt-get: `brew install tree` or `apt-get install tree`

There you go! I’ve used this command quite a lot to create documentation or get a sense of a new codebase. I hope it will be useful for you too.

Cheers
Nifty command lines: series intro
Tags: linux, bash
Published: 2020-10-23 12:45:36

I remember when scary terminals became required for web programmers. No more double-clicking `index.html`. You had to, _gasp_, **run a command** to work on your website. Who said they miss FTP? Not me…

I discovered later that the dreaded terminal could do operations that I used random websites for. For instance: Convert a font, a video, etc. While websites work, they can break, start showing NSFW ads, or stop being maintained.

Command-line interfaces have been around for years (if not decades) without ever changing. Also, it’s easier to remember a command than a bookmark.

### Housekeeping

I recommend using [Homebrew](https://brew.sh/) to install your command line tools. It works on macOS, Linux, and Windows using WSL2.
XUMM SDK: 1. Get your XUMM API credentials 🔑
Published: 2020-10-23 12:43:53

series: [The XUMM SDK in Node/JS]

_Previous: [» Intro "XRP ledger payment requests"](https://dev.to/wietse/how-to-use-the-xumm-sdk-in-node-js-5380)_

Visit the **[XUMM Developer Console](http://apps.xumm.dev/)** by navigating to https://apps.xumm.dev. If this is your first time using the XUMM Developer Console, you will need to register an account OR sign in with your Github account, if you have one.

After logging in to the **XUMM Developer Console**, [create a new application](https://apps.xumm.dev/create-application) by clicking the `Create new application` button. Enter a title and description for your app and upload an icon or picture if desired. If you are only going to be playing and testing with the API, the app title and description do not matter.

For this tutorial entering a `Webhook URL` is not required.

#### After creating your new XUMM API application, you will be taken to a page showing your `API Key` and `API Secret`. 

Example credentials and where to find them.
[New App credentials](https://dev-to-uploads.s3.amazonaws.com/i/0ypo6flou5t29b09996t.png)

### ❗ _**Keep these credentials SAFE!**_

You can always find your **API Key** in the XUMM Developer Console however, your **API Secret** will be displayed **only once**. You can always generate a new one if required, but doing so will require updating the API Secret in all your applications.

### ❗ _**NEVER share or publish your app credentials!**_

Your **API Secret** is for backend use only. Never use these credentials in the frontend of a client side project. If you think your **API Secret** has been compromised, please regenerate a new secret in the XUMM Developer Console.

Congratulations, you have now registered your first (?) XUMM App. Let's get started!

**Next:**
#### [2. Prepare your project and start coding 🔨](https://dev.to/wietse/xumm-sdk-2-prepare-your-project-and-start-coding-a8m)
[3. Your first payload 🔔](https://dev.to/wietse/xumm-sdk-3-your-first-payload-49i2)
[4. Verify the results ⛑ and push 🚀](https://dev.to/wietse/xumm-sdk-4-verify-the-results-and-push-381)
[5. Security & finishing touch 🎉](https://dev.to/wietse/xumm-sdk-5-security-finishing-touch-3335)

## Resources 📚
If you want to learn more about the XUMM SDK, platform, documentation, etc., make sure to check out:

- The XUMM SDK [readme](https://www.npmjs.com/package/xumm-sdk)
- The XUMM SDK [source code](https://github.com/XRPL-Labs/XUMM-SDK)
- The XUMM API [documentation](https://xumm.readme.io/docs) & API [reference](https://xumm.readme.io/reference/about)
- XUMM (end user) [support docs](https://support.xumm.app/)
- In case of questions: [support@xumm.app](mailto:support@xumm.app?subject=XUMM+SDK+-+dev.to)
A machine learning-powered cryptocurrency trading bot
Tags: blockchain, machinelearning, startup, coding
Published: 2020-10-23 12:34:39

The Crypton.trading project was acquired by an investment company that continued its further development as a part of their private business initiative. Due to that from now on Crypton is closed from public access.

See the Crypton.trading website layout here: https://evrone.com/crypton-layout

The founders of Crypton approached Evrone with the idea of creating a smart trading bot which can determine when best to buy and sell a cryptocurrency, so as to maximize returns on investment. Besides a great idea, they brought with them a wealth of experience in finance and trading and sought our technical skills to bring it to life.

Full case study: https://evrone.com/cryptontrading
Authentica B2B portal development for a beauty distributor company
Tags: startup, ruby, rails, development
Published: 2020-10-23 12:29:47

Authentica has been developing the project for more than five years. The developed project is a B2B solution for online trading while also providing a tool for communications between suppliers and an affiliate network.

According to the Russian beauty market research by GfK Russia, the internet channel of cosmetics sales occupies at least 10% of the entire market and it is also the fastest-growing channel — up to 30% per year. Many distributors have made big bets on the Internet channel, enhancing their online presence.

The competition in beauty industry services is extremely high. Today it is not enough for beauty salons to have an extensive assortment and keep track of new products in the market. An established and highly automated system for working with suppliers and inventory of products is also important. This is exactly what Authentica provides through its B2B portal.

Full case study: https://evrone.com/authentica
Regulated hybrid securities and digital assets exchange
Tags: blockchain, webdev, startup, coding
Published: 2020-10-23 12:27:02

The Adara team came to us with the idea of creating an intelligent blockchain ecosystem, which enables anyone to easily buy, trade and sell a range of altcoins and tokenized services. Our task was to develop web service that would allow the startup to conduct ICO campaign to raise funds for a new project.

The solution: https://evrone.com/adaraio
Converting a shape to a Well Known Format with OpenLayers
Published: 2020-10-23 12:23:21

To convert a feature in a Well Known Format (https://en.m.wikipedia.org/wiki/Well-known_text_representation_of_geometry) -> useful for CQLFILTER request HEADERS.

const wktFormat = new ol.format.WKT();
const polyCoords = [];
this.features.forEach(feature => {
    polyCoords.push(wktFormat.writeGeometry(feature.fixLastPoint().getGeometry()));
})
New infrastructure and management for an investment platform
Tags: startup, ruby, python, devops
Published: 2020-10-23 12:23:18

Potok is a crowdfunding platform for lending and investments for medium and small businesses. It allows small businesses to quickly attract loans from investors, individuals and legal entities, while they receive equally fast returns.

The platform was launched as an Alfa Bank project back in 2015, but in 2019, the bank sold a 40% stake to a group of private investors with experience in the development of fintech projects.

The platform is written in Ruby on Rails, so the new shareholders approached Evrone, since we are experts in this technological stack, with the task of managing the development and support of an innovative product.

Read the case study: https://evrone.com/potokdigital
Should Gem assumes that other gem is loaded?
Tags: ruby, rails
Published: 2020-10-23 12:21:27

We have a gem where we have a method `#display_name`, this method returns localized name if I18n gem is defined else falls back to default_display_name.

Following is the current implementation:

```ruby
  def display_name
    if Module.const_defined?(:I18n)
      localized_display_name
    else
      default_display_name
    end
  end
```

We want to refactor it as on every method call we are calling `Module#const_defined?`. 

Following is the proposed implementation.

```ruby
if Module.const_defined?(:I18n)
  def display_name
    localized_display_name
  end
else
  def display_name
    default_display_name
  end
end
```

On surface level this looks ok but we have a concern that now we are assuming the require order of gem. So, my question is, should the gem assume the other gem is loaded (in this case I18n) or it should lazily checks like current implementation.

And any other suggestions for refactoring/optimizations are welcome. Thanks in advance!
Web Dev in JS vs. Android Dev in Kotlin - what would you choose?
Tags: career, kotlin, help
Published: 2020-10-23 12:21:23

Dearest DEV community,

I have 2+ years of professional experience working as a web developer with the MEAN stack. In my spare time, I do enjoy tinkering with Svelte and jamstacky technologies such as Hugo, Netlify and other SSGs.

I'm also unemployed at the moment (long story) and just started job hunting. An opportunity to work as an Android developer with Kotlin is already presenting itself and I wonder what the developer experience is like with Android/Kotlin.

From ~10 minutes of research it seems like Kotlin is at least as loved as JS, but I'd love to hear testimonials from actual devs who have experience in both JS/web dev and Kotlin/Android dev

Thanks!
Advanced TypeScript Exercises - Question 10
Tags: typescript, challenge, javascript, webdev
Published: 2020-10-23 12:13:18

--- series: Advanced TypeScript Exercises ---

Intersection type level operator **&** has changed in the last versions of TypeScript. The current behavior escalates 'never' type, so if any of fields will produce empty/never type, the whole composite will end as 'never'. Let's see some examples:
```ts
type X  = {
    a: 1
    b: number
}
type Y = {
    a: 2
    b: string
    c: boolean
}
// XY is never, as field 'a' evaluates as 1 & 2 which is never
type XY = X & Y 
```
More about this TS behavior you can find here:
- [No empty intersections](https://github.com/microsoft/TypeScript/pull/18438)
- [Reduce intersections by discriminants](https://github.com/microsoft/TypeScript/pull/36696)

Exercise will be about having different intersection behavior. Our task is to write `Merge` type level function which will merge two product/object types. Our final `Merge` should be able to create a type from above `X` and `Y` in such a way that the latter type will overwrite types of fields of former type.
```ts
type XY = Merge<X,Y>
// XY should be {a: 2, b: string, c: boolean}
```
Link to the [playground with the task](https://www.typescriptlang.org/play?#code/PTAECMFMBsHsHdQBNIDMCGBXaAXCkALdANwEtYAnUAKBwE8AHSUADVFAF5QBva999AC5QARj79wwgHaYAtlArUAvtVqNmATU49xA4QCZdEYQGccFUlIDmRgMbDwsWNEjopytU1ZaubAGSgWiCgUpDEkFSqwQC0sXHxCYlJCaAAoiypAEoAwgCSAMqpogAMoMnlyZ7MALIRVpAAPACCADSgAEIAfNrcSqDBBBHMdLCYVCbOmDjkUqCAvBuApLuq9F4AKpBmItpNJiYROA21FPUNLG0anW3cQqD6bZKgZhbWbfYQTi5uSt3B62aPBFG0CQoAY6F2ZVAslcUhM+FAfxwWxMgOwIKgoHMmEgVQRGxw+m2u32hzqjWuggA5OhwLZKfdpHIFEorjdKShUJTvqzhOy0PTjCEmRFvv0wIiAUCQWCIdEoTC4RjEYSUVL4VicVEwBUdbqktRglNSNBSPRQKhKJj8ZYrJjBqAKBtsDgDWBTXCpLA8I7oOgcJAQThYHbmABHbFmGagUhw2BSaB0c2W-3-EyYU04lbMHZ7CgHcSrEQtAt3cQAfWyg1sAGstlxC6BIAAPf1SJBw1aEgD8mIo2NAwgw0D2xfYFar1cJ9cJzdb7YRWx7GoH5vQw5x7E64i4Q72jZbkDbcPHkBri9X65Xu+Ys8P85PNe7F73wg1QA). 

Good luck! If you have a solution then don't hesitate to link it in the comment. Answer will be published soon!

**This series will continue**. If you want to know about new exciting questions from advanced TypeScript please follow me on [dev.to](https://dev.to/macsikora) and [twitter](https://twitter.com/macsikora).
Daily Developer Jokes - Friday, Oct 23, 2020
Tags: jokes, dailydeveloperjokes
Published: 2020-10-23 12:00:09

---
title: "Daily Developer Jokes - Friday, Oct 23, 2020"
description: "Check out today's daily developer joke! (a project by Fred Adams at xtrp.io)"
series: "Daily Developer Jokes"
cover_image: "https://private.xtrp.io/projects/DailyDeveloperJokes/thumbnail_generator/?date=Friday%2C%20Oct%2023%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/5e125933e8609.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:___ What did the fruit basket say to the developer?

___A:___ I hope you're ready for some pear programming!
 -->
Today's Tee Bot with Python and Github Actions
Tags: github, python, actionshackathon, devops
Published: 2020-10-23 11:55:45


If you know me personally, you can see that I love nerd tee-shirts.
There are lots of websites that sell tees with several designs.
In particular, I prefer tee websites that propose t-shirts having designs made by little designers.
It means that any person can create a design and send it to one of these websites. If the project is very voted by the users of online tee shop, the administrators can decide to put on sale for 24 hours. Therefore, Every day a different t-shirt is sold.

Then, I decided to create a tee bot that sends today's tees sold from different tee shops.

## How it works
Every day the telegram bot extracts today's tees with web scraping and sends the images and the titles on a public telegram channel.

## Implementation
You can find the code in my GitHub repository: [varieteebot](https://github.com/frascu/varieteebot).

The repository contains mainly three files:
* **tee.py**: it contains the function `get_tees` that returns a list of objects of type `Image`.
Each object contains: 
 * tee title
 * URL of the image source
 * URL of the tee shop
* **run.py**: it sends the list of tees to the public telegram channel using the Telegram API. This script has two parameters:
 * bot token
 * channel id 
* **python-app-test.yml**: Github action that on the event `push` of the branch `main` installs the pip dependencies and executes the script using the GitHub secrets `BOT_TOKEN` and `CHANNEL_TEST_ID`. This action is used for the test.
* **python-app-prod.yml**: Github action that on the event `schedule` (every day at 7 UTC) installs the pip dependencies and executes the script using the GitHub secrets `BOT_TOKEN` and `CHANNEL_ID`.  This action is used for the main channel.

## Configuration
1. Create the telegram bot using [BotFather](https://t.me/botfather)
2. Create a public telegram channel
3. Add the bot as the administrator of the channel
4. Fork my GitHub repository [varieteebot](https://github.com/frascu/varieteebot)
5. In the repository settings create 3 secrets:
 * `BOT_TOKEN`: the token returned by the BotFather and used to call the Telegram Bot API
 * `CHANNEL_ID`: the public telegram channel id on which the tees are sent (_@channelname_)
 * `CHANNEL_ID_TEST`: the channel id for the test (I used my personal chat id)
6. Test opening the section *Actions* of the repository and clicking on *Tee Bot [TEST]* and on *Run workflow*
7. Test in your local environment by typing the following command
    ```bash
    python run.py {BOT_TOKEN} {CHANNEL_ID}
    ```

## My tee's channel

My fantastic channel is [VarieTee](http://t.me/varietee).
If you like it you can follow the channel and give me feedback.
Generate Vscode snippets wih Python
Tags: python, vscode, productivity
Published: 2020-10-23 11:55:11

Let's go straight to the point. Vscode is the most popular editor out there, I use it personally for everything except for java development (I use Intellij IDE).

The beauty of vscode is the ability to create custom snippets (JSON format) to speed up your development process.
But it is very frustrating for me to create snippet manually, especially if they are very long, I have to copy/paste each line into separate line to keep the snippet organized, and I have to escape double quote characters manually or with some regular expressions.

This process is very tedious and boring, and imagine if you have multiple snippets ....

Long story short, I created a simple script that read list of filenames and generate snippet JSON format to copy/paste directly into vscode config

Take a look and give me your thoughts [github repository](https://github.com/ablil/generate-vscode-snippets)