teleren/devto huggingface dataset:
Linux Commands: printenv
Tags: linux, beginners, codenewbie
Published: 2020-10-18 18:39:15

`printenv` is used to print out the environment variables. Environment variables are a common form of setting global values across a terminal session. Environment variables can be set by the systems, automation scripts, or by the user.

You can print your all environment variables using just `printenv`.

![Screenshot 2020-10-18 at 10.37.02 PM.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1603040828326/B5CBX8Ici.png)

If you want to print the value of a specific variable you can use `printenv <variable name>`.


![Screenshot 2020-10-18 at 10.38.24 PM.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1603040908883/PLr8z_kOF.png)

### Conclusion

If you are ever stuck and want to know what was the value of the environment variable you can use it. I have found myself using this quite often when debugging issues in production or on my local machine.

> If you liked this post please share it with others so that it can help them as well. You can tag me on Twitter [@imumesh18](https://twitter.com/imuesh18). Also please follow me here and on Twitter for future blogs which I write over [here](https://blog.umesh.wtf)
Dotenv-linter v2.2.0: find and fix problems in .env files
Tags: rust
Published: 2020-10-18 18:11:29

We have developed dotenv-linter — a useful tool for checking .env files. It helps to find problems in .env files that you might miss at first, but which later may result in incorrect work of applications. We have made the tool universal, it can be connected to any project regardless of the programming language.

We've just released a new version of dotenv-linter — v2.2.0, and here is an overview of the key changes included in this release!

https://evrone.com/dotenv-linter-v220
Social Dilemma, a thoughtful, yet dangerous topic to discuss in general
Tags: discuss, google, facebook, ethics
Published: 2020-10-18 17:51:34

Social Dilemma is a Netflix movie that discusses inevitable results of social platforms and personalized technologies, as a byproduct of capitalism that created them.

{% youtube uaaC57tcci0 %}

And there is [movie's official website](https://www.thesocialdilemma.com/).

I feel like the movie is heavily connected to [Center for Humane Technology](https://www.humanetech.com/).

## Some topics talked about

Some topics talked about are

- Financial incentives to largest companies' growth
  - I also interpret as direction in biggest Research and Development
- Recommendation system is extremely polarizing and narcissistic; and result in more confirmation bias
- Screen time, and navigating away from direct diplomatic discussions
- Maybe, too capitalistic social platforms are more likely to be affected
  - Lately, I chatted that social media should give more time to **discuss hard topics**, rather than just Likes.
  - Also, why friend recommendation, **without a personal introduction**, on Facebook? Maybe it is more beneficial to the capitalistic nature of the company?
- It works even if you are aware of it

## Adolescents are more affected

- I see mental health as the only part of it
- Another problem is unknown (and maybe unfavorable) effects on worldview and behavioral development

## Conclusion

I feel that we are starting to see more of the other side of utopia.

It is difficult to talk with polarized people, who are unaware, or not really aware. (Yeah, in my situation in my real country.) Also, it may be used to mistrust social media users.

Steering laws might be a way, but honestly I don't believe in more regulated system. (Digital privacy might not be a real solution, yet.)

Also, organization cannot grow without at least marginal profit, and even more profit is required for Research and Development.

Although I know no real solution, I believe that being aware (and getting more people to aware) is already the beginning of the solution.

<small>NB: I also get (very slightly) recommended [Qwant](https://www.qwant.com/) search engine. I will see how decent it is compared to Google and DDG.</small>
has Git scared you ?
Tags: github, git, discuss, devops
Published: 2020-10-18 12:20:17

i'll start with one of my scariest moment when i was like just got started with git cli. around **5-6** years ago, i was assigned on a project with 3 other developers. we had read/write access to Dev repo. i created a branch for my work and tried taking pull from dev repo. team was treating me like an alien(coz i was new) so i googled how to take pull. 

found lots and tried one by one. one **nonsense** user on stackoverflow caught my attention(dont know why lol..) i copied the command and ran it. unfortunately it worked and i got **Warning Email** next day because all other branches were deleted. 

this was the scariest moment of my life as a coder! whats yours ?
lab 4 - reinvent PR by remote repos.
Tags: opensource
Published: 2020-10-18 17:49:57

# lab 4 - reinvent PR by remote repos.

In this lab, we are going to simulate the pull request by using git remote. I first filed an issue on this repo [https://github.com/MSTEWARDSON/LinkStatus](https://github.com/MSTEWARDSON/LinkStatus). Then, I forked the repo to my own Github account [https://github.com/yzwdroid/LinkStatus](https://github.com/yzwdroid/LinkStatus).  I also made a new branch named issue-16 based on the master branch.

## First problem

After I got the permission to work on this issue(add a new feature - ignore URL patterns).
I started to work on the program linkStatus. The first problem is `go run
test.txt` didn't work on my computer. I realize there may be some issues with go module. So I asked Matthew on slack, He did some change on the upstream repo. So my forked version is behind the upstream repo. What I do is below:

```bash
// add remote repo
git add remote upstream https://github.com/MSTEWARDSON/LinkStatus.git
git fetch upstream
// rebase issue-16
git checkout issue-16
git rebase issue-16 upstream/master
```

The issue-16 branch is updated.

## Work on the feature.

The code structure is different from mine, although we all wrote this in go. I
read the code several times, and got a plan on how to add the feature. 

- add the flag -i or --ignore

```go
var ignore = flag.BoolP("ignore", "i", false, "ignore url patterns")
```
- add the function to parse the ignore file `ignore.txt`

```go
// extract the urls from ignore.txt
func ignoreURL(fileName string) []string {
	// urls to ignore
	var s []string
	file, err := os.Open(fileName)
	if err != nil {
		log.Fatal(err)
	}
	defer file.Close()
	scanner := bufio.NewScanner(file)
	re := regexp.MustCompile("^(#|https?://)")
	for scanner.Scan() {
		if !re.Match(scanner.Bytes()) {
			fmt.Println("Ignore file invalid")
			os.Exit(1)
		}
		if line := scanner.Text(); string(line[0]) != "#" {
			s = append(s, line)
		}
	}

	if err := scanner.Err(); err != nil {
		log.Fatal(err)
	}
	return s
}
```

- integrate the ignored slice to the url slice.

```go
	// TODO: ignore links here.
	if ignore {
		var tp []string
		s := ignoreURL("ignore.txt")
		fmt.Println("ignored urls ", s)
		for _, link := range result {
			valid := true
			for _, url := range s {
			if strings.HasPrefix(link, url) {
					valid = false
					break
				}
			}
			if valid {
				tp = append(tp, link)
			}
		}
		result = tp
	}
```

```bash
git commit -m "ignore feature done"
git push issue-16 origin
```

## How we collaborate without a pull request.

After I have done all the coding part, I told Matthew to check out my work by
adding my repo as a remote. Then Matthew noticed that I forgot to update the
readme file about the new feature. I added one more commit. Finally, Matthew
committed my issue-16 branch to the master branch. 

## The best way to learn something

The best way to learn coding or software like git is by building small programs
that you are using in your everyday life. This is the way I learned Go and Python.
Spring JDBC
Tags: spring, jdbc, jdbctemplate, java
Published: 2020-10-18 17:39:04

With traditional JDBC we got redundant (boilerplate) and error-prone code:

```java
public Account findByNumber(String number ) {
		String sql = "select * from accounts " +
			"where number = ?";		
		Account account = null;
		Connection conn = null;
		PreparedStatement ps = null;
		ResultSet rs = null;
		try {
			conn = dataSource.getConnection();
			ps = conn.prepareStatement(sql);
			ps.setString(1, number);
			rs = ps.executeQuery();
			account = mapAccount(rs);
		} catch (SQLException e) {
			throw new RuntimeException("SQL exception occurred", e);
		} finally {
			if (rs != null) {
				try {
					rs.close();
				} catch (SQLException ex) { // OMG
				}
			}
			if (ps != null) {
				try {
					ps.close();
				} catch (SQLException ex) { // OMG
				}
			}
			if (conn != null) {
				try {
					conn.close();
				} catch (SQLException ex) { // OMG
				}
			}
		}
		return account;
	}
```

With a try with resources we could make it easier, but not too much. Instead, with Spring JdbcTemplate we are using the [Template Method Pattern](https://dev.to/eidher/template-method-pattern-4ngf), cleaning the code, eliminating repetitive boilerplate code, avoiding common bugs, and handling exceptions properly:

```java
public Account findByNumber(String number) {
		String sql = "select * from accounts where number = ?";
		return jdbcTemplate.query(sql, accountExtractor, number);
	}

private class AccountExtractor implements ResultSetExtractor<Account> {

		public Account extractData(ResultSet rs) throws SQLException, DataAccessException {
			return mapAccount(rs);
		}

	}
```

Spring acquires the connection, executes the statement, processes the result set, handles the exceptions, and releases the connection. You can query for a single or multiple rows. JdbcTemplate returns each row of a ResultSet as a Map. When expecting a single row use queryForMap, when expecting multiple rows use queryForList, when inserting, updating, or deleting use the update method:

```java
	public Map<String, Object> getUser(int id) {
		String sql = "select * from users where id = ?";
		return jdbcTemplate.queryForMap(sql, id);
	}

	public List<Map<String, Object>> getUsers() {
		String sql = "select * from users";
		return jdbcTemplate.queryForList(sql);
	}
	
	public int insertUpdateOrDeleteUser(String sql) {
		return jdbcTemplate.update(sql);
	}
```

See [Spring Framework Documentation - Data Access with JDBC](https://docs.spring.io/spring-framework/docs/current/spring-framework-reference/data-access.html#jdbc)

See [Spring JdbcTemplate Example](https://examples.javacodegeeks.com/spring-jdbctemplate-example)
Quick tips - Git
Published: 2020-10-18 17:04:40

**What is git?**
=================

The distributed version tools. Used most to development of software

**Command for init repository:**

```
git init
```

**Command for configure name and email of user in git on repository:**

```
git config user.name "username"

git config user.email "email"

```

**Command for verify repository status:**

```
git status
```

**Command for monitore the files or confirm changes the files monitored to the git:**

```
git add .
```
**or** 
```
git add --all
```

**Command for list branchs:**

```
git branch -d branch_name
```

**Command for see commit histories:**

```
git log
```

**Command to send changes to remove repository:**

```
git push url_repository_remove_or_alias branch_name
```

**Command for delete remote repository:**

```
git push --delete url_repository_remove_or_alias branch_name

```

**Command for dowload changes remote repository:**

```
git pull url_repository_remove_or_alias branch_name

```
Recomendação 1 do narcello
Tags: javascript
Published: 2020-10-18 17:00:41

---
title: Recomendação 1 do narcello
published: true
description: Algumas coisas que estou estudando
tags: javascript
cover_image: https://agenciabrasil.ebc.com.br/sites/default/files/atoms/image/obra_de_mazzaropi_pode_ser_vista_no_museu_que_leva_o_seu_nome_em_taubate_sp_-_divulgacao_prefeitura_de_sao_jose_dos_campos.jpg?itok=raHWq829
---

Esses tempo atrás(*esturdia atrás*) eu senti vontade de dar uma aprofundada no tal do JavaScript, saber estrutura da dados com ele, classe, herança, saber as coisas que eu nem sei que existe mas que estarei descobrindo. Mas ai pra isso eu nao queria ir direto, comprar um curso na udemy e ja fazer o JS avancado. Eu queria pegar e ler desde o básico pois de fato nunca parei para ler, queria chegar no avançaado com a base forte.

1. Ai eu to lendo e seguindo esse mapa de curso aqui, que é bem detalhado, comeca só no JS, vai vai vai vai vai e depois entra no JS no Browser... ainda to no inicim, mas é bem massa, todo dia lendo um pra nao desanimar:
https://javascript.info/

2. E também assinei o blog do Dan Abramov JustJavaScript: https://justjavascript.com/
Ele manda no seu email todo dia uma discussão sobre algum tema de JS e não é uma algo simples e direta, ele meio que levanta umas discussões e faz você repensar umas paradas... Comecei esse dele esses dias, recebi dois só ainda, mas é bem brabo. Ele vai colocando uns artigos no meio que são bons também.

3. E pra fechar, agora algo mais avançado, eu me inscrevi no curso avançado de javascript do Erick Wendel(se não fosse dele eu não faria), mas como desde da campus party GYN eu piro nele eu vou fazer:
https://javascriptexpert.com.br/

Depois de feito tudo, algum dia no futuro, eu vou e vou escrevendo as impressões de cada um desses tópicos.
The Head and Tail of bash 
Tags: bash
Published: 2020-10-18 16:58:18

![Alt text of image](https://64.media.tumblr.com/bc00d9419e7001c1df300c3ee942f96c/tumblr_ns7ok5rMMR1rcqnnxo1_400.gifv)

Heads and Tails are not limited to the sides of a coin. In bash, these two words can be used to read from a file straight to your terminal. I found these two commands to be really useful recently and have been using them consistently. 

## Head

Starting with head, this command allows you to read a file into your terminal starting from the beginning. By default, the first twenty lines are read but there are ways to modify this.

```
head [filename] //=> First 20 lines
head -n 11 [filename] //=> First 11 lines  
head -30   [filename] //=> First 30 lines 
head -c 20 [filename] //=> First 20 characters  
```
The code above shows four different implementations of the head command along with the line flag(-n) and the character flag(-c).
These can be combined with other commands to display some unique terminal outputs. [More Here](http://www.linfo.org/head.html)

## Tail
Now onto tail; this command is similar to head but instead of reading from the beginning of the file it starts at the end. The default, like head, reads the first 20 lines from the end. The example below shows some basic uses of tail.

```
tail [filename] //=> Last 20 lines
tail -n 11 [filename]  //=> Last 11 lines  
tail -30   [filename] //=> Last 30 lines
tail -c 20 [filename] //=> Last 20 characters  
```
[More Here](http://www.linfo.org/tail.html)

## Middle??
By combining these commands it is possible to get sections of the text that do not start at the beginning or end. The example below reads a file from line 12 to line 22.

```
head -22 [filename] | tail -11 [filename]
```

Using the '|' between the two commands works as an 'and' operator so that the only lines read are those that are in the first 22 and the last 11 lines of the file. This results in terminal reading lines 12-22.
Completed Hacktoberfest
Tags: hacktoberfest
Published: 2020-10-18 16:24:58

I have officially completed Hacktoberfest 🎉 since my 4 PRs have passed the 14-day review period. While this year Hacktoberfest has not ended yet but it has a lot of stories.

On the first day, we have

{% post thewdhanat/digitalocean-s-hacktoberfest-is-hurting-open-source-2g99 %}

Then DigitalOcean and Dev team come with [the updated rules](https://hacktoberfest.digitalocean.com/hacktoberfest-update).

{% post devteam/an-update-on-hacktoberfest-37a %}

I learned that being an open source contributor is hard but being a project maintainers requires much more efforts.

Thanks to [DigitalOcean](https://dev.to/digitalocean) and [DevTeam](https://dev.to/devteam) for sponsoring and creating [resources](https://dev.to/devteam/hacktoberfest-etiquette-for-contributors-ec6) for this amazing event.
Type Checking in JavaScript
Tags: javascript
Published: 2020-10-18 16:19:52

I like to group all type checking tasks into helper functions like this to be used internally. This has the advantage in case of code minification [^1]

~~~ js
function isArray(x) {
    return Array.isArray(x);
}

function isBoolean(x) {
    return false === x || true === x;
}

function isElement(x) {
    return x instanceof Element;
}

function isFloat(x) {
    return isNumber(x) && 0 !== x % 1;
}

function isFunction(x) {
    return 'function' === typeof x;
}

function isInteger(x) {
    return isNumber(x) && 0 === x % 1;
}

function isNull(x) {
    return null === x;
}

function isNumber(x) {
    return 'number' === typeof x;
}

function isNumeric(x) {
    return /^-?(?:\d*\.)?\d+$/.test(x + "");
}

function isObject(x, isPlainObject) {
    if ('object' !== typeof x) {
        return false;
    }
    return isPlainObject ? x instanceof Object : true;
}

function isPattern(x) {
    return x instanceof RegExp;
}

function isSet(x) {
    return 'undefined' !== typeof x && null !== x;
}

function isString(x) {
    return 'string' === typeof x;
}
~~~

These functions are very inspired by PHP which already has standard functions such as `is_array()`, `is_object()`, `is_string()`, etc.

There was a proposal to allow users to write the type checking as `if ($int instanceof int) {}` expression somewhere. I don&rsquo;t know where the page is. I couldn&rsquo;t find it anymore.

**Update:** [found it!](https://wiki.php.net/rfc/class-like_primitive_types)

**Update:** Is now available as Node.js module.

{% github taufik-nurrohman/is %}

[^1]: Unless you specify it as object property in the library like `jQuery.isString = function(x) {};`. You cannot minify object property in any way.
Hacktoberfest 2020
Tags: hacktoberfest, github, git, opensource
Published: 2020-10-18 16:19:04


*This was my first Hactoberfest and for a beginner like me, it was really an amazing experience.I learned a lot about github and open source contribution.I completed the 4PRs plus extra 7PRs.It was a great experience for me. I suggest others also to take part in it.*
Preciso usar GOPATH para desenvolver com Golang?
Tags: go, portugues
Published: 2020-10-18 16:13:24

#TL:DR
Não! Use Go Modules no seu projeto

`$ go mod init <nome_do_projeto>`

# Entendendo
Em versões anteriores precisávamos definir a variável de ambiente GOPATH, com um ou múltiplos caminhos, para poder desenvolver usando golang. Porém a partir da versão 1.11 e na 1.13 já por padrão podemos utilizar a nova funcionalidade Go Modules, que basicamente permite escrevermos código em qualquer diretório com um arquivo go.mod, para criar programas sem depender dos caminhos definidos na referida variável.

# Mão na Massa
Acesse o diretório raiz do seu projeto e execute o comando:

`$ go mod init <nome_do_projeto>`

Nas versões 1.11 e 1.12 sete a variávelGO111MODULE=on

Deverá aparecer um arquivo 'go.mod' no seu diretório:

![Terminal exibindo arquivos](https://dev-to-uploads.s3.amazonaws.com/i/q8a7ukz3hwg52j95ot39.png)

### Por hoje é isso pessoal!

Obrigado pela visita, deixe seu like e siga para novos artigos sobre Desenvolvimento de Sistemas.

> @feiler no Twitter

# Saiba Mais
GOPATH https://medium.com/@vingarcia00/golang-why-not-use-the-gopath-87521259663a
GO111MODULE https://dev.to/maelvls/why-is-go111module-everywhere-and-everything-about-go-modules-24k
Create a Virtual Host with a script! 
Tags: virtualhost, nginx, aws, server
Published: 2020-10-18 16:11:03


Hello!
So I've been working on a shell script to help me setup a Virtual Host faster running on ubuntu (tested on aws ec2 instance).

Would be so happy if people would want give some critique and to test it on different server managers.

Link to github:
https://github.com/xhika/Create-A-Vhost

Some hosting experience is required..

So the steps would be:

Create an A record at your host provider
Clone the project to your server
In the github link follow the steps required. 
Edit the name of your host inside the .env file and give the scripts some rights provided in the description and you're pretty much good to go. 

Thanks :)
Linux Command line utilities i use almost everyday, why they are useful
Tags: linux, commandline
Published: 2020-10-18 16:01:20

pwd – current working directory .

ls – list all the folders in current working directory .

cd /dir_path – Go to certain directory .

cp rm mv – copy , remove and move files

mkdir dir_name – make a folder in current working directory .

chmod -options read_write_execute dir_path – set the mode (permissions) for current directory.

sudo username – select certain user configuration.

df – disk uses .

top – CPU and memory uses .

curl or wget url – http request in terminal

nano – terminal code editor

tar or unzip – unzip compressed file

ssh – remote login to computer

export – set up environment variables .

ufw – firewall for server

kill – kill a running process.

ifconfig – network utility .

So far that’s it , i will try to add more .
🎉My new portfolio🥳 -> do you like it?
Tags: beginners, discuss, webdev
Published: 2020-10-18 16:00:29

Hey!

Ok, ok... today is a great day because **I have finished the fifth version of my portfolio!** Here it is:

**[pabloherrero.me](https://pabloherrero.me)**

Finally I opted for HTML + CSS + Bootstrap 4 along with a couple of libraries ([Typed.js](https://github.com/mattboldt/typed.js/) and [Animate.css](https://github.com/animate-css/animate.css)) and the [Dracula](https://github.com/dracula/dracula-theme) color palette.

I have tried to keep everything as simple as possible.

You like?
My Top 3 Favourite JavaScript Array Methods
Tags: javascript, arrays, foreach, filter
Published: 2020-10-18 15:52:44

---
title: My Top 3 Favourite JavaScript Array Methods
published: true
description: bite-sized article about javascript array methods
tags: javascript, arrays, foreach, filter
---

In this tutorial I will be working in the **Google Chrome dev tools** console, so feel free to follow along.


![](https://i.imgur.com/j3GVn2O.png)



We will create an array of strings and we will go through each of those methods to see what they are used for in an array.

`let myTutorials = ['Python','JavaScript','Ruby']`

![](https://i.imgur.com/YgF6e8y.png)

### Starting with .forEach()

For each calls a function for each element of the array, in order so basically it loops over the array, and I mostly use `.forEach()` when I want to render something in the dom.

`myTutorials.forEach(tutorial => document.write(`I love ${tutorial}. `))`

![](https://i.imgur.com/hfCWAzB.png)

> Please be careful when you're working with objects, as forEach is an **array method**, and if you try to use it it will throw the following error

![](https://i.imgur.com/c9UFgKH.png)


### The next array method is called .filter() 

Filter it will create an array with the items that pass a certain condition which is provided as a function.

Let's create an array of numbers: `let arrayOfNumbers = [2, 53, 3, 81, 31, 5, 12, 66, 199, 34, 81, 19]`

In the following image you can see how the filter method is easy to apply when you know what you want to filter, in this case, I want to filter out numbers that are higher than 50

![](https://i.imgur.com/JT3XcXD.png)

### And last but not least, your soon-to-be best friend, .map() .

> Map will execute a function over all the elements it loops through, and create a new array of them. 

> Map will not change the initial array and we're calling this a non-destructive behaviour. 

Let's say I want to change something on every element of my previously initialized tutorials array

`let myTutorials = ['Python','JavaScript','Ruby']`

You can see here how I changed each element individually

![](https://i.imgur.com/WznO5af.png)

And here, I could even introduce a conditional statement to display my love for a certain language.

![](https://i.imgur.com/UpffdI0.png)


This bite-sized article is meant to quickly show you how you could use those 3 methods. I hope you enjoyed it and found it useful.