teleren/devto huggingface dataset:
How to create Javascript num.toString(base) method?
Tags: javascript
Published: 2020-08-30 01:58:31

Hi guys, I have recreated toString method of number type in javascript to have some understanding about the method. I wanted to share it with you guys.

Generally, toString(base) method will convert a given number to the base specified as argument, for example:

let num = 255;
console.log(num.toString(16)) => 'ff'
console.log(num.toString(2)) => '11111111'
console.log(num.toString(8)) => '377'

As you can see toString method will convert a number to the specified base.
255 got converted to 'ff' -> 'ff' is 255 in base-16(Hexdecimal number), '11111111' is 255 in base-2(Binary number), '377' is 255 in base-8(Octal Number).

You can pass a base number between 2-36 to toString method, and the method will convert the number to the provided base and return the result as a string.

I have created a function toString which will exactly do the same, pass the number and base to the function, it will convert the number to the supplied base and return the result as a string. Here is the toString function,

```javascript

function toString(num, base) {
  
  let arr = [];  //array for holding the remainder

  const baseArr = [
     0 ,  1 ,  2 ,  3 ,  4 ,  5 ,  6 ,  7 ,
     8 ,  9 , 'a', 'b', 'c', 'd', 'e', 'f', 
    'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 
    'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
    'w', 'x', 'y', 'z'
  ]; //baseArray for conversion

  while (num >= base) {
    remainder = num % base;
    num = num / base;
    num = Math.trunc(num);

    arr.unshift(remainder);
  }
  arr.unshift(num);

  let result = [];
  for (let i=0; i<arr.length; i++) {
    result.push(baseArr[arr[i]]);
  }

  return result.join('');
}

console.log(toString(255, 8)); // Output: '377'
console.log(toString(255, 16)); // Output: 'ff'
console.log(toString(255, 2)); // Output: '11111111'

```

Here, I have a baseArr to represent base number system, if we pass 16 as base to toString method, the array 0 to 15 will be picked for conversion, for base-36 the whole array will be taken for conversion. 

Then, I am performing division on the number and getting the remainder from the number, if the remainder is 10, then it will be converted to string 'a' using the baseArr.

We can create a similar function like this for encryption. I will say 'ff' to you, if you're from programming world, you will understand 'ff' means the number 255 in base-16 system. Encryption works like that.

I hope this post will give you some idea about the method toString and its uses. Thank you
Downloading...
Tags: beginners, sql, database
Published: 2020-08-30 01:34:53

Welcome!

My name is Pranav Gowtam, but I'm also known as Incerah. I am a first-year student at Penn State, currently majoring in Cybersecurity Analytics & Operations. This post marks one of my first steps into the professional world.

During my time in high school, I spent a lot of my time involved in extracurricular activities. However, one that has influenced was Penn State Berks' Computer and Cybersecurity Camp in the summer of 2018, which introduced me to the security field. While my overall knowledge may not be as deep as some of my peers, I am motivated to continue learning and become a more well-rounded student.

For the foreseeable future, I plan to use this site to document my adventures in the professional world. I hope you stick around as well.

Alongside this blog, I will also be uploading videos onto my YouTube channel as I continue to develop my skills in the IT field. For my first video, I'll be talking about the differences between SQL and NoSQL. 

{% youtube 3mgFr6jsHmU %}

For those who would like a bit of a TL;DW, here is some of the notes I made while researching for this video. You can find the full notes in the Pastebin link in the video's description.

- Both are types of databases. As a result, they have the same goal of storing data. The differences come in the way that they accomplish this task.
- SQL databases are relational while NoSQL databases are not. Relational databases define relationships using tables. NoSQL utilizes more a column system.
- SQL databases are vertically scalable (can increase load on server by adding things such as CPU or RAM), NoSQL is horizontally scalable (increase load by adding more servers). Imagine building more floors on a singular apartment complex versus making more houses in a large-spanning neighborhood.
- SQL uses a predefined schema, NoSQL uses dynamic schemas. For SQL, a lot of preplanning has to be in place because if there comes a time where a structural change is required, it is a large hassle to do so as all of the data within the database needs to have this change applied. Contrastingly, for NoSQL, it allows for a flexible schema that allows the user to change data structure more efficiently than SQL.

I hope I didn't stutter or pause too much; I haven't made videos like these in years, so I'm still a bit rusty. As time goes on, I'm sure that I will become more eloquent regarding my explanations. I also avoided doing too many jump-cuts just so I could see how I would do naturally.

While this may be just something I'll be doing for class for this semester, I plan to turn this into something beyond just an assignment page. In the future, when I start getting my feet wet with personal projects, I plan to keep a solid log of my development here alongside other topics. So, please consider subscribing to my YouTube channel and following here!

Thanks for reading!
Pranav/Incerah
Why Do Software Developers Need a Physiotherapist?
Tags: productivity, career
Published: 2020-08-30 01:23:09

This content was originally posted in my blog, [The Product Engineer](https://jorgeferreiro.com/blog).
If you like it, head over there or follow me on Twitter ([@jgferreiro](https://twitter.com/jgferreiro)) for more!

---

# The story
Last week I took a trip to a beautiful city in Spain, Mallorca. Since it was one of those rare times in the year when I disconnect from social media and the Internet I decided to treat myself to a nice massage, which I only do rarely.

While I was taking the massage, María, the physiotherapist, kindly asked me, “How many hours a day do you spend in a chair?” I said “It depends, but it could go anywhere from 6 hours to 12 hours per day. And most of those times I’m writing documents or code on my computer. I’m a Software Developer”. After that, she told me “Well. I didn’t even need you to tell me that, your back and arms are really stiff. Your job is probably one of the hardest for harming your body”.

At first, I was a bit shocked cause I’m young and never feel any issues over my arms or back, but she told me that long term I’ll suffer. When she said so, this thought came to mind: “To some extent, **Software Developers are professional athletes who need to do high performance using their hands, brain, and back**. If professional athletes take care of their bodies with doctors and trainers, why am I not doing so?”.

I’ve experienced headaches on occasion after spending too long at the computer. María told me that when your neck is stiff, that could affect other parts of your body like the head. This shocked me as well, cause I’ve never thought that a bad posture could cause a headache 🤷‍♂️

# Action items
After the trip, I decided that I need a plan of action, and here is what I came up with:
* Getting a couple of armrests for the keyboard and mouse.
* [Buying a mechanical keyboard](https://drop.com/buy/drop-alt-mechanical-keyboard?utm_source=linkshare&referer=QGQDLT) to help me get more feedback when I’m typing and fewer hands fatigue.
* Book a massage once per month. María told me it would be better with two, so I’ll probably try to increase the frequency in the long run.

## Extended action items

Adding a couple of ideas from Matthias Tretter (@myell0w) he commented on [Twitter](https://twitter.com/myell0w/status/1300100024794308610):
* Standing desk
* Stretching breaks (once per hour at minimum)
* Do some sports or walking for 30 minutes.

Now I want to ask you: How do you take care of your body as a Software Developer? Let me know on the comments, [Twitter](https://twitter.com/jgferreiro) or [Linkedin](https://www.linkedin.com/in/jgferreiro/).

See you at the physio!
Run arbitrary commands via a comment and commit the changes
Tags: actionshackathon
Published: 2020-08-30 01:15:11

**DISCLAIMER**: the [`Run terminal command` GitHub Action](https://github.com/neverendingqs/gh-action-terminal) allows for _arbtrary_ code execution by any user allowed to comment on your issues or pull requests. You should probably never use this except to explore what GitHub Actions could do.

To avoid security issues, replace the use of the [`Run terminal command` GitHub Action](https://github.com/neverendingqs/gh-action-terminal) with something that validates input or with something that always runs the same command.

### My Workflow

This workflow allows you to run any command and commit the changes back into a pull request. For example, you can run `/terminal npm version patch --no-git-tag-version` to bump the patch version of your Node package.

This workflow:

* Only runs on new pull request comments and only if the comment starts with `/terminal `
* Acknowledges comments that start with `/terminal ` by reacting with a `+1`
* Determines what pull request the comment came from and gets the corresponding branch name
* Checks out the code at that branch
* Runs the command, commits the changes, and pushes it back to the branch

### Submission Category: 

Maintainer Must-Haves

### Yaml File or Link to Code

```yaml
on:
  issue_comment:
    types: [created]

jobs:
  run-and-update:
    if: contains(github.event.comment.html_url, '/pull/') && startsWith( github.event.comment.body, '/terminal ' )
    runs-on: ubuntu-latest
    steps:
      - name: Acknowledge command
        uses: actions/github-script@v3
        with:
          script: |
            github.reactions.createForIssueComment({
              comment_id: context.payload.comment.id,
              owner: context.repo.owner,
              repo: context.repo.repo,
              content: '+1',
            });
      - id: get-ref
        name: Get branch name
        uses: actions/github-script@v3
        with:
          result-encoding: string
          script: |
            const response = await github.pulls.get({
              owner: context.repo.owner,
              repo: context.repo.repo,
              pull_number: context.payload.issue.number
            });

            return response.data.head.ref;
      - uses: actions/checkout@v2
        with:
          ref: ${{ steps.get-ref.outputs.result }}
      - uses: actions/setup-node@v1
        with:
          node-version: '12'
      - id: terminal
        uses: neverendingqs/gh-action-terminal@main
      - run: |
          git config user.name github-actions[bot]
          git config user.email 41898282+github-actions[bot]@users.noreply.github.com

          git commit -am "chore: update after '${COMMAND}'."
          git push
        env:
          COMMAND: ${{ steps.terminal.outputs.command }}
```

### Additional Resources / Info

* [actions/checkout](https://github.com/actions/checkout)
* [actions/github-script](https://github.com/actions/github-script)
* [`Run terminal command` GitHub Action](https://github.com/neverendingqs/gh-action-terminal)
9 นิสัยเล็กๆ ที่จะเปลี่ยนชีวิต
Tags: habit, productivity
Published: 2020-08-30 01:09:27

---
title: 9 นิสัยเล็กๆ ที่จะเปลี่ยนชีวิต
published: true
description: นิสัยเล็กๆ เมื่อทำๆ ไปจะเป็นผลดีในระยะยาว และจะเปลี่ยนชีวิตเรา มี 9 ข้อ
tags: habit, productivity
//cover_image: https://direct_url_to_image.jpg
---

ฟังจาก Podcast ของ Mission to the Moon มาตอน [นิสัยเล็กๆ มากๆ ที่จะเปลี่ยนชีวิตคุณในหนึ่งปี](https://open.spotify.com/episode/1B6o6dldtjgIHVLZ7Tqdgh?si=T2zrXPSJSy6-8YzY7YzwLA&context=spotify%3Ashow%3A4y8NZOg9W9IiR4Xh6YZWzX) ขอมาสรุปจดไว้ 😊

นิสัยเล็กๆ เมื่อทำๆ ไปจะเป็นผลดีในระยะยาว และจะเปลี่ยนชีวิตเรา มี 9 ข้อ

1. อย่าตอบสนอง ตอบโต้เร็วเกินไป
1. ทำงานให้เสร็จในตอนที่ไม่รู้สึกอยากทำ เช่น ล้างจาน ก็ล้างให้เสร็จๆ ไป
1. ใช้ชีวิตสัก 1 วันโดยไม่เข้า social media
1. เตรียมตัว เตรียมของ เตรียมงานในวันถัดไป ก่อนวันรุ่งขึ้นตอนกลางคืน จะทำให้วันรุ่งขึ้นมีพลังมากขึ้น
1. กินอย่างมีสติ เวลากินก็ให้คิดถึงแต่เรื่องกิน
1. กำหนดเวลาทำ task แบบ time boxing ต้องมีการจับเวลาเกิดขึ้น
1. วางมือถือวางไว้ไกลๆ จากตัวที่สุด โดยเฉพาะเวลานอน
1. เวลาอยากได้อะไร ให้รอก่อน ถ้าต้องการจริงๆ ค่อยกลับมา หรือเวลาเจอป้าย sale ให้ถามตัวเองว่า ถ้าเป็นราคาเต็มยังจะซื้ออีกไหม จะได้รู้ว่าเราต้องการจริงๆ หรือเปล่า
1. เขียนทุกไอเดียที่เกิดขึ้น
[Video] Using React Hook Form Field Array in a Modal Form
Tags: react, javascript, ionic, tutorial
Published: 2020-08-30 00:13:22

###Overview
Create an "Objective" that has subtasks that are required to complete the Objective. Use React Hook Form fields Array functionality to create and Ionic Framework React Components to create a component for a modal form to capture the data.

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

###Whats Covered In The Video
►  1:56 Coding Starts - creating a form with dynamic list items
►  9:38 Passing the form’s data back to parent in a structured object using react hook form
►  13:36 Creating a reusable component, passing properties and calling functions for success in parent component
►  18:07 Going All in with React Hook Form for all input fields
►  21:45 Using Ionic React Components for styling
►  26:24 Deleting Items from the form array
►  27:29 Adding ids to subtasks in the array using an hidden input field
►  29:40 Wrap up

###The Video
{% youtube 61AlrA5BXzg %}

###Source Code
{% gist https://gist.github.com/aaronksaunders/ae969f50193a6a4ae9953a39a249a35c %}
#30DaysOfCJS: Authentication for the REST of Us
Tags: community, javascript, auth, jwt
Published: 2020-08-30 00:10:48

---
title: #30DaysOfCJS: Authentication for the REST of Us
published: true
description: #30DaysOfCJS Day 28, Authentication for the REST of Us
tags: community, javascript, auth, JWT
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/yx1fwl63v0v2o5wyd3wp.png
series: 30DaysOfCJS
---

*This is a follow up post for Day 28 of* **#30DaysOfCJS**, *learn more about* **#30DaysOfCJS** *here* {% link jimcalliu/30daysofcjs-1jd3 %}

**Authentication for the REST of Us | Divya Sasidharan | CascadiaJS 2019**

{% user shortdiv %}

If you'd like to watch the talk, here is the Youtube link.
{% youtube wma2f_cqRnw %}

Further readings:
- [Roll your own JWT](https://login-to-gated-site.netlify.app/)
- [Sign in example](https://github.com/shortdiv/planet-express-delivery-portal)
- [Call an API example](https://github.com/shortdiv/zoom-me-in)
- [Learn Identity](https://auth0.com/docs/videos/learn-identity-series)
How to get all the script tags from HTML documents using JavaScript?
Tags: javascript
Published: 2020-08-30 00:00:00

---
  title: How to get all the script tags from HTML documents using JavaScript?
  published: true
  tags: JavaScript
  date: Sun Aug 30 2020 05:30:00 GMT+0530 (India Standard Time)
  canonical_url: https://melvingeorge.me/blog/get-all-script-tags-html-dom-javascript
  cover_image: https://melvingeorge.me/_next/static/images/main-032a6055294f1a808d84c44d1ba09608.jpg
  ---
  [Originally posted here!](https://melvingeorge.me/blog/get-all-script-tags-html-dom-javascript)
  
To get all the script tags from an HTML document or the DOM, you can use the `document.scripts` property.

Let's say you have many script tags in your HTML file like this,

```html
<script src="script1.js"></script>
<script src="script2.js"></script>
<script src="script3.js"></script>
```

Let' use the `document.scripts` property to get all the script tags using JavaScript

- The property returns the script tags as an `HTMLCollection` Object.

```javascript
// get all script tags
const scriptTags = document.scripts;

console.log(scriptTags);
```

To see the working example see [JSBin](https://jsbin.com/xogifeteva/3/edit?html,js,console).

### Feel free to share if you found this useful 😃.

---
Why I freelance, and why should you too.
Tags: freelancing, career
Published: 2020-08-30 19:12:51

---
title: Why I freelance, and why should you too.
published: true
cover_image: https://www.kartikey.dev/assets/perks-of-freelancing.jpg
date: 2020-08-30 00:00:00 UTC
tags: freelancing, career
canonical_url: https://www.kartikey.dev/2020/08/30/why-do-i-freelance-and-why-should-you-too.html
---

I kicked off my career by working at a typical 9 to 6 IT firm. A few days into the job, I realized I was wasting my time. Outside the office, I wouldn't need a break, even after working for hours. But at the office, I would keep eyeing the clock, and there were many others like me! So I realized I wasn't malfunctioning! 

You cannot command the mind to kindle the mood to work when you feel like starting your day late or feel like cooking a delicious meal, or come across something worth learning and spending a few hours over. However beautiful the weather is outside you cannot tell your boss that you are going out for a walk!

I have been working as a freelancer for five years and have been enjoying every moment of it. I work for around 35 hours a week and don’t have the pressure to follow the routine. I work from anywhere, don’t have to report to anyone, and take out a good time for myself and my family!

I also choose with whom I want to work. After interacting with the client initially, if I feel that the client and I have different work philosophies fundamentally, I can choose not to work with them! For example, my work philosophy is that unless there is an emergency, I never work for more than 40 hours, and I prefer writing tests with the code. If a client wants me to work over weekends and for more than 8 hours a day just because they want to release their product early, I can decide not to take such projects.

Let’s talk about money! As a freelancer, you are [rarely underpaid](https://www.businessnewsdaily.com/7959-freelance-pay-rates.html), as you can charge your client according to your skills and effort. Whereas in a job, people are often underpaid. Additionally, if you are salaried, you need to wait for your company to give you an increment regardless of how much expertise you have attained, unlike in freelancing.
 
In the end, I feel that you should either work for yourself or work for a company that values you and your growth because life is too short to slog and be underpaid!
Implemente os Azure YAML Pipelines NESSA sprint!
Tags: azure, devops, yaml
Published: 2020-08-29 23:58:22

Tem algum tempo que a Microsoft anunciou a [disponibilidade geral dos pipelines YAML](https://docs.microsoft.com/pt-br/azure/devops/release-notes/2020/sprint-168-update#multi-stage-pipelines-ga) para todos os estágios dos ciclos de vida das aplicações, e qual é a diferença entre esses pipelines e os antigos, baseados em interface?

## As diferenças: 

Bom, falo com propriedade quando digo que administrar um pipeline comum é realmente simples, mas como tudo na vida de quem é de tecnologia, a coisa muda de figura quando escalamos...

E aqui a complexidade também é exponencial, tente administrar uma centena de pipelines usando a interface da Microsoft e você vai saber o que quero dizer, toda alteração, por menor que seja, tem que ser feita para **todos os pipelines**, e não há alteração em lote, nem API, somente o trabalho manual e repetitivo vai aplicar aquela correção imprescindível que garante a entrega do código. :)

Nos pipelines YAML esse cenário muda e muito! O [uso de templates](https://docs.microsoft.com/pt-br/azure/devops/pipelines/process/templates?view=azure-devops) garante a modularização e facilita a correção e melhoria em lote.

Além de ser muito simples copiar e colar partes de arquivos YAML, bem mais rápido que navegar pela interface, mesmo que você seja o Ayrton Senna dos mouses...

E **não ouse** se preocupar em decorar as tasks, temos uma extensa documentação e um assistente muito legal para gerar e alterar as tasks.

## Mas, eu vou ter só um pipeline por repositório?

Só se você quiser! A recomendação da Microsoft é que o arquivo contendo o YAML do pipeline se chame `azure-pipelines.yaml` e que ele fique na raiz do repositório, mas isso é só uma recomendação, o importante é fazer o apontamento certo na tela de criação de pipelines e você pode se organizar como preferir.

## Mas, o pipeline vai executar inteiro, todas as vezes?

Não precisa ser assim, [temos as conditions](https://docs.microsoft.com/pt-br/azure/devops/pipelines/process/conditions?view=azure-devops&tabs=yaml)!

E tem ainda mais, alterou o `README.md` e não quer que isso dispare toda uma série de tarefas? [Use os filtros](https://docs.microsoft.com/pt-br/azure/devops/pipelines/repos/azure-repos-git?view=azure-devops&tabs=yaml#ci-triggers)!

## Mas afinal, como implementar? 

Temos um [guia](https://docs.microsoft.com/pt-br/azure/devops/pipelines/create-first-pipeline?view=azure-devops&tabs=java%2Cyaml%2Cbrowser%2Ctfs-2018-2) para quem está começando!

## E mais uma coisa!

**Todo** o processo de CI/CD, build, testes, release e qualquer outro estágio que você possa vir a precisar, pode e deve ser implementado, inclusive no mesmo arquivo.

Para conseguir a divisão lógica da qual você vai precisar nesse ponto, use a sepração de stages, como é explicado [aqui](https://docs.microsoft.com/pt-br/azure/devops/pipelines/process/stages?view=azure-devops&tabs=yaml).
Logical assignment operators in JavaScript
Published: 2020-08-29 23:53:35

Logical assignment operators in JavaScript combine Logical Operators and Assignment Expressions.

```js
//"Or Or Equals"
x ||= y;
x || (x = y);
```

```js
// "And And Equals"
x &&= y;
x && (x = y);
```

```js
// "QQ Equals"
x ??= y;
x ?? (x = y);
```

So, say you have a function `updateID` it can vary in the below ways:

```js
const updateID = user => {

  // We can do this
  if (!user.id) user.id = 1

  // Or this
  user.id = user.id || 1

  // Or use logical assignment operator.
  user.id ||= 1
}
```

You could also use it with `??` 

```js
function setOpts(opts) {
  opts.cat ??= 'meow'
  opts.dog ??= 'bow';
}

setOpts({ cat: 'meow' })
```

This is on [stage-4](https://dev.to/hemanth/stage-4-features-5a26) and you should be able to use it today!

I am happy that I was able to [co-champion](https://github.com/tc39/proposal-logical-assignment#champions) this proposal.

[7 Years ago](https://esdiscuss.org/topic/shorthand-notation-for-attribute-creation) it was just a thought!

![history](https://dev-to-uploads.s3.amazonaws.com/i/figmn087wlr1wm1gppy5.png)
Writing Effective Python - Production Readiness
Tags: python, devops, techtalks, tutorial
Published: 2020-08-29 21:53:40

A lot of folks that I speak with that are trying to learn python aren't sure what to do after Code Academy or how to write code that is ready to ship to production. I wanted to create a few lessons for beginners on things they can implement in their code that isn't about code quality per say, but overall quality of the project. So I put together a few short videos to share some of my experience. 

Part 1 - Basic application layout and implementation
Part 2 - Implement command line arguments
Part 3 - Encapsulate the logic in a module
Part 4 - Add automated test coverage
Part 5 - Implement logging

I hope this video series is helpful to folks new to Python and software development in general. 

You can see the videos here: 
https://www.youtube.com/playlist?list=PLMyhkyn1XSqQPqCTuMUn-QBE5xCKm30gt
Dev Snap has Launched! (Free and Open Source Web Developer Assets)
Tags: javascript, bootstrap, css, jquery
Published: 2020-08-29 23:18:57

![Web Developer Assets](https://devsnap.me/devsnap.png)

Dev Snap (https://devsnap.me) Is A Website With Tons of Free and Open Source HTML, CSS, and JavaScript Assets for Web Developers! Enjoy.

[HTML Code Examples](https://devsnap.me/html-code-examples)

[CSS Code Examples](https://devsnap.me/css-code-examples)

[Bootstrap Examples](https://devsnap.me/bootstrap-code-examples)

[JavaScript Code Examples](https://devsnap.me/javascript-code-examples)

[jQuery Code Examples](https://devsnap.me/jquery-code-examples)

[React Code Examples](https://devsnap.me/react-code-examples)

[Vue Code Examples](https://devsnap.me/vue-code-examples)

[Free Web Programming Books](https://devsnap.me/free-web-books)