teleren/devto huggingface dataset:
A quick look at destructering
Tags: javascript, typescript, beginners
Published: 2019-06-28 20:53:19

This post will use a couple of examples to provide a quick look at destructering In JavaScript (and TypeScript). You should read the [MDN web docs](https://developer.mozilla.org/nl/docs/Web/JavaScript/Reference/Operatoren/Destructuring_assignment) if you want to know more. It's well-written and contains helpful examples.

---
## The basics
Destructering is used to extract data from arrays (`[]`) and objects (`{}`) with little code:
```javascript
const person = ['John', 25];

let name, age;

// Without destructuring
name = person[0];
age = person[1];

// With destructering
[name, age] = person;
```
```javascript
const person = {name: 'John', age: 25};

const {name, age} = person;
```
Default values can be used as well:
```javascript
const namelessPerson = {age: 21};

const {name = 'Jane Doe', age} = namelessPerson;
```
It can be used in a function to only pick the properties you need:
```javascript
const person = {name: 'John', age: 25};

function hello({name}) {
    console.log(`Hello ${name}!`);
}

hello(person); // 'Hello John!'
```
## A bad example
With the last two examples combined you can write code that is quite hard to read:
```javascript
const person = {name: 'John', age: 25};
const namelessPerson = {age: 21};

function hello({name = 'Jane Doe'} = {name: 'John Doe'}) {
    console.log(`Hello ${name}!`);
}

hello(person); // 'Hello John!'
hello(namelessPerson); // 'Hello Jane Doe!'
hello(); // 'Hello John Doe!'
```
(Both the property `name` and the parameter object have default values assigned.)

## An example in TypeScript
One specific situation in which destructering is useful is when you're subscribing to an observable that returns an array. For example when you use `combineLatest`:
```typescript
combineLatest(user$, dog$).subscribe([user, dog] => {});

// And when explicitly typed
combineLatest(user$, dog$).subscribe([user, dog]: [User, Dog] => {});
```
GatsbyJS - Score 100 on Lighthouse with ease
Tags: gatsby, react, appseed
Published: 2019-06-28 20:52:22

---
title: GatsbyJS - Score 100 on Lighthouse with ease
published: true
description: Blazing fast open-source app, built in GatsbyJS and styled in SCSS.
cover_image: https://raw.githubusercontent.com/app-generator/static/master/gatsby-starter-scss/gatsby-starter-scss-intro.gif
tags: gatsby, react, appseed
---
Hello coders, 

I'm focusing a lot, lately on [JAMstack](https://jamstack.org/) and web development tooling. 
After digging a few weeks to find a modern toolchain to vibe with, I can say the winner is [GatsbyJS](https://www.gatsbyjs.org/). I'm not writing this article to convince anyone that [GatsbyJS](https://www.gatsbyjs.org/) will conquer the universe or is better than other tools. It's just something that I'm 100% compatible. 

---

> Thank you! **Content provided by [AppSeed - App Generator](https://appseed.us)**.

---

IMHO, [GatsbyJS](https://www.gatsbyjs.org/) succeeds to isolate the web app content (what users see & use) from the technology (the devs space) and link these **worlds** nicely.  

Based on these facts, allow me to present the latest app that I play with: a [Gatsby stater](https://gatsby-starter-scss.appseed.us/), styled with SCSS. No heavy Bootstrap, no jQuery. Just a clean and simple layout, blazing fast UI with a maximum score on Lighthouse. 

![GatsbyJs starter - The lighhouse Score](https://raw.githubusercontent.com/app-generator/static/master/gatsby-starter-scss/gatsby-starter-scss-lighthouse-score.jpg)


> How to use this Gastby Starter

```
npm install -g gatsby-cli # install Gatsby CLI

# clone the app
gatsby new gatsby-starter-scss https://github.com/app-generator/gatsby-starter-scss

# start the app
cd gatsby-starter-scss/ && gatsby develop

# Build for production
gatsby build 
```

![GatsbyJs starter - Animated intro](https://raw.githubusercontent.com/app-generator/static/master/gatsby-starter-scss/gatsby-starter-scss-intro.gif)


## Resources
 - [Gatsby Starter SCSS demo](https://gatsby-starter-scss.appseed.us/)
 - [Gatsby Starter SCSS sources](https://github.com/app-generator/gatsby-starter-scss)
 - [GatsbyJS Apps](https://appseed.us/apps/gatsbyjs) - index provided by AppSeed
 - [GatsbyJS Themes](https://blog.appseed.us/gatsbyjs-themes-crafted-by-html5up-lekoarts-creativetim/) - Crafted by HTM5Up, LekoArts, Creative-Tim


> Thank you!
Liberate Orphaned OpenStack Volumes
Tags: openstack
Published: 2019-06-28 19:20:24

---
title: Liberate Orphaned OpenStack Volumes
published: true
tags: openstack
canonical_url: https://garettmd.com/liberate-orphaned-openstack-volumes.html
---

If you delete a server that a volume is attached to, and then quickly try to delete the volume before the server has finished deleting (at least, that’s where I think the problem stems from; it could just be that this happens even if you waited for it to fully delete), the volume can get stuck saying that it’s still attached. You cannot run `openstack server remove volume <server id> < volume id>` because it will complain that the server doesn’t exist. The only way I could figure out how to get around this is to use the `cinder` tool to remove the attachement ID

```shell
openstack volume show <volume_id>
# Grab the attachment ID for use in next step

cinder --os-volume-api-version 3.50 attachment-delete <attachment_id>
# For some reason you have to specify at least api version 3.50. Why it can't figure this out on it's own is beyond me
```

Hopefully this will help someone out.
How to display numbers with currency formatting in JS?
Tags: javascript
Published: 2019-06-28 20:48:16

Use Intl.NumberFormat to enable country / currency sensitive formatting.
  
```js
const toCurrency = (n, curr, LanguageFormat = undefined) =>
  Intl.NumberFormat(LanguageFormat, { style: 'currency', currency: curr }).format(n);
```

```js
toCurrency(123456.789, 'EUR'); // €123,456.79  | currency: Euro | currencyLangFormat: Local
toCurrency(123456.789, 'RUB'); // RUB 123,456.79  | currency: Ruble | currencyLangFormat: Local
toCurrency(123456.789, 'RUB', 'Ru-ru') // 123 456,79 ₽  | currency: Ruble | currencyLangFormat: Russian
toCurrency(123456.789, 'USD', 'en-us'); // $123,456.79  | currency: US Dollar | currencyLangFormat: English (United States)
toCurrency(123456.789, 'USD', 'fa'); // ۱۲۳٬۴۵۶٫۷۹ ؜$ | currency: US Dollar | currencyLangFormat: Farsi
toCurrency(322342436423.2435, 'JPY'); // ¥322,342,436,423 | currency: Japanese Yen | currencyLangFormat: Local
toCurrency(322342436423.2435, 'JPY', 'fi'); // 322 342 436 423 ¥ | currency: Japanese Yen | currencyLangFormat: Finnish
```
71 of 1409
Tags: javascript, codenewbie, beginners
Published: 2019-06-28 20:25:59

After resetting my freeCodeCamp progress, I spent this afternoon breezing through the HTML and CSS portions of the curriculum. Once you know HTML and CSS basics, there's not really much to do but remember the syntax.  So I am refreshed with my HTML and CSS. I think I might check out a CSS book to get more thorough info, but should I? Should I crowd my mind with more info just because it's an option, or should I just keep moving along with the basics?
Fuchsia.dev
Tags: discuss, go, fuchsia, rust
Published: 2019-06-28 20:19:19

The documentation for the ~~new~~ ~~future~~ ~~I don't know how to call it~~ OS of Google is now available on [fuchsia.dev](https://fuchsia.dev), so during the time the project compile on my laptop I was wondering what do you think about it and what do you expect also ? :thinking:
How do you document code?
Tags: discuss, programming, documentation
Published: 2019-06-28 19:03:12

---
title: How do you document code?
published: true
description: Discuss how to properly document code
tags: discuss, programming, documentation
cover_image: https://thepracticaldev.s3.amazonaws.com/i/ttbzcx5npi9al3gaqfly.png
---

Today I got into a discussion with a colleague on how to document code within a large web project. My preferred method is to trust my code to be self-explaining on *what* it does and rely on JSDocs or block comments for *why* it does its thing. Hacky or weird lines get the occasional line comment. 
I dislike documenting my code in other places (like wikis or tickets), because that gets outdated and forgotten pretty quickly.

How do you handle that?
Do you trust your code to be self-explaining? Do you use JSDocs/PHPDocs/etc? Do you comment extensively? Or maintain a huge wiki?
What works out for you and why?
I did it, I'm a Software Engineer
Tags: career, webdev, beginners
Published: 2019-06-28 18:58:54

After months of grueling study and hard work, I've made it guys. Today I signed my offer letter for a new job with Community Brands as a Software Engineer.

I can't even explain how happy I am right now. This is my dream come true. 

There were times where I had doubted my ability, thought about giving up.

I never did. I kept pushing through. 

Now I have a wonderful future ahead of me and I am so excited to get out there and build some amazing software.
Unlimited git repositories
Tags: git, devops, tutorial
Published: 2019-06-28 18:54:35

---
title: Unlimited git repositories
published: true
description: Quick tip to manage your private git repositories
tags: git, devops, tutorial
---

Many developers owns one or more instances in any of the many "cloud providers" out there. And most of them uses git to track their project. For this, github or gitlab are pretty good alternatives but, is there any other alternative?

Yes, you can use nothing or go for Bitbucket or manage your own! Which is, in fact, something ridiculous simple and you just need to have an instance/virtual machine running anywhere [^1].

## The process:
In your local machine (read: your laptop), create your project repository and git init it:

```
local: ~ $ cd ~/Code/sample
local: ~/Code/sample $ git init
```

On the other hand, on your remote server let's init a git bare repository:
```
remote: ~ $ mkdir ~/git
remote: ~ $ cd ~/git
remote: ~/git $ git init --bare sample.git
```
Now, assuming that you can reach your remote service using a fancy name, like `dev.mydomain.io`, let's configure our local using that name:

```
local: ~ $ git remote add origin boris@dev.mydomain.io:/git/sample.git
```

After doing that, just use your git repository as usual.

[^1]: Anywhere reachable by ssh
I've never become overly convinced that switch statements are that much cleaner than `if else if else if else if else`
Tags: healthydebate, codequality
Published: 2019-06-28 18:50:25

I sort of know that switch statements are typically considered a good idea when chaining together a lot of `else if` statements. I'm not against this refactor in any big way, but I've also never found it overly important.

I tend to find the behavior and syntax of `if` and `else` to be pretty consistent regardless of language compared with switch statements so reaching for `if` is easier, but even when chained doesn't seem that much _less_ clean than switches.

I definitely agree that getting rid of `if`..`else`..`else` chains are worth refactoring away, but I haven't found that a switch statement actually improves the quality meaningfully.

Thoughts?
”Nah”
Tags: dailywriting
Published: 2019-07-16 23:39:57

---
title: ”Nah”
published: true
tags: daily-writing
canonical_url: https://marcusblankenship.com/nah-rosa-parks/
---

I shuffle when I walk, which means I kinda drag my feet on the ground. This results in ’scuffing’ along, as my father put it.

You can think of this shuffling as a system that’s balanced when my action (shuffling feet) is met with a particular reaction (dirt or gravel which give way) in a suitable environment (loose dirt or gravel).

It also means that I stumble a lot because I trip over the rocks which refuse to move.

Tripping sends me temporarily off-balance, arms thrown out, stomping with giant steps, trying to regain my balance.

When part of the system which usually moves says “Nah” (like the rock that refuses to move) the system ‘trips’. It’s thrown off-balance.

Systems strive for balance (homeostasis), so it immediately tries to regain balance.

This may mean pushing harder on whatever said, “Nah.”

Or, simply ignoring it and trying to avoid it next time.

Or adjusting to find a new balance that works in this environment.

**Today, there may be systems that you’d like to change.**

Maybe the first step is to be the rock that doesn’t move.

To say “Nah,” throw the system out of balance, and watch what happens next.

Sound Risky? Sure, it might be.

But things will continue until the system becomes unbalanced, and has to find a new balance.

Change starts with imbalance.

Today, what would you like to say “Nah” to?

How might the system respond?

Write me back if you wish – love to hear your thoughts.

-m

The post [”Nah” – Rosa Parks](https://marcusblankenship.com/nah-rosa-parks/) appeared first on [Marcus Blankenship](https://marcusblankenship.com).
Let's talk about seniority. 🤓
Published: 2019-06-28 17:55:25

**What is "seniority" for you?**

**Do you think that is a good way to categorize people knowledge/experience/etc?**

**Which levels of seniority do you agree with?**

**How important is seniority for you?**

**What are the main differences between a junior dev and a senior dev?**
How to Keep Up with the Front-End Industry
Tags: frontend, inspiration, newsletters
Published: 2019-06-28 17:51:19

---
title: How to Keep Up with the Front-End Industry
published: true
description: A collection of resources for staying up-to-date with all things front-end related
tags: frontend, inspiration, newsletters
---

Here are some tips while staying up-to-date with any large knowledge set, like programming, the news, or anything!

- Watch out for overwhelm and take a break if needed
- Recognize you can't know everything
- Share what you're learning with coworkers and friends
- Follow the people/groups that make you excited about the topic
- Contribute to the conversation: write blog posts, Tweet, or record podcasts
- Diversify your sources (one person doesn't have all the answers)
- Automate where possible ([Feedly](https://feedly.com/) and [Pocket Casts](https://www.pocketcasts.com/) help me)


## Resources
Here is a collection of front-end resources for staying up-to-date with all things front-end related (in no particular order).

### Email Newsletters
- https://css-weekly.com/
- http://www.angular-weekly.com/
- http://reactjsnewsletter.com/
- https://www.getrevue.co/profile/vuenewsletter
- https://frontendfoc.us/

### Blogs
- https://css-tricks.com
- https://alistapart.com
- https://www.smashingmagazine.com/
- https://csswizardry.com/
- https://www.netlify.com/blog/
- https://blog.angular.io/
- https://reactjs.org/blog/
- https://www.freecodecamp.org/news/

### Podcasts
- https://syntax.fm/
- https://shoptalkshow.com/
- https://spec.fm/podcasts/toolsday
- https://spec.fm/podcasts/developer-tea
- https://frontendhappyhour.com/
- https://devchat.tv/adv-in-angular/
- https://www.heavybit.com/library/podcasts/jamstack-radio/
- https://news.vuejs.org/

### Courses
- https://reactforbeginners.com/
- https://es6.io/
- https://cssgrid.io/
- https://javascript30.com/
- https://www.leveluptutorials.com/
- https://thinkster.io
- https://blog.nrwl.io/

Check out Wes Bos's [other courses](https://wesbos.com/courses/)

### Twitter
There are too many people and groups to list here. I've made a Twitter list. Feel free to follow it or pick out individuals that stand out to you. https://twitter.com/joshmedeski/lists/developers/members

---

I hope this advice and these resources help you in staying up-to-date with the front-end industry! This is a collection of resources that have found helpful over the years and I hope it serves you well.

What resources or tips can you recommend for staying up-to-date with the front-end industry?
Has anybody built a Gatsby site with over 1,000 posts?
Tags: gatsby, discuss
Published: 2019-06-28 17:44:29

I currently have a WordPress site with over 1,000 posts. I'm looking at free hosting options, so all I have to pay for is the domain. I'm just wondering how feasible a large blog really is with Gatsby, and if anyone knows of success stories with situations similar to mine.

Cheers!
AWS Service Quota (view and manage quotas for our aws services)
Tags: aws, servicequotas
Published: 2019-06-28 17:30:59

Wow, I was looking at my AWS console and saw Service Quotas. Just googled it and found that amazon has introduced a new service to view and manage quotas for aws services.

This sure is going to make life easy to know the service limits and increase quotas. Based on my first glance, This one does have more options than trusted advisor service limits.

https://aws.amazon.com/about-aws/whats-new/2019/06/introducing-service-quotas-view-and-manage-quotas-for-aws-services-from-one-location/
Instagram #pride rainbow tag - how did they do it?
Tags: css, frontend, codepen
Published: 2019-06-28 17:22:20

I noticed this nice touch for pride week and wanted to see if there was anything special about how it was done by the devs at instagram. Turns out there wasn't anything special but it looks great and is really simple to do so decided to write it up anyway!

The main property required here is [**background-clip**](https://developer.mozilla.org/en-US/docs/Web/CSS/background-clip). It allows you to clip (or mask) an element or text to it's background image or colour. 

**Important** - in order to apply it to text it still requires the *-webkit* prefix for Chrome, Firefox, Safari and Edge. In Safari it can't be applied to the button tag but you could get around this with a span!

The rainbow is just a simple [png](https://www.instagram.com/static/images/rainbowGradient.png/558818d23695.png) repeated as a background image on the element with the background size increased.

Finally they've set the color of the text to transparent to allow the rainbow background to be visible. Interestingly they used the **-webkit-text-fill-color** property to do this as the standard color property doesn't allow for the transparent value. The two properties are essentially the same, but **-webkit-text-fill-color** will take precedence over **color** if the two have different values. This is useful as it means it will just gracefully fallback to the default colour of the text if not supported.

Here's a quick [codepen](https://codepen.io/anon/pen/jjYZEL) of the final effect. Anyone got any other more advanced examples of background-clip?
You have received a horrible code at work, what will you do?
Tags: beginners, career, askdev, discuss
Published: 2019-06-28 17:15:03

---
title: You have received a horrible code at work, what will you do?
published: true
description: This was an actual interview question I was asked. How would you answer?
tags: beginners, career, askdev, discuss
cover_image: https://images.unsplash.com/photo-1516981879613-9f5da904015f
---


This was an actual interview (which I failed) question I was asked.

---

## The answer I said (Mostly focused on styling/structure)

### Bad code might have its own purpose.

Even if the code looks messy, there might be the reason that it has been written that way. Or, at least, people are already used to it. Changing an existing schema will cause confusion and harm to productivity.

### It could be waste of time to fix it.

Even though There is no reason to keep the code, fixing it might be a waste of your time, especially if when the code is not used constantly. You need to determine first if it is necessary to fix it.

## The answer I have found [online](https://www.lucidchart.com/techblog/2016/05/18/who-the-heck-wrote-this-3-ways-to-deal-with-bad-code/) (focused on debugging)

### Clarifying comments

figure out what the code does and try to clear it out by stating with comments for yourself and the next person rather than touch actual code to risk breaking

### No risk fix

add a special case. It would be safer and faster, but the real issue wouldn't be fixed.

### Delete and Rewrite

Just threw away everything and do again from scratch.

> Whoever wrote this is an idiot.

It would be clean and simple.

---

*What do you think would be the best option? Do you have another good idea? Please share your opinion.*
Fuzzy String Searching in PHP
Tags: php, opensource, contributorswanted
Published: 2019-06-28 17:14:31

Hello everyone!

Yesterday, I released my first composer package to do fuzzy string searching.

I'm a bit newbie when the subject is open-source projects. Feedbacks and pull requests are welcome.

### Fuzzy Search

[Packagist link] (https://packagist.org/packages/lucascavalcante/fuzzy-search) and [Github link] (https://github.com/lucascavalcante/fuzzy-search).
How do you deal with creator burnout as a developer?
Tags: discuss, help, health, creator
Published: 2019-06-28 16:58:26

For those who make videos, podcast, do side hustle projects, write tutorials. And do this consistently without taking a break. You might have reached a point of burnout where consumption vs creation ratio has lead to burnout. 

What are your ways to calm the mind that feels less accomplished?

How do you deal such burnout as a developer or creator?
What do you consider your greatest developer strength? Weakness?
Tags: discuss, programming, career
Published: 2019-06-28 16:48:29

---
title: What do you consider your greatest developer strength? Weakness?
published: true
tags: discuss, programming, career
---

On [JS Party #78](https://changelog.com/jsparty/78) we talked all about developer strengths and weaknesses (and even shared our own). That got me thinking... we all have strengths and weaknesses. Sometimes we have them in common, sometimes they're totally unique because of our background/experience. Let's share 'em! I'll go first: 

### Strength 💪

One of my greatest strengths as a developer (which I learned is shared by some of my JS Party co-panelists) is STUBBORNNESS! I will continue to bang my head against a wall until there's a hole large enough for me to slip a solution through.

### Weakness 😭
One of my greatest weaknesses as a developer is I am not good at thinking _in libraries_, so I often fail to generalize my code for reuse. Or, if I do generalize it for reuse, I don't package it up and release it for others. 

### Your turn 🤝

What do you consider your greatest developer strength? Weakness?
What was your win this week?
Tags: discuss, weeklyretro
Published: 2019-06-28 16:03:47

---
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
---


🥳🥳🥳

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

All wins count -- big or small 🎉

Examples of 'wins' include:

- Getting a promotion!
- Starting a new project
- Fixing a tricky bug
- Cleaning your house...or whatever else that may spark joy 😄

Happy Friday!

![https://media.giphy.com/media/10YX6sWBNQzcqY/giphy.gif](https://media.giphy.com/media/10YX6sWBNQzcqY/giphy.gif)