teleren/devto huggingface dataset:
How to change the permissions of a file synchronously using Node.js?
Tags: node
Published: 2021-03-30 00:00:00

---
  title: How to change the permissions of a file synchronously using Node.js?
  published: true
  tags: Nodejs
  date: Tue Mar 30 2021 05:30:00 GMT+0530 (India Standard Time)
  canonical_url: https://melvingeorge.me/blog/change-permissions-on-file-synchronously-nodejs
  cover_image: https://melvingeorge.me/_next/static/images/main-bc51a18cb7cb3b5b35ac95912800e2db.jpg
  ---
  [Originally posted here!](https://melvingeorge.me/blog/change-permissions-on-file-synchronously-nodejs)
  
To change permission on a file synchronously, you can use the `chmodSync()` function from the `fs` (filesystem) module in Node.js.

Let's say I have a file called `myFile.txt` and want to change the permission to `775`. Here you can use the `fs.chmodSync()` synchronous method and pass:

- a path to the file as the first argument
- the mode or permissions to allow as the second argument such as the `775`. The permission can either be an octal number or a string. My choice is to go with the octal number as it is easy to understand. Also, make sure to prefix the `775` with `0o` which is the convention to write the octal number in Node.js and many other programming languages. To understand what the number `775` means [click here](#understand-permission)

It can be done like this,

```js
// require fs (filesystem) module
const fs = require("fs");

// change permission of myFile.txt to 775
fs.chmodSync("myFile.txt", 0o775);

console.log("Permissions are changed for the file!");
```

See the above code live in [repl.it](https://replit.com/@melvin2016/change-permissions-of-a-file-synchronously-using-nodejs)

That's it 😃.

<a name="understand-permission"></a>

### Understand what the `775` octal number means?

You may be wondering what is `775`, it can be summarised like this:

- the first value `7` means to give `read`, `write` and `execute` permission to the owner of the file.
- the second value `7` means to give `read`, `write` and `execute` permissions for the group.
- the third value `5` means to give only `read` and `execute` permission for others.

So to put it simply the leftmost value is where we define the permission for the `owner`, then the permission for the `group`, and the permission for `others`.

### FULL LIST OF PERMISSION VALUES

- `7` - read, write, and execute
- `6` - read and write
- `5` - read and execute
- `4` - read only
- `3` - write and execute
- `2` - write only
- `1` - execute only
- `0` - no permission

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

---
IC to Management is not a promotion
Tags: career, management, promotion, growth
Published: 2021-03-29 23:45:49

---
title: IC to Management is not a promotion
published: true
description: 
tags: career, management, promotion, growth
cover_image: https://marvel-b1-cdn.bc0a.com/f00000000039764/www1.cbn.com/sites/default/files/styles/image_xl_640x480/public/crossroads_SI.jpg?itok=lnxku_6R
---

https://spandanagovindgari.medium.com/ic-to-management-is-not-a-promotion-c2b525dac9bb
Ten Minutes a Day!
Tags: 10mad, 100daysofcode, codenewbie, webdev
Published: 2021-03-29 23:24:56

In order to help myself stay consistent with my self taught Web Dev studies, I've decided to take part in a challenge I saw someone post about on Twitter. It is a "Ten Minutes a Day" challenge where you do something every single day for a least ten minutes. The goal here is that you force yourself to stick to a routine and will typically go over the ten minutes which works in your favor. Even if you're busy or having a bad day and only work on your task for ten minutes, something is better than nothing.

As an extra bonus I've decided to blog about my daily 10MAD (the acronym I came up with lol) tasks to help reinforce what I've learned. Today I worked on some basic formatting elements in CSS. Some of the things I learned about are:
* Text Decoration
* Text Transform
* Text Align
* Font Weight
* Font Family

My next lesson will be on some basic CSS selectors and how you can use them to style your HTML!
React Testing Library - Testing a Node Attribute
Tags: react, testing, javascript
Published: 2021-03-29 23:22:45

---
canonical_url: https://www.wilbertom.com/post/react-testing-library-testing-a-node-attribute/
---

You can test HTML node attributes with the [toHaveAttribute](https://www.npmjs.com/package/@testing-library/jest-dom#tohaveattribute) matcher. When you need more than an equality check, though, you can use `getAttribute`.

For example, here is a component that has a `mailto` link. Let's test the subject and recipient.

```javascript
import React from "react";

export function Component() {
  return <a href="mailto:example@example.com?subject=Hello">Send</a>;
}
```

You could write one test:

```javascript
import React from "react";
import { Component } from "./component.jsx";
import { render } from "@testing-library/react";
import "@testing-library/jest-dom/extend-expect";

it("has a subject and correct recipient", () => {
  const component = <Component />;
  const { getByText } = render(component);

  expect(getByText("Send")).toHaveAttribute(
    "href",
    "mailto:example@example.com?subject=Hello"
  );
});
```

This test case is testing two things at once though, the "and" in the test name gives it
away.

Lets test each idea seperately:

```javascript
import React from "react";
import { Component } from "./component.jsx";
import { render } from "@testing-library/react";

it("has a subject", () => {
  const component = <Component />;
  const { getByText } = render(component);

  expect(getByText("Send").getAttribute("href")).toMatch(
    /subject=Hello/
  );
});

it("emails the example email address", () => {
  const component = <Component />;
  const { getByText } = render(component);

  expect(getByText("Send").getAttribute("href")).toMatch(
    /mailto:example@example.com/
  );
});
```
Developing For Imperfect: Future Proofing CSS Styles
Tags: webdev, css, tutorial
Published: 2021-03-29 22:29:12

> _This is episode #26 in a series examining modern CSS solutions to problems I've been solving over the last 13+ years of being a frontend developer. Visit [ModernCSS.dev](https://moderncss.dev/) to view the whole series and additional resources_.

How do we plan future-proof styles in a world with an infinite degree of device and user ability variance? Let's explore how things can break and how modern CSS provides solutions.

This episode will cover handling for:

- variable content length and overflow
- unpredictable media sizes
- internationalization
- accessibility-related user settings

We'll explore creating a robust comment thread component.

> **[Continue reading the full article on ModernCSS.dev >](https://moderncss.dev/developing-for-imperfect-future-proofing-css-styles/)**
Stop Dell Email, Snail Mail, Calls, Faxes and Texts
Tags: junkmail, snailmail, unsubscribe, technology
Published: 2021-06-09 19:56:15

---
title: Stop Dell Email, Snail Mail, Calls, Faxes and Texts
published: true
date: 2021-03-29 22:24:54 UTC
tags: junkmail,snailmail,unsubscribe,technology
canonical_url: 
---

![Removal Confirmation](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/blawmxgl9fer1ty625nm.jpg)

Dell’s snail mail just kept showing up and, unlike email, it wasn’t obvious how to stop that. Use their [List Removal form](https://www.dell.com/preferences/listremoval) to unsubscribe from:

- Email
- Postal Mail
- Phone Calls
- Faxes (seriously?!?)
- Text Messages

[https://www.dell.com/preferences/listremoval](https://www.dell.com/preferences/listremoval)

Originally published August 14, 2014, but as of June 9, 2021 the link is still good. Wow.
Regular Expressions CheatSheet!
Tags: javascript, beginners
Published: 2021-03-29 22:23:51


##Basics

Regular expressions always start with / /.

```js
/ expression /, i.e /[A-Z]+/g basic format
/ name\?\*\\/ escape special characters with backslashes
() group with parentheses
| logical OR
Character classes
\w word \d digit \s whitespace (tabs, line breaks)
\W NOT word \D NOT digit \S NOT whitespace
\t tabs, \n line breaks
. any character
```
##Anchors
```js
^world start of the strings
world$ end of the string
```
##Brackets
```js
[xyz] match any x, y, z
[^xyz] NOT x, y, z
[B-X] match any capital letters between B & X.
```
##Quantification
```js
viki|maria match viki or maria
z{n} n occurrences
z* zero or multiple occurrences
z+ one or multiple occurrences
z{min, max} min/max occurrences
z? zero or one occurrences
```
The most easy and fast way to turn an integer number into binary
Tags: tutorial, todayilearned, binary
Published: 2021-03-29 21:33:01

# Here we go...

Even if you don't care much about binary numbers and this deeper knowledge from how the machine works, you surely even have asked yourself a simple question: "What the heck is going on here?!".

And at first sight all this processes under the hood can be a few scaring or a big hassle, but now I will show you that can be simpler than you ever saw turn integer numbers into binary — and vice versa.

---

# Step by step 💡

## Define a number you desire

At this case, I will choose a random number, just for testing. So I will define `217` as my first number — let's get started with a big number.

## Get numbers from binary sequence

Each byte have 8 bits. Each bit is worth to a determined value into the queue, starting from right to left.

|2⁷|2⁶|2⁵|2⁴|2³|2²|2¹|2⁰|
|---|---|---|---|---|---|---|---|
|128|64|32|16|8|4|2|1|

## Separate the number in several sums results

Now it is the time to separate the number into sums that fill into binary sequence values. This process have to consider the sequence left-to-right from numbers, as the example below

> 128 ⇒ 64 ⇒ 32 ⇒ 16 ⇒ 8 ⇒ 4 ⇒ 2 ⇒ 1

To do this, let's get `217` and separate into several operations, always separating the rest of the operations into new sum operations  and considering the next number from sequence as target:

```
217 = 128 + 89
89 = 64 + 25
25 = 16 + 9
9 = 8 + 1
```

And it's done. Now we have the numbers from the binary queue (***128*** ⇒ ***64*** ⇒ 32 ⇒ ***16*** ⇒ ***8*** ⇒ 4 ⇒ 2 ⇒ ***1***) that were within the initial integer number.

## Put `1` at number that are in the sequence

Now, get all the numbers from the sequence, and set each space with `0`. And then, with numbers that you find out within the desired number, fill `0`'s cells with `1`.

|128|64|32|16|8|4|2|1|
|---|---|---|---|---|---|---|---|
|1|1|0|1|1|0|0|1|

It's done 🎉! Now we know that `217`, in binary format, is `11011001`.

---

# Questions

> But, if I had a binary number instead?

Then, you can do reverse engineering and just replace the spaces of sequence above with your binary number. And then, sum the numbers that have been filled with `1`.

> What I could do with a number bigger than `256`?

Build the same method, but increase the exponent of `2` in the sequence. So, if the maximum at this example was `2^7`, you can add one more sequence to the left side, with the biggest value as 
`2^15`.

For example, `2^7 + 2^6 + 2^5 + 2^4 + 2^3 + 2^2 + 2^1 + 2^0` was the previous sequence, and the new with be `2^15 + 2^14 + 2^13 + 2^12 + 2^11 + 2^10 + 2^9 + 2^8 + 2^7 + 2^6 + 2^5 + 2^4 + 2^3 + 2^2 + 2^1 + 2^0`. And the binary number will be at this `00000000 00000000`(16 bits) instead of `00000000`(8 bits).

---

# Conclusion

Computers' processes can be easier to understand than they seem. So, with this new quick tip, feel free to give your feedback and bring yet more value to discussion.

**Made with 💚 by [Cristian](https://github.com/cristianprochnow). Enjoy it!**
Designing a professional community for devs
Tags: community, devrel, showdev
Published: 2021-03-29 20:59:46

## TL;DR:
Discord for live events + Discourse as a support forum and a knowledge base + twitter and twitch for content + 3 amazing developer advocates to run this all.

## In this episode Lera is asking Zan why his company is so smart:

How does CircleCI understand the value of community instead of just buying AdWords and promoting their own posts on Facebook?

And then we talk developer community design and what Zan and his team have for a developer relations strategy in 2021. Events? Livestreams? Virtual swag giveaways?

{% youtube 8qCnEW81-bo %}

## Hosts:
Community builders and digital content creators. Available for contract work.

* Lera: artist, full-time gen z, queen 👑
* Karina: business leader​, money 🤑
* Olle: product, devrel, tech 🎥

## Guest:
[Zan Markan - Developer Advocate](https://twitter.com/zmarkan), CircleCI, dad, storyteller, wanderer, immigrant. Snarks and rambles about computer things, planes, craft beer, and policy.

## Upcoming episodes:
This show runs on our Discord server and is supported by a friendly pancultural community. Most speakers are our community members.

* **How to hire a community manager** with Jamie Cantrell Langskov - MongoDB
* **Making sense of online gatherings in 2021** with Guy 'Yug' Blomberg - Games Industry Gathering
* **Running a Discord server for anime artists** with Aigerim Aimova - Usagi Shop
* **The community for community builders** with Alex Angel - Commsor
* **Using science to research online communities** with Martina Pocchiari - PhD Candidate in Empirical Quantitative Marketing

[Subscribe to get a weekly email](http://communities.show) with new episodes.

## The motivation
Community is the first threat to Google and Facebook in 15 years - says Alexis Ohanian, the founder of Reddit and 776 venture fund.

This line sticks with me 4 weeks after I heard it. It is the title of my talk at a 700,000 people digital event. It just makes so much sense.

In this very episode with Zan, we discuss how a business cannot lead the conversation about a term or a topic by buying AdWords or promoting FB posts, how sponsoring a conference banner for $15,000 doesn't work anymore, how hosting (not renting from Facebook or Instagram) a community helps businesses.

For CircleCI continuous integration is the #1 term, but the way they operate is so appealing, that I have CircleCI stickers around, and Lera has CircleCI socks despite we both are not really into DevOps, but this brand has a good vibe. We want to orbit CircleCI because we feel like they share our values.

/This text has been written by Olle and reviewed by Lera, Karina, our Discord community and Grammarly
Terraform Explained | How to create your first terraform infrastructure on AWS and Google Cloud
Tags: terraform, devops, aws, googlecloud
Published: 2021-03-29 20:53:14

{% youtube jJX6S5JAGpI %}

In this Terraform tutorial, we are going to see - 
1. What is Terraform?
2. Terraform file structure as well as terraform file example
3. What are Terraform command .i.e. - terraform init, terraform plan, terraform apply, terraform destroy
4. How to install terraform
5. We are also going to "Create a terraform file for the demo on Google Cloud platform to provision Virtual Machine"
6. In the second demo we are going to "Create a terraform file for setting up an EC2 instance on AWS"
7. We will also compare the terraform file of Google Cloud vs AWS


▬▬▬▬▬▬ * Instruction's Guides * ▬▬▬▬▬▬ 

1. How to install terraform - https://jhooq.com/install-terrafrom/
2. Setup virtual machine on Google Cloud Platform - https://jhooq.com/how-to-setup-virtual-machine-on-google-cloud-platform/
3. Setup EC2 Instance on AWS - https://jhooq.com/terraform-ec2-instance-setup/
How to use/pull environment variables into Helm Chart
Tags: devops, kubernetes, aws, docker
Published: 2021-03-29 20:50:36

{% youtube dKKMJseMiGU %}


This lab session will help you to understand "How to pass environment variables into the Helm Chart". There are total 2 ways by which you can pass the environment variables into the helm chart

1. **Using command-line interface to pass environment variables example: -** helm install --set replicaCount=2 h helloworld-1 world
2. **Using your own values.yaml to pass environment variables example: -** helm install -f myvalues.yaml helloworldrelease helloworld
Beginner's Introduction to Axios
Tags: beginners, javascript, axios, programming
Published: 2021-03-29 20:27:13


Making HTTP requests to fetch/save data is a common task for any client-side JavaScript application. Axios is a JavaScript library that's used to perform HTTP requests. It works in both Browser and Node.js platforms.

It supports all modern browsers, including support for IE8 and higher.


<h3>Adding Axios to your project</h3>

You can add Axios to your project using any of the methods listed below.

Using npm:

```bash
$ npm install axios
```

Using bower:

```bash
$ bower install axios
```

Using yarn:

```bash
$ yarn add axios
```

Using jsDelivr CDN:

```html
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
```

Using unpkg CDN:

```html
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
```

<h3>Making a "GET" request</h3>

Let's query the <a href="https://dummyapi.io/explorer" target="_blank" class="link">DummyAPI</a> to retrieve a list of users, using `axios.get()`.

```js
import axios from 'axios';

const response = axios.get('https://dummyapi.io/data/api/user?limit=10')
const users = response.data
```

Since Axios always returns the query in an object data, we can rewrite the code above as using <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment" target="_blank" class="link">destructuring</a>

```js
import axios from 'axios';

const {data} = axios.get('https://dummyapi.io/data/api/user?limit=10')
const users = data;

```

<h3>Making a "POST" request</h3>

A POST request is used to add new data on the Backend. A POST request is similar to a GET request, but instead of `axios.get`, you use `axios.post`.

A POST Request also accepts a second argument which is an Object containing the data that is to be added.

Let's add a new user below.

```js
import axios from 'axios';

let newUser = {
    name: 'John',
    email: 'john@gmail.com'
    Gender: Male,
}

addUser (user) => {
    axios.post('https://dummyapi.io/data/api/user/', user)
}

addUser(newUser);
```

This is a quick introduction for beginners. Axios enables you to do so much more. You can read about more advanced Axios methods in this <a href="https://blog.logrocket.com/how-to-make-http-requests-like-a-pro-with-axios/#postjson" target="_blank">Article by Faraz Kelhini</a>
Here to learn - Some of the reasons why I chose SE.
Tags: codenewbie, career
Published: 2021-03-29 20:25:13

For the last 10+ years I've been making a living out of photography and filmmaking. Most would say that it's a great privilege to be able to live out of your passion, and while I partly agree, I believe that statement is not entirely truthy. 

In a perfect scenario, my clients would pay me good money to travel the World making incredible photographs or give me the budget that would allow me to invest years of my time to make an edgy documentary. But truth been told, the majority of the paid jobs I've had over the years were just not so interesting. They allowed me to live and finance my side projects. That is where the fun was.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sqnawzmj3lk3bt3lu1rs.png)
So what if you have to work for others and leave the fun for your free time? Is that such a big deal? Well... it probably shouldn't, but in my case those paying jobs where also eroding my passion for creating overall. And that is where I draw the line.

I needed a change but I never managed to say no to the next gig that would appear. It only took a global pandemic to put a halt to all my projects and give me time for introspection. The time was now.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/18lqecmbj70ucq5kbpa8.gif)

I wanted to do something completely different that would leave my passion for image making completely intact while at the same time representing a challenge. Ah... it would also be cool to be able to do it remotely, since now it seemed everyone was fine with that.

And that is how I got to this point, 2 weeks into my part time SE course at Flatiron, wondering if I'll be able to keep my two sides of the brain working at their full potential.
Very-excited-to-learn.
Azure Functions hacks
Published: 2021-03-29 20:17:44

This is just a collection of mini-hacks to fix problems I've faced during development of Azure Functions, maybe it can help anybody out there. I'm a total newbie in Azure so if you have some insights on these issues you are welcome to show me the way of the light.

## Development storage failing to start

When starting a functions app with `func start` locally, maybe you got it working at the beginning but suddenly you can get this cryptic unhelpful message
>"There was an error performing a read operation on the Blob Storage Secret Repository. Please ensure the 'AzureWebJobsStorage' connection string is valid."

And you have no idea because the storage in dev used to work and you have your `"UseDevelopmentStorage=true"` in place, fear not, just go to your Server Explorer in VS, go to Storage and Blobs, there may be a couple of records there for `azure-webjobs-hosts` so maybe those are conflicting don't know 🤷‍♂️ for sure so just delete them and you should be good to go.

Looks like these deletions are not needed if you use files storage, use file storage for secrets storage type, in local.settings.json you have to add

`"AzureWebJobsSecretStorageType": "files",`

Also every time you start development with `func start` remember to kick off Azure Storage Emulator from program files and make sure to Start Storage Emulator from the commands or status icon in Windows

## SignalR Serverless

### Method not found (404)

When you start development with SignalR you may find yourself not finding the broadcast method to invoke via
`await _connection.InvokeAsync("broadcast", "message" );`

This maybe due the negotiate function having a `[SignalRConnectionInfo(HubName = "hubname")]` attribute

If you don't want to send to a hub at the beginning then just remove the hub linked connection :)

### Failure to deserialize the json message

If your `HubConnection.On<T>` method fails to deserialize and only works with `object`, it may be because you need the parameterless constructor but also a public setter for your properties.

I think there is a way to pass the properties values through a constructor which is much better than having public properties but haven't looked into it.

### Debug your function while running your app

Say you have your functions and app in same solution

If you are running locally using `func start` you can simply attach the debugger to the func.exe process and you get debugging side to side with your app :D
Ready to become a machine learning hero?
Tags: machinelearning, ai, deeplearning, python
Published: 2021-03-29 19:25:18

![Humble Book Bundle: Machine Learning Zero to Hero by Manning Publications
](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/606fqvjlr6m7opties0p.jpg)

**[Humble Book Bundle: Machine Learning Zero to Hero by Manning Publications](https://www.humblebundle.com/books/machine-learning-zero-to-hero-manning-publications-books?partner=indiekings&charity=24627)**

Alongside Manning Publications & Humble Bundle are bringing almost $900 of eBooks focused on AI and machine learning, including Deep Learning and the Game of Go, Succeeding with AI, and Machine Learning in Action. It’s the perfect eBook package for anyone looking to move from good to great when it comes to their AI knowledge!

Your purchase of this bundle helps support the International Rescue Committee, a charity that responds to the world’s worst humanitarian crises and helps people whose lives and livelihoods are shattered by conflict and disaster to survive, recover, and gain control of their future. You’ll also be supporting the World Central Kitchen, Inc, which uses the power of food to nourish communities and strengthen economies through times of crisis and beyond...

This bundle launched on March 29 at 11:00 am PST and lasts through April 19, 2021. Pay what you want and support charity!