teleren/devto huggingface dataset:
Utilizando comandos do PostgreSQL sem digitar senha
Published: 2021-03-21 03:16:56

As vezes você precisa utilizar comandos no terminal ou executa-los em scripts, e as senhas podem ser um problema para se lidar, agora não mais:

## Fornecendo a senha com arquivo de senhas
Criando o arquivo de configuração

```bash
$ touch ~/.pgpass
$ chmod 0600 ~/.pgpass
```

Cada linha no arquivo define uma credencial para conexão

```bash
localhost:5432:project_a_db:jcottobboni:0yRkckAF8lYB 192.168.1.50:5432:project_b_db:jack:mCtEtSd8F08P 10.2.50.150:*:*:alice:flx1me0cTUJV
```

Assim você consegue executar comandos no terminal ou dentro de arquivos bash sem precisar digitar uma senha.

```bash
pg_dump -U jcottobboni -h localhost -p 5432 -Fc project_a_db > /home/jcottobboni/backup_for_project_a_db
```

Não e obrigatório utilizar o mesmo caminho para o arquivo especificado na criação do arquivo, o postgres fornece a configuração para customização do caminho.

```bash
export PGPASSFILE=~/.mycustomfile
```

## O parâmetro -w
w, — no-password nunca emita um prompt de senha. Se o servidor exigir autenticação por senha e uma senha não estiver disponível por outros meios, como um arquivo .pgpass, a tentativa de conexão falhará. Essa opção pode ser útil em tarefas em lote e scripts em que nenhum usuário está presente para inserir uma senha


## Fornecendo senha utilizando variáveis de ambiente
Outra maneira é definir variáveis de ambiente, você pode definir PGHOST, PGPORT, PGDATABASE, PGUSER e PGPASSWORD e usá-lo em seus scripts

Referências
[PostgreSQL 9.3.4 Documentation — libpq — Environment Variables](https://www.postgresql.org/docs/9.3/libpq-envars.html)
[PostgreSQL 9.3.4 Documentation — libpq — The Password File](https://www.postgresql.org/docs/9.3/libpq-pgpass.html)
Instalando versões antigas do Ruby com Rbenv
Published: 2021-03-21 03:08:55

Até aonde eu testei e tive experiência as versões do Ruby menores de 2.4 necessitam que esteja instalado a libssl 1.0 no linux, enquanto que as versões maiores que 2.4 requerem que esteja instalada a libssl com versão maior que 1.1.
Os dois pacotes entram em conflito um com o outro, então você não poder ter os dois instalados. Parece uma coisa besta para se escrever aqui, mas me salvou na hora da instalação para trabalhar com projetos mais antigos, então vamos lá.

para ruby <2.4

```bash
sudo apt install libssl1.0-dev 
rbenv install 'version'
```

para ruby >2.4

```bash
sudo apt install libssl-dev 
rbenv install 'version'
```
Gmail SMTP Settings for the Brother MFC-L3770CDW
Tags: brother, gmail, smtp, mfcl3770cdw
Published: 2021-03-21 03:04:38

# TL,DR: Your SMTP settings should look like this:

![Brother MFC-L3770CDW SMTP Settings page screenshot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z3562xou0cowpy42lpn8.png)

----

If your Gmail account is 2FA protected - and it absolutely should be - you'll have to [generate an app password](https://support.google.com/accounts/answer/185833?hl=en). 

You'll also need to configure at least 1 administrator email address in the web UI at `Network` -> `Notification` -> `Administrator Address`. Click 1 of the `Notification` links to set the address.

Going field by field:

* `Server Address`: `smtp.gmail.com`
* `Port`: `25` (Don't worry about the fact that Gmail's official SMTP documentation specifies ports 465 & 587 for SSL and TLS, respectively. Those apparently don't apply here)
* `Server Authentication Method`: `SMTP-AUTH`
* `SMTP-AUTH Account Name`: `Your_@Gmail.com_Address`
* `SMTP-AUTH Account Password`: `app_password`
* `SSL/TLS`: `TLS`
* Check `Verify Server Certificate`
* `Device Email Address`: `Anything_You_Want` (that doesn't have a space character, presumably)

After entering all the above, click `Submit` and then test the configuration in the following page. You should receive an email at the administrator address you previously configured.
What is .env?
Tags: webdev, node, programming, codenewbie
Published: 2021-03-21 02:50:35

In this tutorial, we will implement a **.env** into our **NodeJS** app to store environment variables inside of it.
Here I will introduce how you can use environment variables and for what you should use them. Let's Go. 

--- 

## dotenv

Dotenv is a zero-dependency module that loads environment variables from a **.env** file into *process.env*. Storing configuration in the environment separate from code is based on The Twelve-Factor App methodology. 

init npm in our directory

```javascript
npm init -y
```

Install express (for the server) and dotenv

```javascript
npm install express dotenv
```

Install nodemon to start the server in watch mode. 
Watch mode => Restarting the server on file change

```javascript
npm install -D nodemon
```

--- 

Create a file called ".env" in the root directory and insert a variable using NAME=VALUE. 

We want to put in out PORT variable to define the port on which our server will start on that is **PORT=3001**. 

In a real-world application, you want to store your API key and any kind of sensitive data like passwords here. 

**Importing Express**              

`const express = require('express');`

**Initialize the app**                 

const app = express(); 

---

### Configure dotenv

This will load the variables we created in the .env file into the process.env so we can use it using process.env.VARIABLE_NAME 

`require('dotenv').congif();`              

---

Getting the port from the .env file and set 3000 as a fallback. 

`const port = process.env.PORT || 3000;`

Starting the server using the port : 

`app.listen(port, () => console.log(`server on :${ port }` ));`

--- 

## nodemon index.js

```
[nodemon] 2.0.4
[nodemon] to restart at any time, enter 'rs'
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node index.js`

```

Now, this should be console logged. If we wouldn't run `require('dotenv').config();` in the index.js then the log should be '**server on:3000**' because then our fallback value would be applied for the port variable. 

server on:3001

--- 

Originally here =>  [https://rahulism.tech/article/what-is-env-file/](https://rahulism.tech/article/what-is-env-file/) 

---

😀 SIMPLE

<a href="https://buymeacoffee.com/rahxuls" target="_blank">
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1616209806065/A24KTdOi6.png?auto=compress">
</a>
Geek Week Local : Learnings
Published: 2021-03-21 02:22:19

#Geekweeklocal is one of the best things that happened to me and I am very grateful for it.
we have learnt to a great deal about application of various platforms first hand and to know how data needs to be sourced and organized.
We have also come across various kinds of projects that can be done and that can be learnt.
we have learnt about using Github, Stack overflow, firebase, designing websites, creating a community out of our guild and to publicly make it a brand.
It has been a great experience and I am eagerly looking out for more of such.

Thank you @geeksforgeeks_students_chapter for taking this initiative and granting us this opportunity to learn.
How to use half and quarter  columns using Bootsrap 4 grid system
Published: 2021-03-21 02:17:45

We know that Bootstrap bootstrap divides the screen into 12 columns. Each column is 1/12th of entire screen... 

But what if you want to a column which is 1.5 column wide? I recently came across a scenario where I wanted my columns wo be slightly wider that 1 column... say 1.25

In order to achieve this, I created a [custom bootstrap extension][1], which allows using fractions of columns.

Usage
-----

In order to use **bootstrap-half-and-quarter-grid** library, you just need to include the css file in your project. You can either copy/paste the file or use one of the following CDNs:

https://cdn.jsdelivr.net/gh/hoomanbahreini/bootstrap-half-and-quarter-grid/fractional-grid.css https://cdn.jsdelivr.net/gh/hoomanbahreini/bootstrap-half-and-quarter-grid/fractional-grid.min.css


Once you have included the library in your project then you can use its class... there are 3 main classes:

````
/* 
 * replace star with a number between 0 and 11 
 */
col-*-1qtr 
col-*-half
col-*-3qtr
````
Example:
--------
````
// add a reference to: https://cdn.jsdelivr.net/gh/hoomanbahreini/bootstrap-half-and-quarter-grid/custom-bootstrap-grid.min.csc

<div class="container">
  <h2>Using fraction of columns</h2>
  <div class="row">
    <div class="col-2-1qtr bg-success">2 and quarter</div>
    <div class="col-3-3qtr bg-warning">3 and 3 quarter</div>
    <div class="col-2-half bg-success">2 and half</div>
    <div class="col-3-half bg-warning">3 and half</div>
  </div>
</div>
````

About Me:
---------
I am software developer at [Shopless online marketplace][2] based in Wellington NZ.

  [1]: https://github.com/HoomanBahreini/bootstrap-half-and-quarter-grid/blob/main/README.md
  [2]: https://www.shopless.co.nz
Show my IP Address - showip.io
Published: 2021-03-21 02:13:05

The web app showip.io was inspired by other web apps like showmyipaddress.com, ip. me, etc. The web app is server-rendered with ReactJs and ExpressJs. 

The server runs a Node.js application managed by PM2 and gives users secure access through an Nginx reverse proxy. The Nginx server offers HTTPS via a free certificate by [Let’s Encrypt](https://www.digitalocean.com/community/tools/nginx).

[Show my IP Address](https://showip.io/)
Strands of information about Javascript Strings
Tags: javascript, webdev, codenewbie, beginners
Published: 2021-03-21 01:34:12

In a programming language, we are directly speaking to a computer and provided instructions to execute. Some of those most communicative instructions include text called *strings* that also make providing instruction to users of your programs straightforward. 

### Strings

Strings can be defined as a data type that represents a  string of sequential characters. It is commonly implemented in an Array data structure and declared by a variable that will be stored in your computer's memory. 

```javascript 
// String Declation:
const message = "I love strings" 
```

### By Value 

In javascript, a string is a primitive data type that is immutable and javascript passes all of these types by value. 

```javascript 
// String Immutability:
let color = 'yellow'
color[0] = 'm' // the value will not change the color value
console.log(color) // yellow 
```

### String Manipulation 

Here are a few ways to make use of strings

```javascript
// String Concatenation: appending strings to another string
let food = "cakes" 

// concatenating a string literal to a the *food* variable that contains a string
console.log("hot" + food) // hotcakes 

// String Interpolation: evaluation of values inside of a string
 
let size = "tall"
let str = `This bridge is so ${size}` // This bridge is so tall

// Notice the backticks(``) and dollar sign($)

```

### String Methods
```javascript 

// length: returns size of the string

let title = "developer" 
console.log(title.length) // 9 

// charAt: returns character at index 

let str = "developer" 
console.log(str.charAt(0)) // d 

// toUpperCase: returns a string with upper-casing

let str = "developer" 
console.log(title.toUpperCase()) // DEVELOPER 

// slice: returns a copy of a string with stripped characters
// String.prototype.slice(start, end) 

let str = "developer" 
console.log(title.slice(0,3) // dev 
```

### Let's chat about Strings
This was a crash course that I hoped helped you to learn more about strings. If you enjoyed this post feel free to leave a comment about your thoughts and experiences working with strings.

Happy Coding,
Terry Threatt
Column guideline on Visual Studio
Tags: editor, visualstudio
Published: 2021-03-21 01:33:40

Nowadays we are not limited to [80 character long punch card or terminals](https://softwareengineering.stackexchange.com/q/148677), but respecting a column guideline makes it so much nicer to read code (no vertical scrolling). 120 is the magic number for me.

Pretty much every decent editor features it however, Visual Studio doesn't, and sadly for the longest time:

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

[Thankfully, there's a little extension just for that](https://marketplace.visualstudio.com/items?itemName=PaulHarrington.EditorGuidelines). After installing it, just right click on the editor to use it:

![](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9f8feg67gewhkmuwxhtm.png)

Thank you Paul Harrington ❤️
Ignoring case and underscore on JSON deserialization in C#
Tags: csharp, dotnet, json
Published: 2021-03-21 01:11:56

For ignoring case, it's a matter of creating and using a `JsonSerializerOptions`. For the underscore, there's no out-of-the-box approach other than set it with `JsonPropertyName`:

```cs
using System.Text.Json;
using System.Text.Json.Serialization;

public static class Program
{
    public static void Main(string[] args)
    {
        var jsonOptions = new JsonSerializerOptions { PropertyNameCaseInsensitive = true };
        var jsonString = @"{
          ""title"": ""Mario"",
          ""description"": ""Video game character"",
          ""extract"": ""Mario is a fictional character in the Mario video game franchise, owned by Nintendo and created by Japanese video game designer Shigeru Miyamoto. Acting as the company's mascot, as well as being the eponymous protagonist of the series, Mario has appeared in over 200 video games since his creation. Depicted as a short, pudgy, Italian plumber who resides in the Mushroom Kingdom, his adventures generally center upon rescuing Princess Peach from the Koopa villain Bowser. Mario's fraternal twin brother and sidekick is Luigi."",
          ""extract_html"": ""<p><b>Mario</b> is a fictional character in the <span><i>Mario</i> video game franchise</span>, owned by Nintendo and created by Japanese video game designer Shigeru Miyamoto. Acting as the company's mascot, as well as being the eponymous protagonist of the series, Mario has appeared in over 200 video games since his creation. Depicted as a short, pudgy, Italian plumber who resides in the Mushroom Kingdom, his adventures generally center upon rescuing Princess Peach from the Koopa villain Bowser. Mario's fraternal twin brother and sidekick is Luigi.</p>""
        }";
       
        var summary = JsonSerializer.Deserialize<Summary>(jsonString, jsonOptions);
    }
}

public class Summary
{
    public string Title { get; set; }

    public string Description { get; set; }

    public string Extract { get; set; }

    [JsonPropertyName("extract_html")]
    public string ExtractHtml { get; set; }
}
```

If you feel like setting the `JsonPropertyName` for each needed property is too cumbersome, I believe you can handle it with a [JsonNamingPolicy](https://docs.microsoft.com/dotnet/api/System.Text.Json.JsonNamingPolicy) (but I'm yet to try it myself).
How to get the hostname of the OS in Node.js?
Tags: node
Published: 2021-03-21 00:00:00

---
  title: How to get the hostname of the OS in Node.js?
  published: true
  tags: Nodejs
  date: Sun Mar 21 2021 05:30:00 GMT+0530 (India Standard Time)
  canonical_url: https://melvingeorge.me/blog/get-hostname-of-os-nodejs
  cover_image: https://melvingeorge.me/_next/static/images/main-84ed1a60defdabe99237a52d5ab8f728.jpg
  ---
  [Originally posted here!](https://melvingeorge.me/blog/get-hostname-of-os-nodejs)
  
To get the name or hostname of the OS, you can use the `hostname()` method from the `os` module in Node.js.

```js
/* Get hostname of os in Node.js */

// import os module
const os = require("os");

// get host name
const hostName = os.hostname();
```

- The method returns the name of the system where the OS currently is installed as a `string`.

See the above code live in [repl.it](https://replit.com/@melvin2016/get-hostname-of-os-nodejs).

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

---
How to Check If An Object is Empty in JavaScript
Tags: javascript, webdev, tips
Published: 2021-03-21 00:00:00

---
title: 'How to Check If An Object is Empty in JavaScript'
date: 21-03-2021
fullDate: Sunday, 21 March 2021
tags: JavaScript, webdev, tips
description: 'In this article, I will be sharing different ways to check if an object is empty in JavaScript.'
image: 'https://www.agirl.codes/posts-images/social-media-header.jpg'
canonical_url: https://www.agirl.codes/how-to-check-if-an-object-is-empty-in-javascript
published: true
---
In this article, I will be sharing different ways to check if an object is empty in JavaScript.

Let's start with creating an empty object using literal syntax.

```jsx
const myObject = {}
```

### 1. Object.entries()

This method returns an array containing the [key, value] pairs found in the object passed in as an argument.
To check if an object is empty, check if the length of the array is 0.

```jsx
Object.entries(myObject).length === 0;
// 0

return Object.entries(myObject).length === 0 ? true: false
// true
```

### 2. Object.keys()

This method returns an array of strings that contains enumerable properties of the object passed as an argument. It returns an array of *[ keys ]*

```jsx
Object.keys(myObject).length === 0;
// 0

return Object.keys(myObject).length === 0 ? true: false
// true
```

You can also create an isEmpty function and pass in the object as a parameter

```jsx
function isEmpty (myObject) {

return Object.keys(myObject).length === 0 ? true: false

}

isEmpty(myObject); // true
```

### 3. Object.getOwnPropertyNames()

It returns an array of strings that corresponds to the properties found in the object passed as an argument. This method calls GetOwnPropertyKeys under the hood.

```jsx
 Object.getOwnPropertyNames(myObject).length === 0;
// 0

if(Object.getOwnPropertyNames(myObject).length === 0) { // return something};
```

### 4. !myObject.key

It checks if the `[key]` is present in `myObject`. Use this when you know the properties that the object is supposed to have.

```jsx
let result = '';

my.object.id // undefined

if (!myObject.id) result = 'object is empty'

console.log(result) // object is empty
```

Note: this won't work `myObject[id]`, JavaScript will throw an error.

### Using a JavaScript Library

### 5. UnderScore.js

[_.isEmpty(collection)](https://underscorejs.org/#isEmpty) Returns true if **collection** has no elements. For strings and array-like objects _.isEmpty checks if the length property is 0. 

```jsx
_.isEmpty([1, 2, 3]);

=> false

_.isEmpty({});

=> true
```

### 6. Lodash.Js

[_.isEmpty()](https://lodash.com/docs/#isEmpty) Method Checks if the value is an empty object, collection, map, or set. Objects are considered empty if they have no own enumerable string keyed properties.

```jsx
_.isEmpty({ 'a': 1 });
// => false

_.isEmpty(myObject)
// true
```
Linear-gradient Text and Animated Linear-gradient
Tags: css
Published: 2021-03-20 23:53:00

{% codepen https://codepen.io/brandonmweaver/pen/YzpmLgZ %}

The key to linear-gradient text is to set the background-clip property to text; this allows you to then apply a transparent color to the text and reveal the linear-gradient background image beneath.

To Animate a linear-gradient background, you simply need to set the background size of the image to be larger than the element, and change the background position within the animation.

You can also apply both of these solutions to get animated linear-gradient text.
GEEK WEEK LOCAL: VIT BHOPAL
Published: 2021-03-20 19:48:47

The GeeksforGeeks VIT Bhopal Community had arranged a marvelous week- long competition where the Community would set some daily tasks and challenges and everyone had to complete them within a time limit of 24 hours. All the students of VIT Bhopal were eligible to take part in this event. Throughout the span of a week -starting from 16th March till 21st March- a healthy competition had ensued between the guilds. I belonged to the BugBusters guild and we, as its members, had a tremendous amount of enjoyment, amusement and excitement throughout the week solving all the tasks. Starting from Day 1, we learnt how to use GitHub and exercised on competitive programming. Day 2 saw us delving deeper into the technical stuffs and examining them properly. Day 3 had us making an android app, generating a tic tac toe game and using a weather API. Day 4 was all about data visualization and exploring web development and redesigning and creating websites. Day 5 brought in tasks like automation, password encryption, building an AI project, generate a chess game and using a social media API to name a few. As the week progressed the tasks grew all the more interesting and tougher. We had week-long and weekend challenges too where we had to research more into web automation, music API, working with GUI, voice assistant and probe deeper into GitHub.
Google Play to F-Droid Migration & Setup of Termux, Termux:Tasker, & Termux:Styling
Tags: android, termux, tasker, fdroid
Published: 2021-03-20 23:44:08

# Migration

Situation: you have a bunch of Tasker stuff that depends on Google Play Termux, which is no longer updated. You need migrate to F-Droid Termux. What to do?

If you're setting up Termux for the 1st time, skip to the next section.

1. If anything you use Termux for depends on commands that do not ship with the base installation or you have scripts that exist only in Termux's home folder, [back up your Termux](https://wiki.termux.com/wiki/Backing_up_Termux). You may have to ask about these at the [official subreddit](https://www.reddit.com/r/termux) or check their [packages list](https://github.com/termux/termux-packages/tree/master/packages). If all the commands you use are in the base installation, skip this step
2. Uninstall all your existing Termux apps

# Setup

1. Install the F-Droid counterparts of the Google Play Termux apps removed in the previous section
2. If you want Termux to be able to interact with `/sdcard` and expandable storage, grant it storage permissions:
   1. Open Termux
   2. Run `termux-setup-storage`
   3. Tap `Allow` in the ensuing pop-up
3. If you previously backed up your Termux, follow the instructions at the backup instructions link above to restore your backup
4. If you have external scripts you want to run in Tasker, import them by running `cp /sdcard/SourceFolder/Script.sh ~/.termux/tasker/Script.sh` in Termux
5. To allow Tasker to execute Termux commands, enable Tasker's Termux permission: 
   1. Enter Android Settings
   2. Tap `Apps`
   3. Tap `Tasker`
   4. Tap `Permissions`
   5. Tap `Additional permissions`
   6. Tap the `Allow` radio button

And that's it. If you have existing Tasker Termux tasks and toggles they should work now. 

More information:

* [Advanced Termux:Tasker setup options](https://github.com/termux/termux-tasker#Setup-Instructions)
* [Setting up new Termux:Tasker tasks](https://github.com/termux/termux-tasker#tasker)
Cheat Sheet for Path Markup Syntax
Tags: wpf, xaml
Published: 2021-03-20 23:40:51

Path Markup Syntax allows WPF Developers to skip nested Segements and use a single line of code to draw multiple shapes. This cheat sheet provides a quick reference to the different syntax of Path Markup Syntax.

![Cheat Sheet for Path Markup Syntax](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yns08cx9u6romt3sfo3m.JPG)
How can I include resources in a compiled C# program for later use?
Tags: dotnet, csharp, help
Published: 2021-03-20 23:33:06

I want something similar to the effect of how Jar files retain data (as they are like zip files).
Since this is not the case w/ CSharp, how can I include resources?

Here's an example of what I want to do (this is meant to be a filesystem):
```
Project:
 Main.cs
 Components:
  JSONHandlers.cs
  JSON:
   myFile.json
   one.json
   two.json
```
Now, let's say I want to read `one.json` from the compiled output (`Project.exe`), as far as I'm aware, files like these aren't included in the end-product, and it doesn't create a file for this, so if I try to read that file, it will throw an exception.

Another example is if I have a folder of resources (images, dialogue, etc...) (in a game-dev ctx), and I tried to use those.
So, is there any way of packaging these resources with the executable?

<div alt="Thanks! Cheers!">
##<b><center><b>Thanks!<br/>Cheers!</b></center></b>
</div>