teleren/devto huggingface dataset:
Timeout mechanism using Promise.race
Tags: javascript, scheduler, async
Published: 2019-11-22 14:28:12

So we have a scheduler factory function. Simple mechanism that runs code periodically. Here is the code:

```javascript
function createScheduler({ callback, time }) {
  let run;
  let timeoutId;
  let ticker;

  function pause(time) {
    return new Promise(resolve => {
      timeoutId = setTimeout(resolve, time);
    });
  }

  async function* cycle(time) {
    run = true;

    while (run) {
      yield pause(time);
    }
  }

  async function runPeriodically() {
    if (!ticker || !run) {
      ticker = cycle(time);
    }

    for await (let tick of ticker) {
      await callback();
    }
  }

  function stop() {
    clearTimeout(timeoutId);
    run = false;
  }

  return {
    runPeriodically,
    stop
  };
}
```

As said in the [previous post](https://dev.to/lvidakovic/implementing-scheduler-s-stop-mechanism-1kcg), we can't blindly await on the callback function that is being passed from outside of our code. We can't know for sure how fast or even if it'll ever finish. To guard ourself from unexpected scenarios we'll implement a timeout mechanism using [Promise.race](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/race) function. It allows us to race with the response from the **callback** function. If callback isn't resolved until some amount of time we can force-skip into a next cycle. Code inside our "for await" loop will slightly change and incorporate our pause function which will act as a reference point in time before which we expect to see some results.

So instead of blindly awaiting on a callback:
```javascript
await callback();
```

This is how we would set a fixed 5 seconds timeout:

```javascript
await Promise.race([callback(), pause(5000)]);
```

This way we protect our piece of code from stalling when something goes bad within the logic of a callback function. To make it more ergonomic, let's parametrize the timeout duration and update our previous code:

```javascript
function createScheduler({ callback, time, callbackTimeout }) {
  let run;
  let timeoutId;
  let ticker;

  function pause(time) {
    return new Promise(resolve => {
      timeoutId = setTimeout(resolve, time);
    });
  }

  async function* cycle(time) {
    run = true;

    while (run) {
      yield pause(time);
    }
  }

  async function runPeriodically() {
    if (!ticker || !run) {
      ticker = cycle(time);
    }

    for await (let tick of ticker) {
      if (callbackTimeout) {
        await Promise.race([callback(), pause(callbackTimeout)]);
      } else {
        await callback();
      }
    }
  }

  function stop() {
    clearTimeout(timeoutId);
    run = false;
  }

  return {
    runPeriodically,
    stop
  };
}
```

It seems like we've covered potential pitfalls for regular use-cases, so next post will cover a bonus feature using async generators and will serve as a wrap  for this series.
Listy
Tags: showdev
Published: 2019-11-22 14:26:19

I have always wanted to use that tag!

[Listy](https://github.com/adam-cyclones/listy/blob/master/README.md)

Here is LISTY a TODO list I wrote with simplicity (I hope!) in mind. Its Vue with TSX if you want to see what that looks like.

Thanks everyone :)
YPSKA #11 GROQ
Tags: json, cli
Published: 2019-11-22 13:48:11

So, have you ever ended up debugging what the h*ll is returned from your REST service? A large chunk of JSON? You need to know if a field is set in one of all the records? What would you say about having a query language that you can run in the terminal for that JSON?

Have a look at [GROQ](https://sanity-io.github.io/GROQ/). GROQ stands for **G**raph-**R**elational **O**bject **Q**ueries, and is an open standard invented by [Sanity, Inc](https://www.sanity.io/). With GROQ you can write queries to find some specific data in your JSON-document. There's a nice introduction of GROQ [here](https://css-tricks.com/query-json-documents-in-the-terminal-with-groq/)

So if you ever end up going through a large JSON document do

`npm install -g groq-cli`

instead.
Everything I know about Markdown Bullet Lists
Tags: web, markdown, tips
Published: 2019-11-22 19:40:01

---
title: Everything I know about Markdown Bullet Lists
published: true
date: 2019-11-22 13:47:00 UTC
tags: Web, Markdown, Tips
canonical_url: https://www.petefreitag.com/item/888.cfm
---

My goal here is to create a quick guide to creating _bullet lists_, also known as _ul lists_ or _unordered lists_ with Markdown.

**TLDR use `*` or `-`**

As long as you start the line with a `*` or a `-` markdown will interpret that as a list item. So the following markdown:

```
* One 
* Two
```

Will produce a bullet list like this:

- One
- Two

As already mentioned we can use a `-` to start an unordered list in Markdown as well:

```
- One
- Two
```

Will produce the same list as above.

**What about nested bullet lists?**

To create a nested UL list just indent the line with a tab or 3-4 spaces. For example the following markdown:

```
* One 
* Two 
    * Three 
        * Four
```

Will render as the following:

- One
- Two 
    - Three 
        - Four

**Can you Mix `*` and `-`?**

You certainly can, the following will render the same list nested bullet list as above:

```
- One 
- Two 
    * Three 
        * Four
```

**What about Numbered Lists?**

You can do numbered lists by prefixing each line with incrementing numbers followed by a period. For example:

```
1. One 
2. Two
```

Results in an ordered list (OL):

1. One
2. Two

That's pretty much all I know about markdown lists, did I miss anything?
10 Year Challenge - 2009 - 2019
Tags: career
Published: 2019-11-22 13:34:43

So I have never written an article anywhere before and just thought about this new trend for the 10 year challenge of photos on the multitude of social media at the moment.

How about a 10 year challenge of code history:-

2009 - I can honestly say that ten years ago I knew less than nothing on how to code of any kind. I was just starting university as a mature student (hah) in Liverpool and studying a foundation degree course in engineering and technology. At that point I had almost no interest in code, I wanted to build a website but for nothing more than a digital cv. When it came to doing the basics in c# of hello world, I thought this is the dogs proverbials.

2019 - Working as Software Engineer mainly working the front end ui using a codestack of react, c#, dotnet core and a whole lot of experience from being in different environments. Iwould advise anyone getting started o find a mentor who can see what your good at and not and help steer your desire those directions. I thought i wanted to be a pure backend dev but quickly realised I had a knack for the visual aspects and was actually quite crap at the backend programming.

So let me know your journey. Mine began after 4 years in uni so i am still very much on the beginning of my career at the tender age of 38 (good gods where di the time go)
How to Provide a Better Customer Experience at Ski Resorts with the Help of Mobile Technologies
Tags: management, mobile, startup
Published: 2019-11-22 13:28:57

https://yalantis.com/blog/how-to-provide-a-better-customer-experience-at-ski-resorts/

To create an attractive ski resort, you need to offer your guests well-equipped slopes and developed infrastructure. You should consider a bunch of things, starting with how many lifts you’ll run and where your equipment rentals will be located. You’ll also have to find a way to help guests orient themselves at your resort. 

You can always show your guests around the old-fashioned way with the help of maps and markings. But what if you could guide your guests with an app that is always at hand and then use that app to attract more guests? This is exactly what a lot of ski resorts are doing right now.

To build not just a good but a leading ski resort, you should integrate digital experiences with your offline sports activities to provide a better customer experience.

Why should ski resort companies invest in mobile technologies?
Over the last two seasons, more than 80 percent of skiers and snowboarders were active on social networks while on the slopes. They posted pictures on Facebook, told about their experiences on Twitter, and shared videos on YouTube.

To attract more guests and make them return, it’s important for ski resorts to pay attention to the social aspects of skiing and use them to better serve customers.

A huge number of people can’t imagine doing sports without their devices and mobile apps. They use wearables to track distances and number of reps and view this data in mobile apps that display easy to understand charts and graphs.

If you are able to track the number of miles you run in the morning, why shouldn’t you be able to record the height of the hill you’re skiing on? If you can share your fitness results from the gym with an instructor, then why shouldn’t you be able to share your ski results with a coach?

Actually, you can.

How to use mobile technology to improve the customer experience
There are several types of apps that are used to improve the quality of customer service at ski resorts.

Navigation
Edge Ski, for example, provides slope maps and weather information. Moreover, the app provides access to this information even without an internet connection. Other than showing maps and weather, the application tracks all sorts of user metrics. Edge Ski is available for 119 ski resorts around the world.

The SkiLynx app is similar to Edge Ski, but in addition to tracking metrics, this application offers messaging with friends to schedule outings or discuss plans.
How to be an effective developer
Tags: todayilearned, career, productivity
Published: 2019-11-22 13:00:05

*Learnings from three articles I read today*

### [11 rules of effective programming](http://bit.ly/37tZNx9)

- Leave your code better than you found it.
- Think about the total cost of ownership: cutting corners, skipping tests for later or creating temporary fixes have costly long term repercussions.
- Look for repeatable patterns from references or projects around you or online that have implemented a feature with similar requirements.
- Micro-optimization can easily make your code a mess and does not bring much value to users.
- The cost of fixing bugs grows exponentially over time. Discovering problems early makes them easier to solve too. 
- Avoid multitasking. Studies show that it has a negative impact on performance and productivity. 

*[Full post here](http://bit.ly/37tZNx9), 8 mins read*

---

### [Slow down to go faster](http://bit.ly/34a9vCP)

- Take time to write automated tests instead of focusing on developing features alone. It will save you manual testing time later and avoid regressions as the code grows. 
- Take time when naming variables, classes, etc, so they are meaningful and self-explanatory. This will ensure other developers can easily grasp the contexts easily from the names.
- Document your code as you write it. Structure it to start with a brief summary of multi-line functions, inline warnings, and explanations of tricky bits. Record intent rather than implementation. 
- Invest time to think about what you want to achieve while things are still simple. This way, you will not be thrown off track by complexity later. 

*[Full post here](http://bit.ly/34a9vCP), 4 mins read*

---

### [Your system is not a sports team](http://bit.ly/2XCBYOV)

- If you are aligned to a mission, rather than being aligned to a specific system, you will work better for the success of the company. 
- Don’t be obsessed with a system that you have built or worked on for many months/years. 
- Don’t focus only on improving the system you are working on. Look at the larger goal your company is working towards and find the best utilization of your time.
- Get your team aligned on the problem at hand and not around the tools & technologies to use to solve the problems. 
- Empower all engineers to focus on the impact of their decisions on the overall company by avoiding silos. 

*[Full post here](http://bit.ly/2XCBYOV), 4 mins read*

---

*[Get these TL;DR style notes directly to your inbox every weekday by signing up for my newsletter, in.snippets(), here.](https://mailchi.mp/appsmith/insnippets?utm_source=devto&utm_medium=post08&utm_campaign=is)*
Is VScode Truly Open Source?
Tags: vscode, opensource, ide
Published: 2019-11-22 12:34:21

For years I only wrote code in a terminal via Neovim but chose to give VSCode a spin and I found I really like it. However, it's not as open source as I originally thought.

After a bit of digging I learned that the download from their website is not open source but the code hosted on Github is open source. This is like Google's Chrome verses Chromium but with the same name so it's expected to get confused.

For some context this [Github issue comment](https://github.com/Microsoft/vscode/issues/60#issuecomment-161792005) explains the difference:

> _When we [Microsoft] build Visual Studio Code, we do exactly this. We clone the vscode repository, we lay down a customized product.json that has Microsoft specific functionality (telemetry, gallery, logo, etc.), and then produce a build that we release under our license._
>
> _When you clone and build from the vscode repo, none of these endpoints are configured in the default product.json. Therefore, you generate a "clean" build, without the Microsoft customizations, which is by default licensed under the MIT license._

So as an open source junkie I proceeded to download the source code from the Github page to build from source when I came across another repo. This repo is called ["VSCodium"](https://github.com/VSCodium/vscodium) as a play with the Chrome/Chromium branding. This repo strips out all telemetry and removes all branding to keep their binaries 100% open source (MIT to be exact).

> _This repo exists so that you don't have to download+build from source. The build scripts in this repo clone Microsoft's vscode repo, run the build commands, and upload the resulting binaries to GitHub releases. These binaries are licensed under the MIT license. Telemetry is disabled._
> - VSCodium_

After a bit of coding with VSCodium it seems to run exactly as expected. The first test was if it could still download extensions because there is no better way to code than with Vim keybindings. It worked as expected!

If you run Arch or Manjaro you can use the [AUR](https://aur.archlinux.org/packages/vscodium-bin/) to install this truely open source variant of VSCode; just search for `vscodium-bin`.

For other system head over to the [Github Readme](https://github.com/VSCodium/vscodium#download-install).

Happy coding!
Which and what approach for internal microservices communication?
Tags: microservices, architecture, design, messaging
Published: 2019-11-22 12:00:52

I am really new in microservices architecture. This is a design I would like to follow in my future software applications. I want to design architecture which is easy to expand into microservices. I don't know if the project will grow into an enterprise application or it will die in the near future. There is a lot of anomalies outside which are going to influence the future of your projects like lack of money or lack of customers.

But now back to the issue of post. I come up with the architecture of one service. It is going to follow the Domain-Driven Design and CQRS pattern. I think that you cannot design the whole system at the beginning of implementation and which part of the codebase should be in independent microservices will show themself in practice. I am currently studying the microservices communication approaches.

By pieces of information provides in this article https://blog.logrocket.com/methods-for-microservice-communication/, we can divide internal microservices communication into three most common disciplines and they are HTTP direct communication, MessageBroker, and Event-driven communication.

HTTP direct communication
I think this one is a bad path to go by default. If you are invoking the API method directly from the code of another service, it is a code smell.
Microservices should be independent and if you are pushed to invoke the API method of another service, maybe you have the wrong design. 
In my humble opinion, you should not ever have the urge to wait for a response and always be capable of calling another service API asynchronously. If you have to wait for a response probably because of need to receive data, which are part of your current business rule flow, you have a wrong design or maybe you are in wrong microservices.

MessageBroker
With MessageBroker approach comes a really nice solution for coupling services to independent instances. This looks like a great way to go but also looks complicated to implement and I am not sure if it is not overkilling of my needs. The problem is the question by itself. What are my needs? As I mentioned, I do not know where the project will take me in a few months or years.

Event-Driven communication
In this case, we are not sending messages directly into Consumer's queue, but simply raise an event and it depends on the consumer if he will take an action or stay chill. Also a very nice independent solution of internal communication, but again, Implementing this will be complicated and time-consuming.

I would love to hear opinions of the community in the comments section.

Thank you
Angular Animations - Let’s create a carousel with reusable animations
Tags: angular, webdev, uiweekly, typescript
Published: 2019-11-22 11:55:00


Hey Guys!

Wrote a blog post about Angular Animations, you can find it here ;)


https://medium.com/showpad-engineering/angular-animations-lets-create-a-carousel-with-reusable-animations-81c0dd8847e8
Wanveo 
Tags: wanveo
Published: 2019-11-22 11:24:24

Decouvrez les meilleurs film sur wanveo voir le lien https://actu-solutions.com/wanveo ainsi que etopop https://actu-solutions.com/etopop ainsi que   
vavozi voir le lien https://actu-solutions.com/vavozi
Chat application development with react-native for Android and IOS, Will it support all the features?
Tags: reactnative, android, ios, chatxmpp
Published: 2019-11-22 10:28:18

Hello,

Good day!!!

I am Android developer, I am new in react-native application development. Need help about development possibility regarding below requirements, 

I am developing chat application like Slack with all the feature including, single, group chat, media sharing, read receipt, typing intimation, add/remove participants, admin assignments(For group chat), video and voice calling (Single and conference calls), screen sharing, integration with external apps etc.

Is this all possible with react-native?
What are the libraries provided for the communication with chat servers like Mongooseim - XMPP, Socket.io etc.?

Please let me know 
- The performance of application in Android and IOS as compare to Native developed apps.
- Is there background service works for Android/IOS?
- Notification supports
- Video and audio calling performance.
- Database handling (like export database file and push over cloud for backup form app)
- Alarm manager support for task execution in particular time. 

Please suggest, which framework is better native or cross-platform for this kind of app development.




Thank you in advance.
Dayanand Lande.
PulseMixer
Tags: colorscheme, themes, gnulinux, linux
Published: 2019-11-22 08:51:21

This looks cool??? Being honest I think that isn't so bad..lol...So if you want this very cool *mixer* for your *terminal* in [GnuLinux](https://distrowatch.com) *Pulsemixer* and *Terminator*
(
```bash
sudo apt install pulsemixer terminator -y
```
) and the theme for windows of *Linux* ([TigerR04r](https://github.com/TitanHero/TheFancyRetroElectroTUX/tree/master/resources/windows_themes/TigerRoar)) and the themes for terminator([shelltrific](https://github.com/TitanHero/Shelltrific))...*Cool*...*Animus*...

```bash
GnuLinux;Linux; sleep 3 && Peace && Love -y
```
Help me choose what I should write next
Tags: motivation, watercooler, meta
Published: 2019-11-22 08:36:14

Dear Dev community, I have more ideas for new articles that I have time to actually write them.
 
Can you help me filter them out?

Please tell me which 1 or 2 subjects sounds most interesting to *you*. 

# A: Simple Continous Integration with GitHub Actions and Gradle

CI is useful but it is one more thing to setup, and when you do it for the first time, it feels overwhelming. It certainly felt that way for me. I have found a nice simple solution for people building with Gradle.

# B: Asciidoc is Markdown done right

Markdown has become really popular and for a good reason: it tackles a real, important problem. Unfortunately while I love the *idea* of Markdown, it isn't really the right solution to that problem, which is why everbody is extending it in mutuable incompatible ways. Can we do better than this?

# C: 20 pro tips for writing on dev.to

I have written a significant amount of articles and comments on dev.to now and I can share what I've found useful to do it better. I don't actually have 20 tips in mind right now, but I'm pretty sure I can brainstorm it :)

# D: Rethinking job hunting powered by dev.to's collective widsom

My current job contract ends at the end of the month and I want to be smarter at job hunting that I was in the past. The basic premise of that article is that the hiring market is mostly broken. Not only because of how companies typically hire, but also because of how software developers typically hunt for a job. The reason it's broken is mostly inertia. It's hard to do things differently than others. But there is a lot of interesting articles on dev.to about careers... By leveraging that collective wisdom, we might be able to do better than that. 

# E: You had a problem, you used a regex, now you have two problems

There are some useful articles here on [how to become a regex master](https://dev.to/awwsmm/20-small-steps-to-become-a-regex-master-mpc). 
True mastery however also involves knowing when not using them and how to do it instead. Regex are very powerful so you can use them fora lot of things. But that doesn't mean you should. 

# F: How to choose a mobile strategy that makes sense for you

You have a product and you think you need an app for this.
There are lots of options on how to do it, from going 100% native
to having only a website, to everything in between. 
How to choose a strategy that makes sense for you?
Basic premise: mobile is hard, there is not one solution that is good
in all or even most cases, and you have to pick your poison. 

---

Your turn: what's the most 1 or 2 interesting topics in this list?