teleren/devto huggingface dataset:
VS Extension That Make Coding Easier 2.0
Tags: vscode
Published: 2023-02-10 17:14:18

1. [Mintlify Doc Writer](#Mintlify-Doc-Writer)
2. [Tabnine AI Autocomplete](#Tabnine-AI-Autocomplete)
3. [UNOTES - Markdown Notes](#UNOTES-Markdown-Notes)


### [Mintlify Doc Writer](https://marketplace.visualstudio.com/items?itemName=mintlify.document)

> Writing documentation sucks. Let Mintlify take care of it. Just hightlight code and see the magic.

![Mintlify](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/47t8zvdidp3a0yqngsfb.png)

Step 1 Highlight code or place cursor on the line you want to document 
Step 2 Click on the Write Docs button (or hit ⌘ + .)

### [Tabnine AI Autocomplete](https://marketplace.visualstudio.com/items?itemName=TabNine.tabnine-vscode)

> Code faster with AI code completions
> AI assistant for software developers

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

### [UNOTES Markdown Notes](https://marketplace.visualstudio.com/items?itemName=ryanmcalister.Unotes)

> Unotes gives you a markdown note editor right inside Visual Studio Code. Don't get distracted with noisy markdown syntax. Enjoy your notes with a rich WYSIWYG editor. Take full control of the markdown when needed. Start taking notes in style!

![unotes](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1hqfem4yh5uqsongwwie.png)

Happy Coding!
Developers Surival Guide, Manual de Supervivencia para Desarrolladores
Tags: webdev, beginners
Published: 2023-02-10 17:10:42

# - Spansih Section -

Bienvenidos a el Manual de Supervivencia para Desarrolladores,
dentro de esta serie, estaré dando consejos para no morir en el intento Desarrollando 😱, mostraremos buenas practicas, ejemplos, documentación, etc... Así que espero que sea de su agrado y les guste esta sección, y claro esto es una parodia a partir del Manual de Supervivencia Escolar de Ned.

---
# - English Section -
Welcome to the Developers Survival Guide,
in this series, I will be giving tips to not die trying to develop 😱, we will show good practices, examples, documentation, etc .... So I hope you like this section, and of course this is a parody from Ned's School Survival Manual.

Resultados no Garantizados.
Results not guaranteed.
© Copyright Zamudio 2023
How to retrieve values from strings using RegEx
Published: 2023-02-10 17:09:37

Hello,

i am trying to retrieve values from below strings using Regular Expression in JavaScript. would you be able to help me out please? it would be separate value for Project Number, Project Name, Insurance Type and the Date.

001196 - La Cabana - Ins Boiler and Machinery – 6/1/21.pdf

Var Project Number= 001196

Var Project Name= La Cabana

Var Insurance Type= Ins Boiler and Machinery

Date=  6/1/21

so far i was able to retrieve Project number using below JavaScript. same way i need to retrieve project name, insurance type and Date without hyphens and pdf.

if (Fidelity == "Ins Fidelity"){
            var projectNumber = fileName.substring(0,6);
        }
        const regex = /[^0-9]/g;
        projectNumber = projectNumber.replace(regex, "");
        builder.SetDocumentMetadata(doc.DocumentId, "Index", "ProjectNumber", projectNumber);
    }

Thanks in advanced!!
Do-while Loop in Solidity
Tags: web3, blockchain, solidity, ethereum
Published: 2023-02-10 17:00:23

>The "do-while" loop in Solidity is a control flow statement that executes its block of code at least once and repeatedly executes as long as the condition specified remains true.

Do-while loop is quite similar to the while loop with the exception that there is a condition check after the loop, which means that the loop will always execute at least once even if the condition is false.

The do-while loop in Solidity is a control flow statement that allows developers to execute a block of code repeatedly until a specified condition is met. This loop differs from the while loop in that the code block is guaranteed to be executed at least once. The syntax of the do-while loop in Solidity is similar to that of other programming languages, with the addition of the "require" statement to ensure that the condition is met before continuing to the next iteration.

The do-while loop is useful for situations where a certain action must be taken at least once, regardless of the value of the condition. For example, if you want to ensure that a certain balance is maintained in a contract, you could use a do-while loop to check the balance and make the necessary transfers to maintain the balance. In this case, the loop would be executed at least once, even if the balance was already sufficient.

When using do-while loops in Solidity, it is important to be mindful of the gas consumption, as each iteration of the loop will require a certain amount of gas. If the loop condition is not met in a reasonable amount of time, it could lead to an out-of-gas error, which could cause the entire transaction to fail. Additionally, care should be taken to ensure that the loop condition is well-defined and will eventually be met, otherwise the loop could run indefinitely, leading to an infinite loop error. To avoid these issues, it is best to test do-while loops thoroughly before deploying them to the main network.

![do](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bqztvdsdzvfs1syfk90y.jpg)

##Syntax:
```
do 
{
   block of statements to be executed
} while 
```
##Do-while loop example
```
//SPDX-License-Identifier:MIT
pragma solidity ^0.8.0; 

// Creating a contract 
contract Types { 
      
    // Declaring a dynamic array
    uint[] data; 
    
    // Declaring state variable
    uint8 j = 0;
  
    // Defining function to demonstrate 
    // 'Do-While loop'
    function loop(
    ) public returns(uint[] memory){
    do{
        j++;
        data.push(j);
     }while(j < 5) ;
      return data;
    }
} 
```
 For more content, follow me on - https://linktr.ee/shlokkumar2303
nyc school chancellor 2023
Published: 2023-02-10 16:55:55

[https://multischolar.com/school-calendar-nyc/](https://multischolar.com/school-calendar-nyc/#utm_source=backlinks&utm_medium=search&utm_campaign=darry+ring+us&utm_content=Michelle)
https://plaza.rakuten.co.jp/chenlee/diary/202302100001/
https://www.provenexpert.com/nyc-school-chancellor/
https://www.producthunt.com/@nycschoolchanc1
https://www.divephotoguide.com/user/nycschoolchancellor/
https://vocal.media/authors/nycschoolchancellor
https://www.lifeofpix.com/photographers/nycschoolchancellor/
https://seedandspark.com/user/nycschoolchancellor
https://rosalind.info/users/nycschoolchancellor/
http://phillipsservices.net/UserProfile/tabid/43/userId/198459/Default.aspx
https://app.roll20.net/users/11614184/nycschoolchancellor
https://speakerdeck.com/nycschoolchancellor
https://social.msdn.microsoft.com/Profile/nycschoolchancellor
https://camp-fire.jp/profile/nycschoolchancellor
https://plazapublica.cdmx.gob.mx/profiles/nycschoolchancellor/activity
https://www.metal-archives.com/users/nycschoolchancellor
https://storium.com/user/nycschoolchancellor
https://trabajo.merca20.com/author/nycschoolchancellor/
https://www.intensedebate.com/people/nycschoolchance
https://www.mifare.net/support/forum/users/nycschoolchancellor/
https://pinshape.com/users/2571991-nycschoolchancellor
http://foxsheets.com/UserProfile/tabid/57/userId/120566/Default.aspx
https://www.kompasiana.com/nycschoolchancellor
https://www.credly.com/users/nyc-school-chancellor/badges
https://www.myminifactory.com/users/nycschoolchancellor
https://www.sqlservercentral.com/forums/user/nycschoolchancellor
https://www.longisland.com/profile/nycschoolchancellor
https://guides.co/a/nyc-school-chancel/
https://myanimelist.net/profile/nycschoolchance
https://www.iheart.com/podcast/269-nyc-school-chancellor-108659187/
CodePen Designs - 35 : 3D Ecommerce Experience with Spline
Tags: codepen, css, webdev, design
Published: 2023-02-10 16:39:00

### We are excited to introduce our new series that will explore the best design ideas from the Codepen community. 

We will be publishing these each day and hope you find them insightful and inspiring as we showcase some of the most talented designers in this space.

---


#### Codepen Design - 35

<p>3D experience made with Spline.</p>

<p>Credits: 3D shoe made by Przemek Gesicki, downloaded on Sketchfab.</p>

{% codepen https://codepen.io/jorgecheevers/pen/QWBPzmJ %}


---
## For more information

1. Check my GitHub profile
[https://github.com/amitSharma7741](https://github.com/amitSharma7741)

2. Check out my youtube channel 
[https://www.youtube.com/channel/UCTBG1pUL9HtP4ntbj63Fngw](https://www.youtube.com/channel/UCTBG1pUL9HtP4ntbj63Fngw)

3. Check out my Fiver profile if you need any freelancing work
[https://www.fiverr.com/amit_sharma77](https://www.fiverr.com/amit_sharma77)

4. Check out my Instagram
[https://www.instagram.com/fromgoodthings/](https://www.instagram.com/fromgoodthings/)

5. Linktree
[https://linktr.ee/jonSnow77](https://linktr.ee/jonSnow77)

6. Check my project

- EVSTART: Electric Vehicle is the Future
[https://evstart.netlify.app/](https://evstart.netlify.app/)
-  News Website in react
 [https://newsmon.netlify.app/](https://newsmon.netlify.app/)
-  Hindi jokes API
 [https://hindi-jokes-api.onrender.com/](https://hindi-jokes-api.onrender.com/)
- Sudoku Game And API
[https://sudoku-game-and-api.netlify.app/](https://sudoku-game-and-api.netlify.app/)

---
---
 
--- 
## Support us 
Don't miss the amazing video we've embedded in this post! Click the play button to be inspired

{% youtube  p6t7Iprd-38 %}

---
Career Development by Planting Acorns
Tags: career
Published: 2023-02-10 16:32:41

[Richard Hamming](https://en.wikipedia.org/wiki/Richard_Hamming) gave a famous talk called ["You and Your Research"](
https://www.cs.virginia.edu/~robins/YouAndYourResearch.html) in which he had many great insights on doing world-class work, including this gem:

> The great scientists often make this error. They fail to continue to plant the little acorns from which the mighty oak trees grow. They try to get the big thing right off. And that isn't the way things go. 

Something to think about when moving to a new project, new role, or an unfamiliar tech stack. Take the time to learn the little things, put in the work, and give those seeds the proper time to grow...
Nodejs: How much ram does a basic node app use?
Tags: node, ram, memory
Published: 2023-02-10 16:08:48

The answer is: **32mbs of ram.**

I got this by setting up a basic node server _(i am running node v16.14.0)_ and used [PM2](https://pm2.io/) to monitor its usage:
![Screen shot of nodejs memory consumption](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/95onhrh0si0g0rumbqjm.png)

Code ran:
```js
import * as http from 'node:http';

const PORT = 8000;

http.createServer(async (req, res) => {
  res.
  writeHead(200, { 'Content-Type': 'text/html' })
  .end("hello");
}).listen(PORT);

console.log(`Server running at http://127.0.0.1:${PORT}/`);
```

This test was done to know the baseline of a nodejs runtime so you can understand your codes memory impact and work to improve from there.

Thanks,
Gregg
Astro + Storyblok: SSR Tips and Tricks
Tags: astro, storyblok, cms, javascript
Published: 2023-02-10 16:01:07

This is a companion post to [Astro + Storyblok: SSR preview for instant visual editing](https://dev.to/jgierer12/astro-storyblok-ssr-preview-for-instant-visual-editing-3g9m). Please read it first if you haven't already!

Below you'll find some extra tips and tricks I've discovered while developing my Astro + Storyblok site.

### Remove drafts from the production site

To avoid loading draft content in production, I created a wrapper function for the Storyblok API:

```ts
// src/storyblok/utils.ts

import * as sb from '@storyblok/astro';

export const storyblokApi = (slug: string, params?: sb.ISbStoryParams) => {
  const api = sb.useStoryblokApi();

  return api.get(slug, {
    version:
      import.meta.env.PUBLIC_ENV === 'production' ? 'published' : 'draft',
    ...params,
  });
};
```

You can then use this wrapper wherever you would've used the Storyblok API, e.g.:

```ts
// src/pages/[slug].astro

import { storyblokApi } from '../storyblok/utils';

export async function getStaticPaths() {
  const { data } = await storyblokApi('cdn/links');
  let links = data.links;
  links = Object.values(links);

  return links
    .filter((link: any) => !['index', 'site-config'].includes(link.slug))
    .map((link: any) => {
      return {
        params: { slug: link.slug },
      };
    });
}

// ...
```

### Prevent search engine indexing of the preview site

You probably don't want your preview site containing drafts and unfinished content to be indexed by search engines. To prevent that, use the [`astro-robots-txt`](https://github.com/alextim/astro-lib/tree/main/packages/astro-robots-txt#readme) integration:

```sh
npx astro add astro-robots-txt
```

```ts
// astro.config.{mjs,ts}

import robotsTxt from 'astro-robots-txt';
// ...

export default defineConfig({
  // ...
  integrations: [
    robotsTxt({
      policy: [
        {
          userAgent: '*',
          disallow: process.env.PUBLIC_ENV !== 'production' ? '/' : '',
        },
      ],
    }),
    // ...
  ],
  // ...
});
```

### Disable `astro-imagetools` image processing in SSR

I found that my SSR pages loaded very slowly because I was using [`astro-imagetools`](https://github.com/RafidMuhymin/astro-imagetools) to process images. Since optimized images aren't necessary during editing anyways, I created a wrapper component to bypass image processing in the preview environment:

```astro
---
import type { Picture } from 'astro-imagetools/components';

export type Props = Parameters<typeof Picture>[0];

let {
  breakpoints = [500, 900, 1800], // fallback breakpoints
  class: pictureClass = '',
  ...props
} = Astro.props;

let Component;
if (import.meta.env.PUBLIC_ENV === 'preview') {
  Component = 'img';
  props = {
    class: pictureClass,
    ...props,
  };
} else {
  Component = (await import('astro-imagetools/components')).Picture;
  props = {
    breakpoints,
    attributes: {
      picture: {
        class: pictureClass,
      },
    },
    ...props,
  };
}
---

<Component {...props} />
```
Symbiosis - Managed Kubernetes
Tags: kubernets, devops, containers, cloud
Published: 2023-02-10 15:44:11

Hi! I’m Sauraj and I wanted to introduce a project I’m part of building called [Symbiosis](https://symbiosis.host/) that we launched last year!
We’re building a significantly cheaper managed k8s service with the goal of simplifying management and day-2 operations. We’re happy to say that we’re helping several EU-based developers and companies with their production k8s and we’re now planning to take our service to a wider audience.
I’d love for you to try it out. I would also be happy to receive any comments, questions or feedback you have. In case you’re interested, we just launched our [discord](https://discord.com/invite/bd4DKsgtkS) channel.
Polaris bank codes and info
Published: 2023-02-10 15:40:36

[https://www.bankfanz.com/polaris-bank-transfer-code/](https://www.bankfanz.com/polaris-bank-transfer-code/#utm_source=backlinks&utm_medium=search&utm_campaign=darry+ring+us&utm_content=Michelle)

https://plaza.rakuten.co.jp/polarisbankcode1/diary/202302100000/
https://peatix.com/user/15902270/
https://www.provenexpert.com/polaris-bank-code-to-check-balance-20232/
https://www.producthunt.com/@polarisbank4
https://www.divephotoguide.com/user/polarisbankcode4
https://wakelet.com/@Polarisbankcodetocheckbalance202360
https://vocal.media/authors/polaris-bank-code-to-check-balance-2023-9ggaga0rq8
https://www.lifeofpix.com/photographers/polarisbankcode4/
https://seedandspark.com/user/polaris-bank-code-to-check-balance-2023
https://rosalind.info/users/Polarisbankcode4/
http://phillipsservices.net/UserProfile/tabid/43/userId/198401/Default.aspx
https://app.roll20.net/users/11613438/polaris-bank-code-to-check-balance-2
https://speakerdeck.com/polarisbankcode4
https://social.msdn.microsoft.com/profile/polaris%20bank%20code%20to%20check%20balance%202023/
https://camp-fire.jp/profile/polarisbank4
https://plazapublica.cdmx.gob.mx/profiles/polarisbankcode4/activity
https://www.metal-archives.com/users/polarisbankcode4
https://storium.com/user/polarisbankcode4
https://trabajo.merca20.com/author/polarisbankcode4/
https://www.intensedebate.com/people/Polarisbank4
https://www.mifare.net/support/forum/users/polarisbankcode4/
https://pinshape.com/users/2571751-polarisbank4
http://foxsheets.com/UserProfile/tabid/57/userId/120522/Default.aspx
https://www.kompasiana.com/polarisbank3
https://www.credly.com/users/polaris-bank-code-to-check-balance.c3dc6bdd/badges
https://www.myminifactory.com/users/polarisbankcode4
https://www.sqlservercentral.com/forums/user/polarisbankcode4
https://www.longisland.com/profile/polarisbankcode4
https://guides.co/a/polaris-bank-2037
https://myanimelist.net/profile/Polarisbankcode4
Challenge #2: 🏵 Token Vendor
Tags: web3, blockchain, solidity, javascript
Published: 2023-02-10 15:36:24

## Tasks to be done

🤖 Smart contracts are kind of like "always on" *vending machines* that **anyone** can access. Let's make a decentralized, digital currency. Then, let's build an unstoppable vending machine that will buy and sell the currency.

## My Review

This was a fun challenge because I got to create my own crypto [KevinCoin](https://goerli.etherscan.io/token/0xccdba9c461ffe52b480e2899975ead2341ff70b1) which is priced at 0.01 ETH 😎 (on a testnet 🫠) This challenge essentially teaches you about the ERC 20 standards and how it works, its mechanism of approve, why it exists and so much more...

## Important links

- [Speed Run Ethereum](https://speedrunethereum.com/challenge/token-vendor)
- [Deployed webapp](https://kevinj-sre-c2.surge.sh/)
- [Deployed contract](https://goerli.etherscan.io/address/0x84ab81388e155D697291300F4Ed0e493E988c513)
- [Project source code](https://github.com/kevinjoshi46b/speedrunethereum/tree/master/challenge-2-token-vendor)
Ruby, accelerated
Tags: beginners
Published: 2023-02-10 15:32:31

Wrapping up week 2 of my learning journey. This past week has been an accelerated introduction to core Ruby concepts: arrays, hashes, loops, methods, classes, objects. Whew! Our class has been working through the Treehouse online learning modules, which are mostly well-done video tutorials paired with a few quizzes along the way.

It feels like the knowledge instantly drains away right after I've learned a new concept. I can't wait to put the knowledge into practice on my own project soon.
Trigger do evento submit fora do formulário sem a necessidade de javascript
Published: 2023-02-10 15:29:20

Já precisou construir um formulário e o botão de submit ficava fora do elemento `<form>`, ai bateu a dúvida de como fazer o trigger do evento?

Existe uma forma nativa no html pra lidar com isso, o atributo form da tag `<button>`.

O tributo form espeficica o formulário ao qual o botão pertence. O valor para essa propriedade tem que ser igual ao id do elemento `<form>` em questão e estar no mesmo documento .html.

No exemplo abaixo, mostro um counter, onde ao submit do form, o valor do input é somado ao estado do counter.

```html
    <div>
      <button form="form">submit</button>
      <button type="reset" form="form">reset</button>
      <form id="form">
        <input
          type="number"
          name="my-first-input"
          placeholder="my first input"
        />
      </form>
    </div>
    <span id="display">0</span>
```

```js
      const display = document.querySelector("#display");
      const input = document.querySelector("input[name='my-first-input'");
      const reset = document.querySelector("button[type='reset']");

      const form = document.querySelector("form");
      form.addEventListener("submit", (event) => {
        event.preventDefault();
        const { value } = input;

        display.innerHTML = Number(display.innerHTML || 0) + Number(value);
      });

      reset.addEventListener("click", () => {
        display.innerHTML = 0;
      });
```

**preview**
{% embed https://codesandbox.io/embed/form-submit-com-o-botao-fora-do-formulario-6ncnvr?fontsize=14&hidenavigation=1&theme=dark %}

Se quiser testar e editar tu mesmo, da uma olhada nesse exemplo: 

https://codesandbox.io/s/cold-butterfly-6ncnvr?file=/index.html:115-295

## Conclusão

Nem sempre precisamos utilizar javascript para realizar algumas tarefaz de manipulação do html, as vezes já existe alternativas nativas do html que vão te poupar código e tempo.

Foi útil pra ti? sinta-se livre pra me seguir no [Twitter](https://twitter.com/Censuradho/)
How to handle threads with multiple gunicorn workers to get consistent result
Tags: python, flask, threading, gunicorn
Published: 2023-02-10 15:24:28

Hi I have a flask app which needs to run a background task at certain intervals,I have tried to achieve this by using threading.The issue is my server needs to handle lots of request coming to it and so I assigned multiple workers in gunicorn to handle it but when I do that my background task gives inconsistent result,for a certain time interval it should be executed only once but sometimes it gets executed multiple times instead.If i reduce the worker count to 1 in gunicorn the background tasks behave as expected.

```
import time
import threading


def writemotiondata():

    deviceid='abcdd33656'
    while True:
            response = openapi.get("/v1.0/devices/{}".format(deviceid))
          
            result = response['result']
            status = result['status']
            value = status[0]['value']


            print(value)
            if (value == True):
                tempdata = motiondata.find()
                previousdata = [{item: key[item] for item in key if item != '_id'} for key in tempdata]

                if len(previousdata) == 0:

                    data = {"sensorname": "pir",
                            "numberofpeople": 1}
                    motiondata.insert_one(data).inserted_id
                   
                else:
                    count = previousdata[0]['numberofpeople']
                    count += 1
                    filter = {"sensorname": "pir"}
                    updateddata = {"$set": {"numberofpeople": count}}
                    motiondata.update_one(filter, updateddata)

                time.sleep(40)
              

            else:
                
                time.sleep(10)
               



if __name__ == '__main__':
    t1 = threading.Thread(target=writemotiondata)
    t1.start()
    app.run(debug=True)
```
Can anyone please help me how to get consistent result for this background task using multiple workers in gunicorn. I have tried using thread lock but it didn't work.Thanks in advance.
Union bank ussd code
Published: 2023-02-10 15:23:34

<a href="https://www.bankussdcode.com/union-bank-transfer-code/#utm_source=backlinks&utm_medium=search&utm_campaign=darry+ring+us&utm_content=Michelle">https://www.bankussdcode.com/union-bank-transfer-code/</a>

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hqf7zyndge1xwjgdz8is.jpg)
TIL. LearningLoops&RevisingCollections(Arrays&Hash)
Tags: ruby, hash, array, beginners
Published: 2023-02-10 15:13:50

first time around when going through the lessons of arrays and hash, i had an extremely hard time understanding (i forgot my headphones so i wasn't fully focuses) but after looking at the module again i was able to put it all together. 

The thing about ruby that stresses me out is how literal and down to the point it is but sometimes when the questions are asked to put it to practice makes it more difficult than writing the code itself.