teleren/devto huggingface dataset:
Use Multiple Threads in Node like a PRO
Tags: node, javascript, programming
Published: 2021-03-26 17:04:37

Time consuming and software intensive programs cannot be run on the main thread. With Piscina, create new threads with absolute ease.


###Why Should You Care?
While building APIs, most of us have hashed passwords before storing it in our database(if you haven't... please do it). We often tend to go lightly on our hashing so that it does not affect performance. With multiple threads, this can be done separately without blocking the main thread and leaving the user hanging.

###Example
Let's setup an NPM project:

```zsh
npm init -y
```

Install piscina:

```zsh
npm i piscina
```

Create an `index.js` file and add the following code:

```js
const path = require('path');
const Piscina = require('piscina');

const piscina = new Piscina({
  filename: path.resolve(__dirname, 'worker.js')
});

(async function() {
  const result = await piscina.runTask({ a: 4, b: 6 });
  console.log(result);  // Prints 10
})();
```

We've created a new `piscina worker` and passed in the absolute path to the worker. Then, in an async function, we've allotted a task to our worker.


Now, for our worker.... let's create a `worker.js` file:

```js
module.exports = ({ a, b }) => {
  return a * b;
};
```

Our workers can also be a `promise`.


```js
const { promisify } = require('util');
// Make setTimeout() a promise
const timer = promisify(setTimeout);

module.exports = async ({ a, b }) => {
  // Fake some async code
  await timer(() => {
    console.log('1 second later');
  } ,1000);

  return a * b;
};
```

What we've seen is pretty straightforward and not very difficult to implement on our own.... here's where piscina start's to shine:


* Efficient Communication Between threads
* Task Cancellation
* Delaying Availability
* Custom Task Queues
* Statics for run and wait times
* Async Tracking
* Support for Typescript(yay!), common JS and ESM

We'll look at most of this throughout the post.


###Cancellation
For this, we'll need use the `events` package.... this comes by default so no need to install anything. The event package gives us an `EventEmitter` which we can use to send events. Our worker listens to the `abort` event, stops executing and throws an error to let us know that it was successfully cancelled.


```js
const path = require('path');
const Piscina = require('piscina');
const EventEmitter = require('events');

const piscina = new Piscina({
	filename: path.resolve(__dirname, './worker.js'),
});

(async function () {
	const eventEmitter = new EventEmitter();

	try {
		const task = piscina.runTask({ a: 4, b: 5 });

		eventEmitter.emit('abort');
		await task;
	} catch (error) {
		console.log('Task cancelled');
	}
})();
```
If you look carefully, you will find that we haven't immediately awaited our task. If we don't do this, then by the time the `abort` event is emitted, the task would have finished executing.

This is by no means a complete list of what piscina can do.... checkout the official docs [here] (https://github.com/piscinajs/piscina).


That's it for now, I hope you guys liked this post. If you did please like it and follow me. Bye 👋
Creative Menu CSS3
Tags: 100daysofcode, html, css, javascript
Published: 2021-03-26 17:04:26

the day 96 of challenge #100DaysOfCode

Creative Menu Using HTML5 & CSS3

Demo : https://creativemenu.netlify.app/

Code : https://github.com/saidMounaim/100DaysOfCode/tree/main/Day96
Sync GitHub Issue to Zendesk Ticket
Tags: integration, github, zendesk
Published: 2021-04-09 11:37:13

---
title: Sync GitHub Issue to Zendesk Ticket
published: true
date: 2021-03-26 10:26:33 UTC
tags: #integration, #github, #zendesk 
canonical_url: https://tech.forums.softwareag.com/t/sync-github-issue-to-zendesk-ticket/240036/1
---

## Summary

This article describes a business use case to sync the issue created in **GitHub** to the ticket in **Zendesk**.

## Pre-requisites

- User should have a working [webMethods.io](http://webMethods.io) Integration tenant.

- User should have a working **GitHub** and **Zendesk** account.

## Steps

1. Login to [webMethods.io](http://webmethods.io/)Integration tenant and create a Workflow.

2. Click the **Settings** and search for **GitHub** trigger from the available list of triggers.

3. Select **New Issue** from the list of **Select Trigger** options. Authorize **GitHub** by either default or manual configuration, then select the **Repository Name**.
![image](https://aws1.discourse-cdn.com/techcommunity/original/2X/f/f6336b22696bc56aaee2015e308a98d4aec4aa4b.png)
4. Click **Save** , skip testing the trigger for now, then click **Done**.

5. Drag and drop the **Zendesk** connector to the workflow palette.

6. Double click the **Zendesk** connector icon in the workflow palette to configure the action.

7. In the action configuration screen, click on the **+** icon under **Select Action** to create a custom action.
![image](https://aws1.discourse-cdn.com/techcommunity/optimized/2X/4/4ede2a2eaf877b48592e2fa298efed847f76f5ac_2_528x500.png)
8. Authorize **Zendesk** by providing the necessary credentials.

9. Provide a name to the custom action, then select **Tickets** as the functional area.
![image](https://aws1.discourse-cdn.com/techcommunity/original/2X/7/7bebe82aaac91e4909935cb482006ab808d9f65d.png)
10. Select **Create Ticket** as the operation.
![image](https://aws1.discourse-cdn.com/techcommunity/original/2X/9/90b1343ba7d3c907bd8ed17c8b9a3e978ad73ca3.png)
11. Click **Next** , then **Done**.

12. Once the custom action is created, click on **Next**.

13. Map the appropriate fields from the **GitHub** trigger to the **Zendesk** connector fields.
![image](https://aws1.discourse-cdn.com/techcommunity/original/2X/4/4c37f40c9ff60e12ddeaa6cb80f89f73fbba7cd5.png)
14. Click **Next** , then **Done**. Save the workflow.

15. Now, create a new issue in the **GitHub**. Use the same repository selected in step 3.
![image](https://aws1.discourse-cdn.com/techcommunity/original/2X/3/33387a1914aa8ee342ae01271a9119840a86d00c.png)
16. Soon the issue is submitted the workflow will execute.
![image](https://aws1.discourse-cdn.com/techcommunity/original/2X/d/dd3238624a1ceb230244758bc7facf682727b33b.png)
17. Now check the **Zendesk** account for the ticket created.
![image](https://aws1.discourse-cdn.com/techcommunity/original/2X/1/1edce7c055b8e515f1457acf148fdb3e97814a69.png)

[Read full topic](https://tech.forums.softwareag.com/t/sync-github-issue-to-zendesk-ticket/240036/1)
10 tips to write good CSS
Tags: css, html, tips, frontend
Published: 2021-03-26 16:33:49

Greetings fellow developer, how are you? 👋🏼 
Hope you all are doing great 🙂

Today, I'm gonna talk about CSS! **Almighty CSS**, every developer's worst nightmare. OK, maybe not the worst but let's admit it, CSS is wearisome if you are a beginner who does not have much experience writing CSS.  

![Gif](https://media.giphy.com/media/yYSSBtDgbbRzq/giphy.gif)

So I just had a wonderful session with the CSS Wizard, [Kuhagra Gour](https://kushagra.dev/). For those of you who don't know him, he's the creator of [CSS Battle](https://cssbattle.dev/), [Web Maker](https://webmaker.app/) and more. The session was a part of [NeoG Camp](https://neog.camp/)'s guest lecture series where we get the chance to interact, learn and clear our doubts directly with the industry experts.

We covered a lot of topics and discussed tons of problems that students face while writing CSS.
Now as we covered a lot of ground it's not possible for me to write each and everything that we discussed but I can provide you with some tips which may be very useful to you if you struggle while writing CSS or if you are just a beginner in front-end development.

## Let's Start, 

- When developing applications, always try to do a mobile-first approach. And then, later on, optimize it for desktop.

- Try not to nest classes while writing CSS inside the stylesheet, writing CSS for one class only will help.

  ```css
  /* BAD */
  .conainer .paragraph .hightlight {
    background-color: gray;
  }

  /* GOOD */
  .highlight {
    background-color: gray;
  }
  ```

- Keep the Magic Numbers & Values inside CSS variables (such as colors, margin, padding, font-size, etc)

 ```css
 :root {
   /* COLORS */
   --primary-color: #0B5ED7;
   --secondary-color: #5C636A;
   --dark-color: #1C1F23 ;
   --info-color: #0EA5E9;
   --link-color: #1D4ED8;
   /* SPACING */
   --padding-one: 1rem;
   --padding-two: 2rem;
   --padding-three: 3rem;
 }
 ```

- The above point will also help you in creating themes based on your current CSS, just change the variable values and VOILA! there you have yourself a new theme.

- Always keep spacing consistent.

- Use Vanilla CSS as much as possible.

- Try not to use "px" for spacing and sizing, instead use "rem" and "em" for responsiveness ("rem" is more preferred).

 ```css
  /* Avoid */
 .container {
  padding: 48px;
 }
  /* Use */
 .container {
  padding: 3rem;
 }
 ```

- Use a consistent naming convention for your classes (for better DX).

- While writing an app keep in mind to give equal importance to both UX and DX.	

- While approaching a complex design, first take your time and identify your components
 - Components that are not going to be in normal flow i.e., components having `position: absolute` and `position: fixed;`
 - Container components which are uni-directional will use `display: flex;`
 - Container components which are bi-directional will use `display: grid;`

And then plan your approach accordingly.

That's all for now! 
I hope this helps somebody. 

![gif](https://media.giphy.com/media/3oKIPnAiaMCws8nOsE/giphy.gif)

Thank You ✌🏼
Happy Coding 🧡
What was your win this week?
Tags: discuss, weeklyretro
Published: 2021-03-26 16:18:19

---
title: What was your win this week?
published: true
description: Got to all your meetings on time? Started a new project? Fixed a tricky bug?
tags: discuss, weeklyretro
cover_image: https://cl.ly/188e843c2985/download/Image%202019-02-15%20at%202.36.37%20PM.png
---

Hey!


**Looking back on your week — what was something you're proud of?**

All wins count — big or small 🎉

Examples of 'wins' include:

- Starting a new project
- Fixing a tricky bug
- Visiting a beautiful place near where you live ... or whatever else might spark joy ❤️ 

---

Happy Friday!

![Lucille Bluth Excited](https://media.giphy.com/media/q6QHDGE3X4EWA/giphy.gif)
3 most convenient programs for managing family budget
Published: 2021-03-26 16:16:35

It's easy to keep track of personal money, and the family budget is already full-fledged accounting. Here are the programs that do the job.

For effective use, the application must be multi-user and suitable for different operating systems so that everyone in the family can make changes in real time. For the ability to access multiple people, developers usually offer to pay.

<h2>1. CoinKeeper</h2>

You can manage finances using a mobile application or the web version of the service. The developers claim that CoinKeeper allows you to deal with both the family's cash flows and the budget of a small company. You can set reminders for the return of debts and a limit on spending during the reporting period.

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ehhwnkaxfar146e3l1na.png) 

<h2>2. Toshl</h2>

The app supports almost 200 currencies, including 30 cryptocurrencies, and the rate is constantly updated. Imports data from online banking files, reminds you to enter expenses in the appropriate columns, automatically synchronizes with the website. Funny monsters will help you keep track of your budget. For conservatives, the application generates reports in PDF, Excel and Google Docs.

<h2>3. Moneon</h2>

Quite an interesting young application from Russian developers. There is financial accounting by categories and several accounts, debt accounting, import of transactions from SMS messages (this function is rarely found on iOS). The app also allows you to conveniently manage the total budget with your family members, however, for this, each member will need to pay a monthly premium subscription.
Writing a Discord Bot with Node.js, Redis, and the Illuminati 
Tags: redis, javascript, node, discord
Published: 2021-03-26 16:15:49

---
title: Writing a Discord Bot with Node.js, Redis, and the Illuminati 
published: true
description: I show how to write a Discord Bot with Redis and Node.js.
tags: #redis #javascript #node #discord
---

I made a video showing you how to write a Discord Bot for the Illuminati with Node.js and Redis. Check it out! Fnord.

{% youtube NUGdJG1WUjU %}
Use spread operator in Javascript to merge two objects
Tags: javascript, development, es6
Published: 2021-03-26 16:04:04

If you need merge two objects in javascript, you only need to use spread operator. It's very simple to use.
![Merge two objects in javascript](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9y075n6esux48thr3rb6.gif)


Pay attention if both objects have the sam property name. The second will override the first property.

![Merge two objects in javascript. Same property name](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0rpj1l5qcoeo6w8gr4xc.gif)
Threat Modeling
Tags: security, python
Published: 2021-03-26 15:49:56

El día pasados mi corazón volvió a latir al observar que el Theat Modeling no esta muerto, sino que esta muy vivo.
Lo cual me llevo a revisar el proyecto de owasp pytm. Comenzaré con algunas pruebas y algunos modelos para ver los resultados.
En la próxima entrada instalare y ejecutare un modelo de prueba de un REST API Básico.
Teaching gf to code
Tags: python, tutorial, 100daysofcode
Published: 2021-03-26 15:42:15

I never thought this would be possible but today for the first time solid progress was made.

Previously I have taught her how to edit videos and upload them to Youtube and finally got her a laptop to explore Davinci Resolve (which kept crashing) then Premiere Pro (she enjoyed much more) then Photoshop which after Premiere she seemed to have fallen in love with redoing all her Youtube thumbnails.

Photo and video editing are great but the real money making skill is programming so after getting her comfortable with a laptop (her first laptop btw) PHP and Node.js hello world tutorials were top of mind. This was a mistake.

So I decided to do some digging and find a recent programming tutorials. I found "100 Days Of Code – The Complete Python Pro Bootcamp For 2021". The only python programming I have done is some really basic Scrapy scraping so at first was not sold but after seeing the next best decided a female instructor with solid reviews from a respectable boot camp is a better bet and copied the files to my phone so she can watch and code at the same time.

To my surprise and amazement python is really easy to learn with the help of Replit and she was able with relatively little help build the band name generator which also to my surprise she loved as a project (its just 2 inputs printed with a space between lol).

I should also add the night before we went to a developers night where she met real programmers (other than me) both male and female of all different levels and I think that really inspired her.

Now I feel the best thing I can do to support her is carrot/reward approach and as I think she would make a great data analyst very very gently steer her in that direction. Given her last job was a waitress at a hotel buffet pretty excited how it went today!
Day 87 Of #100DaysofCode: Wrote Blog For News Scrapping
Tags: womenintech, 100daysofcode, codenewbie, beginners
Published: 2021-03-26 15:37:47

Today is my 87th day of #100daysofcode and #python learning journey. Today also keep learning from DataCamp. Most of the time I gave for writing a blog for the project. Here is my [link.](https://iamdurga.github.io/2021/03/23/nepali-news-scrapping-ekantipur/) My blog is not completely perfect or error-free. I would be grateful if you were to find an error in my blog please let me know.
<blockquote class="twitter-tweet"><p lang="en" dir="ltr">Day 87 Of <a href="https://twitter.com/hashtag/100dayOfCode?src=hash&amp;ref_src=twsrc%5Etfw">#100dayOfCode</a> and <a href="https://twitter.com/hashtag/Python?src=hash&amp;ref_src=twsrc%5Etfw">#Python</a> <br>Wrote blog for project. Here is [Link](<a href="https://t.co/rnTBqvkzFJ">https://t.co/rnTBqvkzFJ</a>)<a href="https://twitter.com/hashtag/WomenWhoCode?src=hash&amp;ref_src=twsrc%5Etfw">#WomenWhoCode</a> <a href="https://twitter.com/hashtag/100daysofcode?src=hash&amp;ref_src=twsrc%5Etfw">#100daysofcode</a> <a href="https://twitter.com/hashtag/womenintech?src=hash&amp;ref_src=twsrc%5Etfw">#womenintech</a> <a href="https://twitter.com/hashtag/DEVCommunity?src=hash&amp;ref_src=twsrc%5Etfw">#DEVCommunity</a></p>&mdash; Durga Pokharel (@mathdurga) <a href="https://twitter.com/mathdurga/status/1375468088183844864?ref_src=twsrc%5Etfw">March 26, 2021</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
ECMAScript learning note
Tags: javascript, ecmascript
Published: 2021-03-26 15:32:53

![ECMAScript4096](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9adynopdozke7q5zjagm.png)
 [link](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9adynopdozke7q5zjagm.png)
Create a custom button in Jodit editor
Tags: jodit, webdev, editor, javascript
Published: 2021-03-26 15:19:48

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/trv0gawie2djanqxf83p.png)

Jodit allows to insert buttons on the toolbar, but what if you want more customisation ?.

Take a look at this example : 

```js
let helloButton = {
  text: "helloButton"
}

let toolbarButtons = [
  helloButton, 'link'
]



let createHelloButton = function () {
  let toolbar = document.querySelector(".jodit-toolbar-editor-collection .jodit-ui-group");
  let allButtons = 
    Array
      .from(toolbar.childNodes)
      .map( n => Array.from(n.children)[0]);
  let foundButton = allButtons.find( b => b.computedName == "helloButton");
  let newButton = document.createElement("button");
  newButton.classList.add("jodit-toolbar-button__button");
  newButton.innerHTML = "<span>🧙 <em>Hello</em></span>";
  foundButton.replaceWith(newButton);
  newButton.addEventListener("click", () => editor.s.insertHTML("Hello 🧙"));
}

// eslint-disable-next-line no-unused-varfdsdfs
let editor = new Jodit("#editor", {
  buttons: toolbarButtons,
  buttonsMD: toolbarButtons,  
  buttonsSM: toolbarButtons,
  buttonsXS: toolbarButtons,
  enter: "div",
  language: "fr",
});


createHelloButton();

```

You can test it  here : [Jodit](https://flems.io/#0=N4IgtglgJlA2CmIBcAWAzAOgIwA4A0IAZhAgM7IDaoAdgIZiJIgYAWALmLCAQMYD21NvEHIQAHgCEAEQDyAYQAqATQAKAUQAE7TgD4AOtTHbYG2LWoBzALx6Qw2-sMt4tKI40axDNrQ08WtABOpPBsNiAAqgoAYgC0OA4GHl6hvuxsAA6x8ACOAK4QAG7hABqxEQCCsXJ8YBm0bBAARgi2fgJCguEAkmpW8FAW8InUyd6+dAzhhRDwAO4ZfIFsbfyCwmG2c9BsLFZQ8DM88LHbULt4GhDUEI20sLGkPPfwVlgYAAwjyY1sCDoKeCkNgaABSfCgtzEAHpfv8kp5YNcANYaQLwWDhYEATzIzlCbRY6MI4XSGVISGh0J4UGoACtSBgeLA+HkoIQzOimbVobQ6bQAB7QpFNUjQukQ27QzAobBYcWStgYSDUJmkUi2aGOMRPQIQDIg0iBHiktiZClUmn0xnM1nsznwblgXn8oUisUSyFsaUYWVYeWe27K64YBkOGG6-VsbXQ5yubVNCHY9yeIQCnzo3zQcIDW5LcOw+DpoIuGOJqDJgww4w6bggEIIHiNATkJj+pBoACsIAAvngaPRGMwGXW1p02KIECDnLAWQAhPJmgQaKwaYAItNsJAaWwz+eLtgCWwGHsGAxTjSHviwJpBBdL6ikFcaCgIvd8e+H6iXADkSOoyI-gYAC6Z7UGBF48JmQgABIYvuD7PoQeTUE2EDLgAFAAlGuCIXleN5BM+UB8DweQMIIGD5PAgTYgAyhi8BNksGG2KGiqxARt6BNkXpLLE-CzkxzajOxXqxAUsQWIErIZLYWEANx4aEGj3LAn4ts+CIeBUgSBLQ2LaR4GgYIQMlgBhXFBEyLAkFAAByEJAlhRkeMqtAZBhGijFYOgaLp+nYqZ5kYaq-h2ei1BYRQHzAYpykgoQrLUFAGk+aps5pYyxApV5TQrn5TROhki4DPZg4rquu7wR+B5HiA8WjKYKnUPMaXEaR5EbEy0HwGoCAUWwrEgE0dXgQ1SlNa1cxpUyZjqgAMhAwIYK4UDDYGbCcXw17cbEo0PgA+odB1fvJk0eNNs3XK1gQwQoACyC1aeIpD1NQOiAHwbgCbu548BgDocGznwML-ToEbvfoIAXRoSUoalY0YOiGRmMcADqtwsKFbVjY1l04w+q0wGohQbEtwLCDRw3MhAPDIrYlzYQVGi5oegQYIy1whMs91PcNQMshoP3yY1p7gdQVIs6Q-5bZCpC0C0JytemsT-vA3l8BJ1B5CEUCxIUQSEFApDshq1AXqzSzPtNYKKsNADEluBAzuFNadLbblZgRZXgCLu4+D1SJ7O2Ed7Y2kJcO5u+HdEPcHu13uHvvRw+pAlHR8ehz7CIbDR262JChQM3h5gWHktBDPnRDO9wJ6NWBUEuLBNVpdhk1gXWDbCehj6iF2SAAEwfLEHxIB8vb9iAkxDmq5C8B0GyiL2wE9kAA)
Java / CPython Language Bridge
Published: 2021-03-26 15:08:02

I've implemented support for two-way compatibility between Java and Python/CPython, meaning that Java can import standard CPython modules and use code as if it were Java, and Python can import Java classes and use them as if they were Python classes.

Imports in both languages are done with standard import statements.

## How It Works

Java code imported into Python is subjected to reflection and then Python wrapper classes are generated using the Python API that provide runtime translations between the two language runtimes.  A native Python module is provided that provides the "magic import" functionality from Java to Python (https://qoretechnologies.com/manual/qorus/current/python/html/index.html#python_qoreloader_import_java).

Python code imported into Java is introspected using the Python C API and then bytecode is generated for Java wrapper classes that provide a similar runtime translation as the imports in the other direction.  A custom compiler based on [javax.tools](https://docs.oracle.com/en/java/javase/11/docs/api/java.compiler/javax/tools/package-summary.html) is provided ([QoreJavaCompiler](https://qoretechnologies.com/manual/qorus//gitlab-docs/develop/jni/html/classorg_1_1qore_1_1jni_1_1compiler_1_1QoreJavaCompiler.html)) as well as runtime dynamic code generation support for wrapper APIs in a custom class loader ([QoreURLClassLoader](https://qoretechnologies.com/manual/qorus//gitlab-docs/develop/jni/html/classorg_1_1qore_1_1jni_1_1QoreURLClassLoader.html)) - more info here: https://qoretechnologies.com/manual/qorus//gitlab-docs/develop/jni/html/index.html).

This is all accomplished using a third language called Qore that provides the functionality of a "language bridge" and also manages the references to data in each separate runtime.  Because Qore has a [deterministic garbage collector](https://github.com/qorelanguage/qore/wiki/Prompt-Collection), strong references to Python and Java data are managed in Qore and released when there are no more valid references to the data (in Qore - therefore various tricks are used to manage references transparently including sing thread-local data; there is also the possibility of using custom reference handlers to maintain the validity of objects using different language runtimes and garbage collection implementations).  A high level description of the approach is here: https://drive.google.com/file/d/1QfzoXKoqgm6s1wTTykB0VdnIo4j5p0oK/view?usp=sharing

While support for importing Java into Python has been released, importing Python into Java will be released in April 2021 but is currently working and stable.

The idea is to facilitate the mixed use of enterprise technologies (Java) and AI / data science technologies (Python).

All of the source code required has been released under permissive open source licenses (MIT).

I hope it could be interesting and useful for someone - happy to provide more information if there's interest.