teleren/devto huggingface dataset:
How-to: Programming In Linux
Tags: linux
Published: 2021-08-24 13:34:45

I am an engineer who uses Linux everyday, and I write code everyday. 

Linux is a free open source operating system that has been around for decades. With the rise of computer science majoring in college, and the introduction of the [Raspberry Pi](https://www.raspberrypi.org/), the demand for more linux  has grown in the recent years.

When you're writing a piece of software, you're usually writing it on a computer running some kind of operating system. If you've ever written software for linux, you know how many things are different when programming under linux. 

The user interface is definitely different from what most people are used to, so if you're new to linux, I recommend spending some time with it before trying to write any software.

![where app store](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pwkq51f9i4uc218njnv0.png)

## Why Linux?

Linux is one of the most widely used and popular operating systems in the world. It powers devices from phones, tablets, and servers to media centers, supercomputers, and more. Because it's open source, it's also free to use and modify.


## Coding on Linux

Here is a brief run-down of how to go about getting started:

[1.] Download and install Linux!
[2.] Pick a text editor for programming
[3.] Get familiar with the terminal and begin coding!

Let's go over each step in greater detail. First pick a Linux distribution, create a live USB and install it on your computer. You can go for Ubuntu, Suse, Fedora or any of the other Linux based systems. Next comes the terminal (and editor).

One of the key power houses in Linux is the [terminal](https://bsdnerds.org/what-is-linux-shell/). From the terminal, you can do coding.  If you have used Mac OS X before you may be already familiar with the terminal, but on Windows there is nothing similar.

Many coders use the vim programmers editor, which has quite a hard learning curve but is powerful, see [vim tutorial](https://vim.is)

Linux comes with a variety of tools, like Python, C++, C and other languages.

```bash
# run python
python app.py

# run C
gcc test.c -o test
./test

# run C++
g++ test.cpp -o test
./test
```

You can also use an IDE if you want to. There is Visual Studio Code, Jetbrains IDE and lots of others. If for some reason you prefer doing everything in the inconvenient way (with a mouse) then you can use an IDE for coding.
Shorten Your Deliverables
Tags: growth, motivation, learning, beginners
Published: 2021-08-31 03:06:44

---
title: Shorten Your Deliverables
published: true
date: 2021-08-24 13:22:00 UTC
tags: growth,motivation,learning,beginners
canonical_url: https://x-team.com/blog/shorten-your-deliverables/
---
I am interested in a thousand things. When I look up at the sky, I wonder how clouds form. When I look at a building, I wonder what makes it beautiful. When I look at the cars lined up in the narrow street where I live, I wonder how we can make cities more livable.

When you have this many questions about everything, you quickly realize that you have to choose. I don't have enough time to read a book about meteorology _and_ take a course in architecture _and_ read long articles on urban planning blogs. I have to choose what I want to focus on, and so does everyone else who's interested in many things.

The question then becomes, what do you choose? After all, the gateway to mastery is the ability to focus on something for years on end. So what do you choose that will keep your attention for that long?

Some people figure this out early in their life. They know what they want and can focus on it for a long time. But for those whose interests vary widely, knowing what to focus on isn't that straightforward. Everything seems at least _kind of_ interesting, but you won't know what you find _really_ interesting until you spend much more time on it.

One of the best ways to try out more of the things you find _kind of_ interesting to figure out what you find _really_ interesting is to shorten your deliverables.

What's the shortest possible amount of work that will deliver a complete result? That's what you should aim for. Take one pottery class and mold a clay pot. Build a to-do app in [Kotlin](https://x-team.com/blog/kotlin-flow-android-app/) before you think you're ready. Write a blog post about the history book you just read.

Create something tangible and see whether you find it interesting enough to continue focusing on. This is how you [try new things](https://x-team.com/blog/try-new-things/) and, ultimately, find what you're passionate about.

That's not all. Shortening deliverables is also a good way to [stay motivated](https://x-team.com/blog/loss-of-motivation/). It's satisfying to tick off items on your to-do list or move Trello cards on your Kanban board. Short deliverables make it feel as if you're making progress, which, in turn, encourages you to keep going.

Being interested in many things certainly isn't a bad thing. If anything, it's important to [cultivate your curiosity](https://x-team.com/blog/cultivate-curiosity/) and understand that there's depth everywhere in everything. But it's equally important to make something _your main thing_. Finding what that is and sticking with it is a matter of shortening your deliverables.
REACT JS timezone using moment-timezone
Tags: react, javascript, webdev, programming
Published: 2021-08-24 13:09:49

get timezone according to ip address or location using moment timezone library

function App() {

  var moment = require('moment-timezone');
   var timeZone = moment.tz.guess();
  console.log(timeZone);
  var time = new Date();
  console.log(time);
  var timeZoneOffset = time.getTimezoneOffset();
  console.log(timeZoneOffset);
  var abbr = moment.tz.zone(timeZone).abbr(timeZoneOffset);
  console.log(abbr);
  return (
    <div className="App">
    </div>
  );
}

export default App;

output : 

    Asia/Calcutta
    Mon Jun 28 2021 11:39:16 GMT+0530 (India Standard Time)
    -330
    IST
#005: Combinando filtros na busca do Elasticsearch
Tags: elasticsearch, bool, term, must
Published: 2021-08-24 12:30:21

Antes de continuarmos é importante ler [#004: Adicionando filtro na busca do Elasticsearch](https://dev.to/brunoflegler/004-adicionando-filtro-na-busca-do-elasticsearch-508l).

Dessa vez vamos aprender como combinar mais de um filtro na sua pesquisa, suponha que queremos filtrar todos os documentos que foram criados no dia 21/08/2021 e que o cliente tenha 49 anos.

```sh
GET customers/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "age": 49
          }
        },
        {
          "term": {
            "createdAt": "2021-08-21"
          }
        }
      ]
    }
  }
}
```

Encontramos 2 clientes com idade igual a 49 anos e que foram criados no mesmo dia.

```json
{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 2,
      "relation" : "eq"
    },
    "max_score" : 2.0,
    "hits" : [
      {
        "_index" : "customers",
        "_type" : "_doc",
        "_id" : "4",
        "_score" : 2.0,
        "_source" : {
          "id" : 4,
          "name" : "Mrs. Zachary Schneider",
          "email" : "Ruthie47@yahoo.com",
          "age" : 49,
          "createdAt" : "2021-08-21T03:16:33.102Z"
        }
      },
      {
        "_index" : "customers",
        "_type" : "_doc",
        "_id" : "92",
        "_score" : 2.0,
        "_source" : {
          "id" : 92,
          "name" : "Charlotte Hansen",
          "email" : "Adelbert82@gmail.com",
          "age" : 49,
          "createdAt" : "2021-08-21T03:16:33.126Z"
        }
      }
    ]
  }
}
```

Quando queremos combinar filtros onde **TODOS** os valores deverão estar nos resultados, iremos usar o termo `must`. Ex: Os clientes com 49 anos que não foram criados no dia 21 não serão retornados. O `must` equivale ao famoso `AND` se fizermos uma analogia aos bancos de dados relacionais.

Agora ficou fácil, para filtrar por mais atributos é só adicioná-los dentro do array.

```json
{
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "campo 1": "valor 1"
          }
        },
        {
          "term": {
            "campo 2": "valor 2"
          }
        },
        {
          "term": {
            "campo 3": "valor 3"
          }
        },
      ]
    }
  }
}
```

Sua vez agora, pratique. E te vejo no próximo artigo.
5 Things to do before making the build for Production. (React JS)
Tags: webdev, javascript, react, writing
Published: 2021-08-24 12:25:58

This article is not something you might not already know but maybe you might not have it all listed in a one place. There can be more things that I'll surely be missing in this article which I would like you to mention down in the comments so that I can compile another part to this article. And this is a beginner level post.

So let's start on listing the things that I feel one should do before pushing their production build. These are the things that I have used for the react project I have built but they are definitely the points which can surely be helpful in other projects.

**1.** Clearing all the `console.logs` that are absolutely not intended for the users. And it's rare that `console.logs` are there for users.

**2.** Remove all the `commented code` which doesn't serves any purpose or in the end is just misleading. Comments are meant for giving extra context to why something has been done not the other way around.


![Screenshot (309)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7ttpxsa5z79q4077anq4.png)

>The above screenshot depicts how there is a `useless console log` which the developer might have used for the `testing purpose` which should be `removed` once everything is wrapped up in development and the project is ready for getting into production.

>Another thing worth keeping note is the commented code which serves no purpose in the end.


**3.** Removing all the `unused npm packages` and `libraries` that are installed.

**4.** Deleting all the `unused files` that are just clogging up.

> It might feel overwhelming to find all the unused packages and files manually but don't you worry.
As the diamond cuts the diamond, in the same way we will use another package to remove the dead files. 

You can follow the packages below:
[depcheck](https://www.npmjs.com/package/depcheck)
[unimported](https://www.npmjs.com/package/unimported)

![Screenshot (119)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/935ega4ef8386v4uqz5k.png)

**5.** Check how the build works by `serving the build` in react. I know that I used to create a build and then push it to staging server to check how it will behave there because I wasn't aware of the fact that React offers this functionality. It's always good to check your build before pushing it to the server.

![Screenshot (310)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pfijqotdyhfohsq6zfqk.png)

*So basically this is not about improving the code or optimizing it. These things go hand in hand when you are doing development.*

*The goal🎯 of this article is primarily on giving the finishing touch to your React Web App before making it live in the production.*

*I hope this article was helpful to you. I would be more than happy to receive your feedback on this article. Thanks for your precious time reading this. Stay tuned for more insightful reading by me.😊*
How to add Firebase service account json files to Vercel
Published: 2021-08-24 12:19:47

---
title: How to add Firebase service account json files to Vercel
published: true
description: 
tags: 
//cover_image: https://direct_url_to_image.jpg
---

If you're using Firebase, Next.js, Vercel, firebase-admin, and if you've been Googling for the past hour on how to load your Google service account JSON file the easiest way possible, then you've come to the right place.

This blog post explains how to store the service account json file in a single environment variable and then pass it down to the Firebase admin SDK.

Here's how to do it:

## 1. Download the service account JSON file

Follow the steps at https://firebase.google.com/docs/admin/setup and download the JSON file.

##2. Remove line breaks on the JSON file

Go to https://www.textfixer.com/tools/remove-line-breaks.php and paste the content of the JSON file.

**Do not** remove the `\n` characters from the `private_key` fields or the key won't be valid afterwards.

## 3. Create a new Vercel environment variable with the JSON content

Either via a command line:

```sh
vercel env add FIREBASE_SERVICE_ACCOUNT_KEY
? What’s the value of FIREBASE_SERVICE_ACCOUNT_KEY?
```

(paste the JSON content and submit)

Or via the Vercel web ui: https://vercel.com/docs/environment-variables

In both cases, the value will be encrypted.

## 4. Use it locally in .env.local

This is the tricky part, because you have to use single quotes instead of double quotes when surrounding the environment variable value in your file.

I am using the gitignored `.env.local` as explained in the Next.js documentation: https://nextjs.org/docs/basic-features/environment-variables#loading-environment-variables.

```ini
# .env.local
FIREBASE_SERVICE_ACCOUNT_KEY='JSON file content without line breaks'
```

## 5. Use the environment variable

Here's an example Next.js api route that will receive a Firebase id token and verify it. See https://firebase.google.com/docs/auth/admin/verify-id-tokens#web

```ts
// pages/api/user.ts

import * as admin from "firebase-admin";
import type { NextApiRequest, NextApiResponse } from "next";

type Data = {
  uid: string;
};

const serviceAccount = JSON.parse(
  process.env.FIREBASE_SERVICE_ACCOUNT_KEY as string
);

if (admin.apps.length === 0) {
  admin.initializeApp({
    credential: admin.credential.cert(serviceAccount),
    databaseURL: process.env.NEXT_PUBLIC_FIREBASE_DATABASE_URL,
  });
}

// example usage 
export default async function revenueCatApi(
  req: NextApiRequest,
  res: NextApiResponse<Data>
): Promise<void> {
  const firebaseToken = req.headers?.authorization?.split(" ")[1];

  if (!firebaseToken) {
    res.status(404).end();
    return;
  }

  const decodedToken = await admin.auth().verifyIdToken(firebaseToken);

  res.status(200).json({ uid: decodedToken.uid });
}
```

That's it! Hope this helps.
You know what copyright is, but do you know what copyleft is?(short article)
Tags: opensource, devops
Published: 2021-08-24 12:01:38

Copyleft is a term referring to a license. It is used to indicate that a particular license allows to freely redistribute and modify the intellectual property(in most cases, source code) with the requirement of the same license to be preserved in the distributed works created from the original property. This type of license also preserves credit to the original owner. The redistributors must avail the source code of the redistribution, meaning that the redistributions need to be open source.<br>
Copyleft software licenses are more protective in contrast to free software licences which do not require the license and credit to the original owner to be preserved.<br><br> It is in extreme contrast to Copyright licenses which do not allow the redistribution of the intellectual property. Popular copyleft licenses include [GNU General Public License 3.0](https://choosealicense.com/licenses/gpl-3.0/) and [Mozilla Public License 2.0](https://choosealicense.com/licenses/mpl-2.0/).
A Quick 10-Second Programming Joke For Today
Tags: jokes, dailydeveloperjokes, watercooler
Published: 2021-08-24 12:00:30

---
title: "A Quick 10-Second Programming Joke For Today"
description: "Check out today's daily developer joke! (a project by Fred Adams at xtrp.io)"
series: "Daily Developer Jokes"
published: true
tags: #jokes, #dailydeveloperjokes, #watercooler
---

Hi there! Here's today's Daily Developer Joke. We hope you enjoy it; it's a good one.

![Joke Image](https://private.xtrp.io/projects/DailyDeveloperJokes/public_image_server/images/5e12594523a5e.png)

---

For more jokes, and to submit your own joke to get featured, check out the [Daily Developer Jokes Website](https://dailydeveloperjokes.github.io/). We're also open sourced, so feel free to view [our GitHub Profile](https://github.com/dailydeveloperjokes).

### Leave this post a ❤️ if you liked today's joke, and stay tuned for tomorrow's joke too!

_This joke comes from [Dad-Jokes GitHub Repo by Wes Bos](https://github.com/wesbos/dad-jokes) (thank you!), whose owner has given me permission to use this joke with credit._

<!--
Joke text:
___Q:___ What did the process say after working in an infinite loop all day?

___A:___ I need a break.
 -->
The ephemeral miniconf
Tags: perl, raku, conference, miniconf
Published: 2021-08-24 11:56:51

**The ephemeral miniconf** is a **Perl** and **Raku** virtual miniconf that will take place in Zoom the **18 november 2021**.

It's **free**, small and relax.

[![](https://raw.githubusercontent.com/thibaultduponchelle/the-ephemeral-miniconf/e274c8caf77e9b1b893a3034bc901e55fe3d82d6/ephemeralraptor.png)](https://thibaultduponchelle.github.io/the-ephemeral-miniconf/)

The talks can be about toolchain, devops, cloud, sysadmin, core, design patterns, web or whatever linked to Perl or Raku.

## Call for papers
There is still some slots for you to join the speakers team, please contact me at **thibault.duponchelle@gmail.com**

You will have to send me your material by email an I will make me available for rehearsals (but no hurry).

There is also slots for lightning talks that can be **small talks** or **advertisements** or just a few **funny slides**... Be creative!

## Infos
The main place to get informations like the **planning** and the **Zoom link** (when available) is on the [ephemeral miniconf info page](https://thibaultduponchelle.github.io/the-ephemeral-miniconf/).

![Roar](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/94fow3t1ahw0qkxn9zqv.png)

Join the crowd and I enjoy the event!
Code Snips
Tags: html, javascript, css
Published: 2021-08-24 11:20:39

I just released a small project know as [code snips](https://eureka-imagineee-server.github.io/code-snips/).

Basically, it's a small repo of code snippets I use or have made you can use in your project by just importing it or by copy and paste or what I like to call it:
> "Ctrl+A, Ctrl+C, Ctrl+V and this is now my code"
 
Get started today by going over to the [website](https://eureka-imagineee-server.github.io/code-snips/) and going through the list.

At the time of writing there might a small list of snippets, but this list will grow over time.

If you have any thing you might want to add, just ask in the comments.

I've just added my favourite: [springy Buttons](https://eureka-imagineee-server.github.io/code-snips/#springy-buttons)
How to properly ignore Junit 4 in Gradle and Maven
Tags: testing, java, gradle
Published: 2021-08-24 11:11:32

Jump to the best example here for [Gradle](#gradle) and [Maven](#solution)

### Problem

Quite a lot of Java dependencies bring [Junit 4](https://junit.org/junit4/) or [Junit vintage engine](https://junit.org/junit5/docs/current/user-guide/) as a transitive dependency.

As well as Junit vintage engine is [designed to integrate 4 and 5 version](https://github.com/junit-team/junit5-samples/tree/master/junit5-migration-gradle), it allows to use both at the same time. When you want to finally migrate, it leads to problems such as:
* Runtime issues: a junit4 class not found
* A test has run, but no coverage aggregated
* Not concise annotations usage

### Solution

All these problems have only one proper solution:

> Use one particular version of Junit to prevent misleading and misusage

Here I focus on the latest - Junit 5 version usage, hence, excluding of Junit 4.

One of the options is to ignore this dependency from a specific dependency:

```groovy
testImplementation('org.springframework.boot:spring-boot-starter-test') {
    exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'  
}
```
```xml
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <scope>test</scope>
    <exclusions>
      <exclusion>
        <groupId>org.junit.vintage</groupId>
        <artifactId>junit-vintage-engine</artifactId>
      </exclusion>
    </exclusions>
  </dependency>
```

**But**, it requires you to know _which_ dependency brings unpleasant dependency for you. In this case, you can use this command to track:

```shell
./gradlew dependencyInsight --dependency "junit:junit" --configuration "testCompileClasspath"
```

Another option is to exclude not necessary dependencies from **all the configurations**. It leads you another problems such as: some library still requires Junit 4 / vintage. But, the compilation / runtime reflection errors actually only makes these dependencies visual and help to mark **explicitly** those Java modules, that still require on any reason to work with a legacy library.

#### Gradle:

Having [configurations in Gradle](https://docs.gradle.org/current/dsl/org.gradle.api.artifacts.Configuration.html) it is easy to exclude a dependency in one particular place:

```groovy
/* for all the configurations */
configurations {
  all {
    /* only junit 5 should be used */
    exclude group: 'junit', module: 'junit'
    exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
  }
}
```
```groovy
/* for a particular test module */
configurations {
  testCompile {
  /* only junit 5 should be used */
    exclude group: 'junit', module: 'junit'
    exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
  }
  testRuntime {
    /* only junit 5 should be used */
    exclude group: 'junit', module: 'junit'
    exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
  }
}
```

And don't forget to leave a comment for the future!

### Resume

Hope this note helped to ignore unpleased dependency and keep control over your build configuration.