teleren/devto huggingface dataset:
How to set env parameters conditionally in GitHub Actions⚙
Tags: github, actions
Published: 2021-08-13 14:27:29

Sometimes we want to set environment variables conditionally in GitHub Actions. For instance, setting build parameters of web server depending on setup like staging, acceptance and release. Here, I show an easy way to set environment variables conditionally depending on what git tag is created on a repo in GitHub Actions workflow.

Let's assume that we want to build Docker images and push them to a Docker registry. The trigger to run workflow is git tags. `release-XXX` tags are for release env and `staging-XXX` tags are for staging respectively. In actual cases, the tags can be like `release-v1.0.1`.

```yaml
on:
  push:
    tags:
      - release-*
      - staging-*
```

Let's go to env setting steps. I would like to use different Docker image tags for release and staging and set a full Docker image name as an env variable respectively. We can use `if` grammar to judge if the env is release or staging and `echo "VAR=XXX" >> $GITHUB_ENV` sentence to set environment variables throughout a job. `startsWith` is [a built-in function](https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#startswith) which can be used in `if`.

```yaml
jobs:
  build:
    name: Build Docker Image
    runs-on: ubuntu-latest
    steps:
      # Pulls my code
      - uses: actions/checkout@v2
      # This step is run when the tag is release-XXX
      - name: Sets env vars for release
        run: |
          echo "DOCKER_IMAGE_NAME=my.docker.repo/awesome-image:release" >> $GITHUB_ENV
        if: startsWith(github.ref, 'refs/tags/release-')

      # This step is run when the tag is staging-XXX
      - name: Sets env vars for staging
        run: |
          echo "DOCKER_IMAGE_NAME=my.docker.repo/awesome-image:staging" >> $GITHUB_ENV
        if: startsWith(github.ref, 'refs/tags/staging-')
```

Variables are used with `env.XXX` expression, that is `env.DOCKER_IMAGE_NAME` in my example. Use `${{ <expression> }}` to use the variables.

```yaml
- name: Build Image
  run: docker build -t ${{env.DOCKER_IMAGE_NAME}} .
```

That's it. Pretty easy and it's very clean code. By replacing `startsWith` with `endsWith`, you can use a tag rule like `XXX-staging`. If the condition to decide env is very complicated, you may want to write a dedicated step with shell script and [set output parameters](https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-output-parameter) to detect environment and use the output in `if` grammar in steps to set env variables.

However, I recommend not to use complicated rule because it makes it hard to manage environments.

Hope you like it! See you :)
Muse - Vue Ant Design Dashboard
Tags: vue, dashboards, opensource
Published: 2021-08-13 14:27:06

This article presents an **open-source** product crafted by Creative-Tim on top of popular Ant Design: **[Muse Admin Dashboard](https://bit.ly/3xJ13IH)**. The product aims to help developers start faster a new project using a modern design powered by Vue JS Framework. Designed for those who like bold elements and beautiful websites Muse Vue Ant Design is ready to help you create stunning websites and web apps.

> *Thanks for reading!* - Content provided by **[Admin Dashboards](https://www.admin-dashboards.com/)**.

---

- [Muse Vue Ant Dashboard](https://bit.ly/3xJ13IH) - product page
- [Muse Vue Ant Dashboard](https://bit.ly/3xGJlp1) - LIVE Demo

---

> *Disclosure* - **This post contains affiliate links**. 

If you use these links to buy something (no additional cost to you) I may earn a commission, product, or service. **Thank you!**

---

![Muse Vue Ant Design Dashboard - Login Page.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zaowacpy7fea5p9x38b1.jpg)

---

*Official product description* - **Muse Vue Ant Design Dashboard** is a beautiful Ant Design Vue admin dashboard with a large number of components, designed to look beautiful and organized. All components can take variations in color, that you can easily modify using SASS files and classes. Using this template designers and developers might save a lot of time going from prototyping to full-functional code because all elements are implemented.

If you want to get inspiration or just show something directly to your clients, you can start fast your development with pre-built example pages:

---

> Muse Vue Ant Design Dashboard - **Billing Page**

![Muse Vue Ant Design Dashboard - Billing Page.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/89llvup999khnilmkrn3.png)

---

> Muse Vue Ant Design Dashboard - **User profile** 

![Muse Vue Ant Design Dashboard - Profile Page.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0zdtid0mkuqaxvv9xujx.png)

---

## Compile from sources

The source code is published on Github, and we can download and compile the project from the [public repository](https://github.com/creativetimofficial/muse-vue-ant-design-dashboard) without a registration lock. Let's do it!
 
> **Step #1** - Download sources
 
```bash
$ git clone https://github.com/creativetimofficial/muse-vue-ant-design-dashboard.git
$ cd muse-vue-ant-design-dashboard
```

---

> **Step #2** - Install Dependencies

```bash
$ npm i
// OR
$ yarn
```

---

> **Step #3** - Start the project in development mode

```bash
$ npm run dev
// 
$ yarn dev
```

If all goes well, **Muse Ant Dashboard** should be up and running in the browser.

---

![Muse Vue Ant Design Dashboard - product cover.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d0gluw663fvab4gcjomi.png)  

---

> Thanks for reading! For more resources feel free to access:

- More [Free Templates](https://bit.ly/3wd5D25) provided by Creative-Tim agency
- Free [Vue Dashboards](https://dev.to/sm0ke/vue-dashboard-open-source-apps-1gd1) - a curated list published here on **Dev**
Why Django-Single Framework for Backend and Front-end
Published: 2021-08-13 14:09:09



If you are not updated daily, then you must be missing a lot as a software developer. Technology is an industry that requires keen observation and anylysis of what will happen tomorrow. The field is growing faster than any other industry.

I love web development. I have built websites with vanilla JavaScript before deciding which framework was the best. But one experienced developer told me never to compare them because each has its advantages and disadvantages. According to my analysis, I wanted something that will help me develop websites much faster.

Framework for backend and Front-end
I landed on react but when it comes to the backend, you need to learn PHP or node.js again. That means you must be commited to another framework or language for the backend. Can Django perform all those tasks? Yes.

Large Community
The python framework is still growing with the addition of features daily. It has a wide community that contributes to open-source projects. It's simple, with inbuilt features that accelerate the rate of development. 

A few lines of Code
Furthermore, it makes use of redundant code. You just have to write a single base.html class that contains the footer and header. So when building other templates, you just call the block with two lines of code. This will decrease the loading time. Always develop sites that use less memory and load faster(Algorithm).

Simple pagination
What about pagination, it's very simple. With four lines of code, you can hide other products. Pagination is good, it acts like lazy loading. It helps to increase the loading speed. Feel free to read my blog about pagination.(https://dev.to/maniamartial/django-pagination-simple-that-any-framework-2i6d)

Built-in Form
When it comes to the backend, the process becomes much simpler. The authentication of users and admin has been taken care of. If it's a registration or login, there is an existing drafted form. The developer might decide to use it to design another one. Resetting and editing staff from the backend is also available.

Complete Admin section
Fascinating thing about Django, it has a well-designed Admin backend. The developer has to create-super-user and login in. Inside the admin panel, there are a lot of things you can do. There are many defaults like deleting another user, giving a mandate, and adding people.

All in all, I feel it’s the best framework while working on a single project as a solo developer. But if you are working with a team, you might decide to specialize on the backend or front-end. The best answer to which framework to use depends on the user, try out to get your best meal. According to the statistics, react.js is said to be more popular among 67% of frontend developers.
Full Stack Twitter Clone
Tags: node, javascript, vue, express
Published: 2021-08-13 13:59:40

In the project, I am doing it to develop myself on the back-end side. I spend my experience and effort to become a full-stack developer using Node.js and mongoDB.

In this project, I preferred Node.js in Back-end, mongoDB as Service, object document mapper (ODM) mongoose, Vue.js and pug in Front-end, SCSS for styling. I'm thinking of deploying my project to Google Cloud.

As a front-end developer, it's a study I've done about wondering what's going on with the backend. It is a project that I aim to learn by making a full-stack project using express.js and mongoDB, which are the most common frameworks of Node.js.

The project is ongoing, I know there are many missing, I continue to work on it. I would be very happy if you would like to contribute.



### Used technologies

Back-End
  - Node.js
  - Express.js
  - MongoDB
  - Mongoose

Front-End
  - Vue.js 
  - SCSS
  - Pug
  - axios
  - Vuex

Containerization
  - Docker
  - docker-compose

Deployment
  - Google Cloud

[Project's open source code link](https://github.com/cihat/full-stack-twitter-clone)

![Class Diagram](https://user-images.githubusercontent.com/57585087/129368881-67e96d9b-2346-49d2-a288-05bae52aef1f.png)

![Basic version](https://user-images.githubusercontent.com/57585087/129048076-a2b17cc9-3bc5-4447-baaa-14100f64aa03.png)

![Basic-II version](https://user-images.githubusercontent.com/57585087/129362860-a552ed07-9426-4d87-9115-e35777793d8c.png)
trying  to add ads.txt to the root of my domain
Tags: angular, typescript
Published: 2021-08-13 13:56:11

i added a file to the root directory next to the index.html page in angular project the file name is ads.txt
i would like to add a line in type script to app-routing.modules.ts to enable me to browse to this page 
please advise i am new to angular 

const routes: Routes = [
   { path: 'ads.txt', ????(what sould i  put here? }
]

i would like when browse to http://mydomain/ads.txt  the text file should be seen on browser
Utiliser du SVG avec XCode 12
Tags: ios, xcode, apple, swift
Published: 2021-08-13 13:39:59

Avec la WWDC 2020 et Xcode 12, une information est passée un peu inaperçue dans la communauté de développeurs iOS : il est maintenant possible d'importer des SVG sur Xcode.

On vous explique tout ici : 
https://blog.async-agency.com/utiliser-le-format-svg-avec-xcode-12/ 

A plus !
Play in one team with your body, not against each other
Tags: beginners, productivity, career
Published: 2021-08-13 13:32:07

## A problem

As a beginner developer, I want to study fundamental computer science concepts, practice algorithms/data structures skills, complete side-projects, and of course, try out all new JS frameworks. In short, I need to take a step in the right direction every day. But it seems like there isn’t enough time on a typical day. I wake up, have breakfast, take a shower, get to work, and have a rest with my friends and family in the evening.

Wait, why I don’t have time in the morning? Oh, it’s because I usually hit a snooze button dozens of times and feel pretty sleepy, anyway. However, I already tweaked my sleeping schedule several times, but still to no avail.
<br>
## A solution

So, isn’t there a better way to start a day to maximize productivity from the ground up? Turns out, there is.

> Do not use an alarm clock at all.

As many of you know, the human body has a so-called biological clock. The clock governs a sleep-wake cycle but also affects mood and mental alertness. But an alarm clock disturbs the natural mechanism by forcing your body to wake up whether or not you got enough sleep.

As always, the dose makes the poison. If you set an alarm clock once a month, it’s not a big deal. However, its daily usage completely disorients your natural clock.
<br>
## How to implement new knowledge in real life?

Developers have a lot of flexibility in working hours and it’s the ideal situation to achieve alarm-less life. First, warn colleagues about your experiment. Then forget about alarm clocks for a week, but follow the simple rule.

> Stop kidding yourself.

When you nod off, go to bed. When you feel tired, go to bed. There is no workaround. So get used to it.
<br>
## A result

I noticed positive results after a week of the new routine. I went to sleep in the gap between 10:30 and 11:30 PM, and my body waked me up around 6 AM.

I’ve been following the new routine for two months now and I’m eager to continue. I have enough time to study CS in the morning every day and have a rest after full-time work. It’s all because now we play in one team with my body, not against each other.
How to update a single document in a MongoDB collection
Tags: mongodb
Published: 2021-08-13 18:35:29

---
title: How to update a single document in a MongoDB collection
published: true
date: 2021-08-13 13:18:02 UTC
tags: MongoDB
canonical_url: https://donaldfeury.xyz/how-to-update-a-single-document-into-a-mongodb-collection-2/
series: "Small Bytes of MongoDB"
---

For a full overview of MongoDB and all my posts on it, check out my [overview](https://donaldfeury.xyz/introduction-to-mongodb/).

You can update existing documents in MongoDB and if you want to update only one document at a time you have three main options.

You can use the `update` method to update one document. By default, it will only update one document, even if the query provided matches multiple documents.

First, we'll insert our data set into a collection called `podcasts` using [`insertMany`](https://donaldfeury.xyz/how-to-bulk-insert-documents-into-a-mongodb-collection/)

```
db.podcasts.insertMany([
	{
		"name": "Tech Over Tea",
		"episodeName": "#75 Welcome Our Hacker Neko Waifu | Cyan Nyan",
		"dateAired": ISODate("2021-08-02"),
		"listenedTo": true,
	},
	{
		"name": "Tech Over Tea",
		"episodeName": "Neckbeards Anonymous - Tech Over Tea #20 - feat Donald Feury",
		"dateAired": ISODate("2020-07-13"),
		"listenedTo": true
	},
	{
		"name": "Tech Over Tea",
		"episodeName": "#34 The Return Of The Clones - feat Bryan Jenks",
		"dateAired": ISODate("2020-10-19"),
		"listenedTo": false
	}
])

```

Let's update the podcast episode that aired on `2020-10-19` to indicate we've listened to it now.

```
db.podcasts.update({dateAired: ISODate("2020-10-19")}, {
	{ $set: { listenedTo: true } }
})

```

The first argument is our query specifies what document we want to update. The second argument is a document describing how we want to update the document.

We're using what is called a `update operator` called `set` to tell MongoDB to update the `listenedTo` to the new value of `true`.

We can achieve the same result with `updateOne`.

```
db.podcasts.updateOne({dateAired: ISODate("2020-10-19")}, {
	{ $set: { listenedTo: true } }
})

```
Smashed a DEV Bug: Tiny regex fix
Tags: devbugsmash
Published: 2021-08-13 12:54:07

### I fixed a tiny regex

Hey there! I'm Siddharth Shyniben, a 13 year old dev just coding for a hobby. I participated in the [DEV Bug smash v2](https://dev.to/devteam/bug-smash-is-back-join-the-challenge-g41), and I wrote this post to tell you about it.

### Open Source Background

I started coding around ~4 years back, after being inspired by my father, who does the same. Back then, my code was only on my computer, and I never dreamed of my code being viewed by everyone. Once I ~~discovered~~ started using GitHub around 2 years ago, all that changed. Suddenly, everyone could see my code, and report bugs, and contribute. I could host sites using GitHub pages. 

GitHub was what introduced me to open-source. Seeing how beneficial open-source was to me (and everyone else), I started open sourcing almost all my work.

### About This Bug

The bug was a very simple one, and most of you may not have seen it.

{% github https://github.com/forem/forem/issues/14334 %}

When you use [Forem](https://github.com/forem/forem) to create a new community, you get to customize the sidebar, including the icons of the links. There is a function to validate the icon SVG, which looked like this:

```pcre
/<svg .*>/i
```

But this regex wouldn't match multiline SVGs, so we had to manually remove all the newlines in the SVG.

### How I Smashed It

The bug was pretty easy to smash, just had to add a single flag:

```pcre
/<svg .*>/im
```

{% github https://github.com/forem/forem/pulls/14481 %}


### Reflection

This was a pretty basic issue, and I can only consider this a warmup, so there's nothing much to say here. But, I've taken up another issue, and I'll elaborate when I write about that :D.

One **super important** takeaway, is that once you learn one programming language, most other ones are pretty easy to use. I have *zero* experience in ruby, but guess what? I've smashed 2 bugs (one from the previous bug smash). So, If you're worried because you don't know a programming language used – don't worry, It might take you less than a day to learn it. This applies to a lot of stuff.

### Suggestions for DEV Community Bug Smash

More bug smashes! There's a really great feeling when you contribute to OSS! Maybe you could make this a seasonal thing :D
Day 9 of #100DaysOfCode
Tags: 100daysofcode, codenewbie, career, beginners
Published: 2021-08-13 12:40:22


Found a bug on my simple temp converter app. Just learned how to branch in git just so the main won't get messed up. Finished my number guessing game app. Watching vids about debugging.

https://vernonranis.github.io/number-guessing-game/
Moved my blog from Wordpress to Serverless
Tags: devjournal
Published: 2021-08-13 12:39:53

I published my first blog in mid-2018 and since then this is my 4th revamp.

I used to host my blog, a WordPress instance in Digital Ocean, then moved the entire setup (thanks to plugins like Duplicator) to AWS LightSail. And now it is completely serverless.

Clearly, I get bored with things pretty fast and when you have a blog, there is always someplace for improvement be it performance or the look and feel. 

A lot goes behind the scene.

The very first reason I switched to a serverless architecture was performance.

For a long period of time, my blog was lagging on several performance parameters.

- Sometimes I needed to optimize all the images
- The SSL certificate expired and my traffic bounced off.
- The themes I chose were not looking best for a coding blog
- Caching issue of styles and JS scripts.
- Syncing issue in cloud distribution.

And a ton more I have to take care of every now and then.


I couldn't focus on the main thing, WRITING. Because I was not satisfied with the site itself.

Fortunately, I came across an article about static site hosting from AWS.

Then I found out a few sites that were running serverless and man, these sites were fast, like blazing fast!

Well quite obvious, because these static sites are pre-rendered. Do not require back and forth DB calls. Cutting down all the server-side requests.

Quite impressive.

The next chain of thought in my brain went on like this:
- Do I really need a dynamic site?
- What dynamic features do I use?
- Well, there is comments, subscriber list and the WordPress 
backend and all the plugins and the power to customize.

But the static site gives me:

- Pre-rendered static pages
- Good performance
- No worries to manage plugins and cache
- No SSL maintenance worry (Because AWS will take care of it)
- One time configuration
- And markdown support! Who needs the WP editor anymore?

I was already on AWS and here is the best part, all I had to deal with was s3 and CloudFront, maybe a bit of lambda function (I didn't stop there though! Will tell that story next time).

> _Will tell you about the serverless stack in my future post._

Serverless architecture is not truly serverless. It's a concept of moving out of the traditional DB dependency to the static world of things. 

And for a blog, I don't see it as a downgrading.

Of course, it has some Pros and Cons. But, now when I look at my [blog](https://anjandutta.com), it's a relief.

Focusing on writing better content :) which is all about coding.
Is the Generation Gap today bigger than ever?
Published: 2021-08-13 12:07:14

We can define Generation Gap as a lack of understanding between people of distinct generations. These differences can be about work ethics, moral values, respect, political views, attitudes toward different group and religious beliefs. 

In this generation, technology is leading the way to and being responsible for a gap never ever seen.

Education has gained heaps from technology.  It is much more affordable: we can study in our own time, in a queue bank.  

Even if you can't afford a course, the internet offers tons of free training.  With the same internet, you can also meet people for each part of the word to learn a new language.  It was impossible 20 years ago. 

We are saving more lives. Now we can do a heart surgery with more precision. We have other ways to identity a cancer before it become irreversible. The treatment for several diseases is becoming cheaper fast. Technology allows to see the world and discovery the universe. 

We can see a black hole from an astronomy laboratory and say with sure if a planet has or no water. And why this concern about water? Because is the premise that we know about life. 
The news is faster. If something happened in one side of the world, the other side knows in seconds. It was totally unthinking decades ago.  

The way of how to work has changed. We can be an employee working for someone abroad. This gave us freedom to live wherever we want and still work for the country we were born 

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

To top all of that, we put this entire technology and global communication in a small object. The smartphone. 
We can do a lot of things starting by taking off the smartphone from pocket and open a app. Need to call a taxi? It has an app. Ask for food? It has also an app. Even find a soulmate or something not so engaged has a specifically app. We became closer with everyone in the world with social networks. On the other hand, the abuse use social networks is not so good for mental health. Needs to be used carefully. 

Ours cars are now electric. Zero emission of polluting gases. With robots we can build more, better, and faster. But the gap between how jobs disappear with these robots and how fast we can train the people who lose their jobs in new function is growing every day. 

Other things like taste in music, way to wear or how to speak became different with time, but the effect of technology changed the world forever, so far. 

This effect is exponential and what we built in 50 years, if compared with the last 100 years is incredibly. What could we expect for the next gap with all this technology available?

We can expect more. Maybe find life in another planet or extend our life with scientific research. We can expect a cleaner, gas-free and more connected world than ever before.