teleren/devto huggingface dataset:
How can you implement the sleep() function in Javascript?
Tags: javascript, webdev, beginners, tutorial
Published: 2022-02-27 04:14:18

### Hello Folks 👋
What's up friends, this is **SnowBit** here. I am a young passionate and self-taught frontend web developer and have an intention to become a successful developer.

Today, I am here again with an amazing topic that you'll love reading. So let's gets started 🚀

---

### 🌟 Introduction

By default, Javascript doesn't come with the `sleep()` function. To implement sleep timers, `setTimeout()` function  is the closest equivalent to the `sleep()` function.  There, are other few less common ways to implement a sleep function to create a pause after some specified duration of the time.

### setTimeout
`setTimeout()` sets a timer for a function that executes the code once after the time expires. The only code that is inside the `setTimeout()` function will execute after the given amount of time. Duration is always written in **milliseconds(ms)**. Here's how you write the `setTimeout()` function.

```js
const printHelloWorld = () => {
  console.log("Hello");
  setTimeout(() => console.log("World"), 500);
};

printHelloWorld(); // "Hello", "World" ("World" logs after 500ms)
```

### Synchronous method
Here, we can use a loop to stop the execution of the function
```js
const sleep = (ms) => {
  const stop = new Date().getTime() + ms;
  while (new Date().getTime() < stop) {}
}

const printHelloWorld = () => {
  console.log("Hello");
	sleep(500)
  console.log("World")
};

printHelloWorld(); // "Hello", "World" ("World" logs after 500ms)
```

### Asynchronous method
A less interfering method to implement the `sleep()` function using the `async` and `await` and a `setTimeout()` and `Promise`. Since we are dealing with the `Promise` the executing function must be `async`.

```js
const sleep = (ms) =>
  new Promise(resolve => setTimeout(resolve, ms));

const printHelloWorld = () => {
  console.log("Hello");
	sleep(500)
  console.log("World")
};

printHelloWorld(); // "Hello", "World" ("World" logs after 500ms)
```

---

So, this was it for this article. I hope you learnt something new and enjoy reading. Stay tuned for the next article. 

Let's connect on Twitter - [@codewithsnowbit](https://twitter.com/codewithsnowbit)

### 🌏 Let's connect
- [GitHub](https://github.com/codewithsnowbit)
- [Twitter](https://twitter.com/codewithsnowbit)
- [YouTube](https://www.youtube.com/channel/UCNTKqF1vhFYX_v0ERnUa1RQ?view_as=subscriber)
- [Buy Me A Coffee](https://www.buymeacoffee.com/codewithsnowbit)
Google Summer of Code 2022 Timeline Explained (2/5)
Tags: opensource, googlesummerofcode, productivity, beginners
Published: 2022-02-27 03:29:41

Post (2/5) on Google Summer of Code (Long Post)

Let's talk about the timeline for Google Summer of Code 2022.

All the data is taken from the GSoC website. Rest all are my personal views.

Timeline (2022)
● February 7 -  March 6
Mentoring organizations will be announced. Every year Google updated the list of participating Orgs for the GSoC.

● March 7 -  April 3
List of accepted mentoring organizations published. This is an important date as from here things will change a lot. Once the organisation announced applicants will have better clarity in which Org to apply and on what project to apply for.

● April 4 - 18:00 UTC
GSoC contributor application period begins. From this date, students can apply to their respective Org.

*Keep in mind it is not first come first serve. So take your time and even you apply to the last date things will work perfectly fine.

To Apply you have to make a proposal form, your student ID (college id) and a few basic details.

You can apply to a maximum of 3 Organisations.

● April 19 - 18:00 UTC
GSoC contributor application deadline.

● May 20 - 18:00 UTC
Accepted GSoC contributor projects announced.

● May 20 - June 12
Community Bonding Period. GSoC contributors get to know mentors, read documentation, get up to speed to begin working on their project.

This is the time when you will first meet your mentor. The mentor may ask you to explain your proposal and timeline. Try to clear all your doubts in this meeting.

You can start your project from this date if your mentor permits. Let your mentor know If you have any other commitments along with GSoC.

● June 13
Coding officially begins!

● July 25 - 18:00 UTC
Mentors and GSoC contributors can begin submitting Phase 1 evaluations. The milestones that you mentioned in the proposal form would be complete by now. On that basis, your evaluation will be done.

● July 29 - 18:00 UTC
Phase 1 Evaluation deadline (standard coding period)

● September 5 - September 12 - 18:00 UTC
Final week: GSoC contributors submit their final work product and their final mentor evaluation (standard coding period).

● September 12 - September 19 - 18:00 UTC
Mentors submit final GSoC contributor evaluations (standard coding period). All your milestones should be complete by now which were mentioned in the proposal form. You may talk to the mentor regarding any issue or completion of work.

● September 20
Initial results of Google Summer of Code 2022 announced

● September 12 - November 13
GSoC contributors with extended timelines continue coding

● November 21 - 18:00 UTC
Final date for all GSoC contributors to submit their final work product

● November 28 - 18:00 UTC
Final date for mentors to submit evaluations for GSoC contributor projects with extended deadlines.

All the dates are fixed and they are taken from the GSoC official blog.
Planning for release 2.8
Tags: javascript, opensource
Published: 2022-02-27 02:47:53

This week, we talked to each other on what we were gonna work on for release 2.8. 

My plan is to finish the parser service, I'm struggling a bit with e2e tests but (Roxanne)[https://github.com/rclee91] offered me some help with changing the mocked `indexer` to Elasticsearch mock, it became easier. 

### Writing e2e tests for parser: 
Most unit tests are written already, I just ported those tests over to `sr/api/parser`, changed some imports and added a few small tests. 

My approach is to clear the redis database first and add a few feeds (invalid, valid, youtube) to the queue to process using a custom mocked `getWikiFeeds()` and fetch `posts` service to compare the result when the queue is drained. 

My mistake when trying to write e2e tests was that I tried to use mocked Redis, but e2e is where you test the flow of the application so mocking is not needed. I've got the first test to work but encountered this problem 

```
Jest did not exit one second after the test run has completed.

This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue.
```

I then ran the test with `--detectOpenHandles` and found out that the code had a few Redis connections open, somehow `logger` is an open handle, such as 

```js
// src/api/parser/src/lib/queue.js
const client = Redis();
const subscriber = Redis();

// /src/api/parser/src/utils/storage.js
const { logger, Redis } = require('@senecacdot/satellite');
const redis = Redis();
```

I have something in mind, will update this blog when I find a solution! 

--- 

Personal notes: I hope the people of Ukraine can stay safe, I have a few Ukrainian friends and I can't imagine being in their shoes, it hurts me when thinking about it. The world has become unpredictable in the last 2 year.
tc39 proposal-tempral: Time-zone conversion
Tags: javascript
Published: 2022-02-27 02:27:23

## What is `Temporal`

>  A global Object that acts as a top-level namespace (like Math), that brings a modern date/time API to the ECMAScript language.

[Temporal documentation](https://tc39.es/proposal-temporal/docs/index.html)

It is on Stage 3 proposal at the time of publishing this article.

## Time-zone conversion

What I would like to show you in this article is one of the  killer methods that should be super useful, Time-zone conversion🗺.
(Plus, it does support DST-safe arithmetic!! 🤯)


```js
const instant = Temporal.Instant.from('2022-02-27T02:04Z');
instant.toString(); // => '2022-02-27T02:04:00Z'

const currentTz = Temporal.Now.timeZone();
currentTz.toString(); // => 'Asia/Tokyo'

const jpDateTime = new Temporal.ZonedDateTime(
  instant.epochNanoseconds, 
  currentTz, 
  Temporal.Calendar.from('iso8601')
);
jpDateTime.toString(); 
// => '2022-02-27T11:04:00+09:00[Asia/Tokyo]'

const laDateTime = new Temporal.ZonedDateTime(
  instant.epochNanoseconds,
  Temporal.TimeZone.from('America/Los_Angeles'),
  Temporal.Calendar.from('iso8601')
);
laDateTime.toString() 
// => '2022-02-26T18:04:00-08:00[America/Los_Angeles]'
```

## How I tried `Temporal`

Open [this official doc](https://tc39.es/proposal-temporal/docs/index.html) and used the dev-tool console 🎮

![how-to-try](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sy0845p5xs74z4cwzrka.png)
 

## Reference

For more details, please check out the official documents 😉
- [Temporal documentation](https://tc39.es/proposal-temporal/docs/index.html)
¿Qué son los empty-statement en javascript? ¿Existen casos de uso?
Tags: javascript, beginners, spanish, programming
Published: 2022-02-27 01:46:38

Javascript tiene ciertas peculiaridades que en ciertos momentos resultan ser importantes, o al menos interesantes, de conocer. Puede que los `empty-statement` sean de esas peculiaridades de JavaScript que resultan no ser tan necesarias o al menos no con tantos casos de uso.

## ¿Qué es un statement?

una sentencia (statement) es una unidad sintáctica de un lenguaje de programación imperativo que expresa alguna acción a realizar. Podemos decir que son las unidades ejecutable más pequeña de un programa.

Si tiene una línea de código que dice `var x= 10; consola.log(x);` eso es una línea y 2 sentencias.

## ¿Qué son los empty-statement en javascript?

Un `empty-statement` o sentencia vacía es usada para no proveer una sentencia, incluso si la sintaxis JavaScript esperase una. En pocas palabras un `empty-statement` es un `;` (punto y coma).

Una sentencia vacía no proporciona ninguna declaración aunque JavaScript la espere. La declaración no tiene ningún efecto y no realiza ninguna acción.

Un ejemplo típico sería crear un bucle for que no tenga cuerpo.

```
var arr = [1, 2, 3];

// Asignar el valor 0 a todos los elementos del array
for (i = 0; i < arr.length; arr[i++] = 0) /* sentencia vacía */ ;

console.log(arr);
// [0, 0, 0]

```

Siempre se recomienda añadir un comentario a nuestro código cuando estamos utilizando sentencias vacías de forma intencional.

Un ejemplo de un uso no intencional (Mozilla Doc):

```
if (condicion); // Esta condición no ejerce ningún control!
   borrarTodo() // Por lo cual esta sentencia será ejecutada siempre!!!

```

## Algunos ejemplos de uso

### Asigna a 'b' el valor cero si 'a' no es cero.

```
var a = 1, b = 1;
if((a == 0) || (b = 0));
console.log(b); // 0

```

### Cadenas de `if-else`, para excluír ciertas condiciones

```
const name = "Fernando";

if (name === "Barrios")
    console.log(name);
else if (name === "Fernando")
    console.log(`Hola ${name}`); // Hola Fernando
else if (name === "Juan"); // No se realiza ninguna acción si el nombre pasado es "Juan"
else if (name === "Carlos")
    console.log(`Gusto en verte ${name}`);
else
    console.log("Adiós");

```

### Para evitar un comportamiento no deseado en [IIFE](https://developer.mozilla.org/es/docs/Glossary/IIFE), en algún momento querrá anteponerlo con una declaración vacía

```
;(()=>console.log('hola'))()

```

### Esperar a que una condición se cumpla

```
while ( !condition );
// haz lo que sucede una vez que se cumple tu condición

```

## Referencias:

1. [The Empty Statement](https://dev.to/bhagatparwinder/the-empty-statement-in-javascript-3lg7#:~:text=An%20empty%20statement%20provides%20no,loop%20that%20has%20no%20body.&text=It%20is%20a%20good%20idea,on%20using%20an%20empty%20statement.)
2. [Empty Statement](https://developer.mozilla.org/es/docs/Web/JavaScript/Reference/Statements/Empty)
3. [What is the point of using empty statement in JavaScript?](https://stackoverflow.com/questions/34840628/what-is-the-point-of-using-empty-statement-in-javascript)
Telescope 2.8 planning 
Published: 2022-02-27 01:35:33

For Telescope 2.8 releases. We decided to host our own docker, first decided to move our repo during the study week to another organization to use the tier for hosting our docker with GitHub, we also tried to option to email Docker to get the free tier for open sources projects. But @humphd hasn't heard back from Docker. Lucky thanks to Chris, we were able to have our own server for telescope.
There is several small tasks.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ire5vfbzt5sjabyvren4.png)
I assigned myself to the registry config, nginx config, outh2-proxy config, and GitHub Provider config with team, token access. I think it good enough issue to work on during the study week.
I'm also parallel working on [Issue #3030](https://github.com/Seneca-CDOT/telescope/issues/3030), this issue is similar to setup docker with outh2-proxy but instead of docker I need to setup for portainer. 
The only Pull request I did for this week was [Pull Request #3041](https://github.com/Seneca-CDOT/telescope/pull/3041), to setup i18n for docusaurus. 
This week I didn't do much but next week is where the fun start.
Editorial-Chart experiment
Tags: codepen, css, html, javascript
Published: 2022-02-27 01:14:14

<p>This is only an experiment
Source code: <a href="https://github.com/schmidtsonian/calendar-stats" target="_blank">https://github.com/schmidtsonian/calendar-stats</a>
Original design: <a href="https://dribbble.com/shots/2531003-Editorial-Chart" target="_blank">https://dribbble.com/shots/2531003-Editorial-Chart</a></p>

{% codepen https://codepen.io/elynaur/pen/jOGgrge %}
JUnit Script
Tags: java
Published: 2023-01-05 22:24:51

---
title: JUnit Script
published: true
date: 2022-02-27 01:02:53 UTC
tags: Java
canonical_url: https://brandonrozek.com/blog/junit-script/
---

Running a JUnit test on the terminal is a little annoying. Here is a quick script to make it easier, make it executable and drop it in [`~/.local/bin`](/blog/customexec/) for easy use.

```
#!/bin/sh

set -o errexit
set -o nounset
set -o pipefail

JUNIT_PATH="/usr/share/java/junit4.jar"

show_usage() {
    echo "Usage: junit [class file path]"
    exit 1
}

# Check argument count
if ["$#" -ne 1]; then
    show_usage
fi

java -cp "$JUNIT_PATH":. org.junit.runner.JUnitCore "$1"

```

Replacing `JUNIT_PATH` with the location of the `junit4.jar` on your system.
Section 4.2 - AWS Certified Cloud Practitioner Study Guide
Tags: aws, cloudskills, examprep, cloud
Published: 2022-02-27 00:55:23

**This series is intended to be a personal study guide. Information may not be comprehensive or accurate. I am sharing it in case others find it useful. Please feel free to comment if any information is inaccurate.**

[Return to Exam Guide](https://dev.to/aidutcher/aws-certified-cloud-practitioner-study-guide-exam-guide-outline-233o)

**<u>4.2 Recognize the various account structures in relation to AWS billing and pricing</u>**

**Recognize that consolidated billing is a feature of AWS Organizations**

- [Consolidated billing for AWS Organizations](https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/consolidated-billing.html)
- Consolidate billing and payment for multiple AWS accounts
- Has benefits:
     - One bill
     - Easy tracking
     - Combined usage (to get volume discounts)
     - No extra fee

**Identify how multiple accounts aid in allocating costs across departments**

- [Managing your costs with AWS Cost Categories](https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/manage-cost-categories.html)
- Departments can have separate accounts that are all billed together but have metrics which can be tracked independently to monitor spend
- Resources can be provisioned separately for each account

[Return to Exam Guide](https://dev.to/aidutcher/aws-certified-cloud-practitioner-study-guide-exam-guide-outline-233o)
HTML concluído 💥 Jornada DEV 1/52 semanas
Tags: beginners, html, jornadadev, github
Published: 2022-02-27 00:45:26

2º dia de Jornada DEV:
Hoje não consegui estudar, mas finalizei a parte de HTMl de uma pagina de perguntas e respostas. O site de inspiração é bem simples, mas a ideia é treinar o que tenho aprendido de HTML e CSS do Curso em Vídeo.

Acompanhe o progresso no [Repositório do GitHub - SweetQuestions](https://github.com/bysunshinearts/sweet-questions-weheartit)
Von Neumann ve Harvard Mimarisi Farkları
Tags: programming, beginners, tutorial, opensource
Published: 2022-02-27 00:34:19


## **Von Neumann**

- Rom bellek genel olarak bilgisayar sisteminin açılışını sağlamak amacıyla kullanılır.
- Programlara ait kod ve veri ram bellekte saklanır.
- İşlemci veri yolu ortak.
- Donanım gereksinimi, ortak erişim olduğu için Harward’a göre daha az karmaşıktır.
- Harward’a göre fiziksel yer ihtiyacı daha az.
- Komut ve veri artarda erişmek zorunda olduğu için hız daha azdır.
- Hem komut hem program verisi tutmaya uygundur.
- Bellek kullanımı daha efektiftir.
- Komut ve komuta ait verilerinin bellekten getirilmesi sırasıyla olduğu için kontrol karmaşıklığı azdır.

## **Harvard**

- Rom bellek komutlar için, ram bellek veri için kullanılır.
- İşlemci veri yolu bağımsız.
- Donanım gereksinimi, her iki tipteki bellek için bağımsız erişim yollarına ihtiyaç duyar ve işlemcinin donanım yapısı daha karmaşık.
- Karmaşık olduğu için daha fazla fiziksel alan ister.
- Komut ve veriye aynı anda erişim verdiği için işlemcinin komut çalıştırma hızı yüksektir.
- Romdaki boş alanlar program verisi tutmak için kullanılamaz.
- Ram deki boş alanlar programlara ait komutları tutmak için kullanamaz.
- Birden fazla program aynı anda çalışmasında daha fazla bellek ihtiyacı olur.
- Komut ve komuta ait verinin ilgili bellek birimine aynı anda getirilmesi kontrol karmaşıklığını arttırır.
# Hello [DEV] World; I'm Bashing in, but All in One Bite!
Tags: firstpost, bash, scripting, hugo
Published: 2022-02-27 00:22:53

Here I share a modest addition I made to a tool I found that makes it more useful for me in my desktop Manjaro Linux.

_Borrow_ and improve, right? 

First, I was looking for a bash script that would allow me to use a function in my `bash` terminal, calling the name as an alias to create a post in Hugo for the static website blog I am in the process of designing and creating.  While I have no complaints about the [normal way it is done](https://gohugo.io/getting-started/quick-start/#step-4-add-some-content), it just seems kinda clunky, no? 

`hugo new posts/your-new-post.md`

Instead of two words, why not one? And instead of a path each time, can't we  _DRY_ that? The `.md` extension too, while we are at it? Since hyphens are common in markdown posts, can't we _automagically_ make those sandwich where needed too? I think so. 

What I had in mind was something like `hugpost my new post` And I would, assuming I am in the base of my Hugo instance, expect it to create a new `markdown` file, in this case, `my-new-post.md` in the `/content` directory of the that instance and open _vscode_ in said directory with the file I just created in one short line. Why not?

I found a post in [this](https://onebite.dev/create-new-hugo-post-faster-with-bash/) blog post that nearly gets me there. And it is very helpful too inasmuch as  the anonymous author bothers to explain the bash syntax and credits and links to their source of inspiration. Still, I wanted to be able to not just create the new post, but also ~~push~~ `pipe` it into the present working directory and `pipe` it again to open it in my editor of choice: _vscode_.

Credit where it is due, here is their script from their post, [Create New Hugo Post Faster With Bash](https://onebite.dev/create-new-hugo-post-faster-with-bash/??mode=bitesize) :

```bash
function hugonp() {
    str="$*"
    hugo new posts/$(echo $str | sed -e 's/[^[:alnum:]]/-/g' | tr -s '-' | tr A-Z a-z.md).md
}
```

Aside: And how about that `bitesize` _mode_ they use in the blogpost too, eh? Cool tool there, I think.

Here is my ever so modest extended version, using 2 `|`'s, two calls (one with a switch),  and _Voila_!: 

```bash
# example:  $:>> hugpost my new post
function hugpost() {
    str="$*"
    hugo new post/$(echo $str | sed -e 's/[^[:alnum:]]/-/g' | tr -s '-' | tr A-Z a-z.md).md | pwd | code -n .
}
```

KA-Chow! Modest indeed. But it works, folks...at least on my laptop. <grin>

For those unfamiliar with bash scripting, the above would, typically, be put in the `.bashrc` file found as a hidden file in the base your home directory, depending on which version of Linux you are using.  Once there I can simply type the following in the terminal:

```bash
hugpost my new post
```

### Teaser- My next post will be about my new favorite amazing learning tool: [Lurnby](https://youtu.be/L2ViB6jbLzU)

Stay tuned...
I need help in understanding a portion in functions
Tags: c, functions, variables, beginners
Published: 2022-02-27 00:17:35


I am an Animal Science student and started venturing into programming
I decided to learn C as my first programming language because am interested in mechanized agriculture using drones and other automatic machines (I am probably wrong for doing this according to people) but am very much interested in finishing what I've started
Currently, am stuck in where seems to be pretty easy and straightforward; Functions
**I am stuck at understanding functions: how variables from the main function are assigned to the parameters of a called function, then assigned into the variables in the function itself**

I don't know if my question is reasonable enough. It's hard for me to even understand what am asking but I hope if you do, you can help me with some explanations
What is a Factory Function?
Published: 2023-09-09 01:10:22

---
title: What is a Factory Function?
description: Kyle Shevlin on how to use factory functions as an alternative to classes.
published: true
date: 2022-02-27 00:00:00 UTC
tags: 
canonical_url: https://michaeluloth.com/javascript-what-is-a-factory-function/
---

I hadn’t heard of the factory function technique until I read [What is a Factory Function?](https://kyleshevlin.com/what-is-a-factory-function) by Kyle Shevlin:

> A factory function is a function that returns a new object. The key feature of a factory is that its only job is to _pump out those items_, just like an actual factory.

> The place I use factories most often is when I want to return an object with methods but use closures to create private methods and values. Even better, I _never_ have to even think about the `this` keyword.

In other words, you can write them instead of classes!

I found a good use case for this technique today while adding extra properties and helper methods to blocks I’d fetched from the Notion API, so I wanted to give Kyle a shout-out for the timely assist.

Check out [Kyle’s blog](https://kyleshevlin.com/all-posts) for lots of other interesting coding tips.