teleren/devto huggingface dataset:
How to Set Permanently $PATH on Linux/Unix
Tags: bash, zsh, linux, unix
Published: 2020-04-07 12:34:53

---
title: How to Set Permanently $PATH on Linux/Unix
published: true
date: 2020-01-09 00:00:00 UTC
tags: bash, zsh, linux, unix
canonical_url: https://tech.serhatteker.com/post/2020-01/how-to-set-path-permanently-on-linux-unix/
---

You're trying to add a directory to your `$PATH` so it will always be in your linux `$PATH` and accessible anywhere.

You can add your 'path' to `$PATH` with below command:

```bash
$ export PATH=$PATH:/path/to/dir
```

However each time you exit the terminal or start a new terminal instance, or reboot the system this path is lost and you need to run the export command again.

To set it permanently follow one of the two below:

## User Wide
This method will effect your 'current user' only.  According to your shell, add your path into your `.profile`, `.bash_profile`, `.zprofile`.

For instance, add it to `/home/user/.profile` or in short `~/.profile`:

```bash
# ~/.profile

export PATH=$PATH:/path/to/dir
```

Then source the file to activate the new `$PATH`:

```bash
$ source ~/.profile
```


***
_Note:_

You can add it into `.bashrc`,`.zshrc` as well but I do not prefer this method. Since environment variables should be set in `~/.profile`.

## System Wide
This method will effect all users in your system. It means that if you add path with this method the path will be visible for all users in the system. In order to execute that you have to have `root` privileges.

Add your 'path' to `/etc/profile/`:

```bash
# /etc/profile

export PATH=$PATH:/path/to/dir
```

All done!
Operator Overloading in JavaScript, more fun with a technical design.
Tags: javascript
Published: 2020-01-08 23:51:14

More for fun than anything else, I am a little obsessed with strange syntax. If you want to know how this works check out the first post. This is a mock-up of some sort of node.js http server library that reads more in english, probably good for some code generation 🤷‍♂️.

This is parsing just fine 🤣 stick it in your console I dare you.

``` js
// Skip to the end for shock and awe.
const get = () => ({
  valueOf(){
    return 0;
  }
});
const Ok = {
  valueOf(){
    return 1;
  },
  html(){
    return {
      valueOf(){
        return 2;
      }
    }
  }
}
const Err = {
  valueOf(){
    return "";
  },
  page() {}
}

// usage?
const homeRoute = get `/foo/bar` << Ok.html `
<div>
   somehow tis valid?
</div>
` | Err.page()
```

I should note that valueOf is returning some random values, the fully computed value of homeRoute is 0, what you would want to do perhaps instead is build up some stringified JSON object which describes this chain of routing. Was a URL given? Was an error given? etc etc.

I kind of like this design because it's so decoupled it's beyond funny. It's also a very to the point design. URL OK HTML OR ERR. It's like a caveman, hmmm caveman.js 😳 nah
How to set Eslint and Prettier for a React project on vs code
Tags: codenewbie, react, vscode, showdev
Published: 2020-01-08 23:37:58

Hello guys, so I was just taking a look on some of the most recent post, and more that any other thing I saw "How i set my tests for react" but I think one of the most important parts of setting a new react app, its the linting and the styles.

# Lets install everything
So we are going to need some packages, but all of them are going to be in your devDependencies so it wont matter for your deploy.

You are going to need to execute this command on your react project root
## Eslint

```bash
npx eslint --init
```
here we are going to need to answer some questions, try to answer them yourself or use my answers:
![Answers](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/evx3ipukhbv4e15ey4p3.png)

## Prettier

```bash
npm install -D prettier eslint-config-prettier eslint-plugin-prettier
```
here you actually just need to install this packages...

# Eslint configuration

So we need a file on our react project's root called ".eslintrc.js", you will probably have it because of the commands we ran, but we are going to make some little changes, just adding prettier on our extends and our plugins.

```js
// This is your .eslintrc.js file
module.exports = {
  env: {
    browser: true,
    es2021: true,
  },
  extends: ['plugin:react/recommended', 'airbnb', 'prettier'],
  parserOptions: {
    ecmaFeatures: {
      jsx: true,
    },
    ecmaVersion: 12,
    sourceType: 'module',
  },
  plugins: ['react', 'prettier'],
  rules: {
    // this one is if you are using jsx on .js files
    'react/jsx-filename-extension': [1, { extensions: ['.js', '.jsx'] }],
  },
};
```

 
# Prettier configuration

Once again we need a file on our react project's root called ".prettierrc.js".
And here we are going to write as a common JS file with a module exports, lots of people have different prettier settings, but this ones are simple and effective

```js
// This is your .prettierrc.js file
module.exports = {
  printWidth: 100,
  singleQuote: true,
  trailingComma: 'es5',
};
```

That should be all, now we just need to set vs code.

# vs code setup

Actually this is the shortest of all the blog, you just need to install to extensions to your vs code.

1. Eslint (dbaeumer.vscode-eslint)
2. Prettier (esbenp.prettier-vscode)

Either use ctrl+shift+p to excute the command "ext install <Extension>"
or just look for them on the store.

to style your code you just need to use ctrl+shift+i (alt+shift+f on windows) on the .js or .jsx file you need to style


That should be all, if you need any kind of help with this just leave a comment and I will try help you out.
Coding: the great mystery, just waiting for you to solve it
Published: 2020-01-08 23:36:18

I will happily admit that I love coding. I have been at it for long enough now to get at least some exposure to a huge swath of languages... from AppleBASIC on the IIgs, to TI-BASIC on the TI-89, to C, C++, Java, C#, Python, Prolog, Assembly, and now Lua too! What I find most motivating is that I can make a difference for someone, somewhere, with some code that solves a problem, whether it's speeding up a tedious task or just giving someone entertainment. As a programmer, you truly CAN make this world better - and as a group, we tend to forget this, as the development process itself is uniquely challenging.

If you have ever spent 3 hours staring at output from a debugger, for something you intended to allocate 30 minutes to, you know how puzzling coding errors can be to ferret out and solve. Yet, I feel a sense of satisfaction and even excitement when I finally debug an elusive issue. The best example I can give comes from one of my earliest games: Fantastle. In the process of building v2.0, I wanted to add layers to the game's map model (so you could stack a key on top of any type of ground you want, for instance). Implementing the map changes was easy. Getting the drawing code to display the results properly... wasn't. It took me 4 weeks of sheer persistence before I finally figured out what was wrong: I was drawing the layers bottom-to-top, rather than top-to-bottom, so the bottom layer was the only visible one. A few changes later, and IT WORKS!

One thing led to another, and now I'm working on games 33 and 34! It's truly amazing to me that I got so sucked into coding... to the point that, despite never expecting to find myself in web app development professionally, let alone personally, I find myself doing both nowadays! 

New coders reading this: May you be inspired to attempt great things... and don't be afraid to fail. As coders, we learn a LOT through failures.
React, Reactive Microservices, Kubernetes, GraphQL & gRPC - Appwish - Fullstack Tutorial Series & Opensource Project Update #1
Tags: react, javascript, java, webdev
Published: 2020-01-08 23:35:08

#### Hello everyone! Just wanted to give you an update on the project. 

## I did not expect so many people willing to contribute - we got over 60 people on Slack channel at the moment!

If you have not read the previous post in this series I'll give you some context with a short quote that describes the high-level overview of the platform we build:

> Appwish - a platform where people can express their app wishes (e.g. "I  wish I had an app for X and Y") and vote up other people's great ideas.
>
> Developers can use Appwish to keep track of the most wanted apps and features. They can assign themselves to projects, create dev teams and collaborate to fulfil people's needs.
> 
> In the future, the platform could also introduce elements of fund-
> raising or voluntary donations for the most appreciated developers and teams.

We are still on stage of planning the features/architecture of the platform - you can track the progress of planning here:

- Architecture: https://app.creately.com/diagram/ToXBd2y63z4/view
- "Mind Map" of features and user journey: https://app.creately.com/diagram/SB1Gc6cyHdD/view

Those two still evolve thanks to suggestions of the contributors.


We are planning to use React for UI(with SSR), React Native for mobile, GraphQL + gRPC for communication and mainly reactive Vert.x on the backend - if you want to join us and learn some stuff by actually doing things, join us on the Slack channel: https://join.slack.com/t/appwish/shared_invite/enQtODk4MTgzOTMwMjg4LWUwZGFlNjQ5ZWZiMzIyYWRmYjA1NDgyMzVlMjIxNzc4NTU0NmUyMWIzYzgyNzk0YjVlMDkzMjZjMmUzYmQyMTg

Thanks for reading!
Tip 6: Bat, Rip, & Skim
Tags: linux, dotfiles
Published: 2020-01-08 23:20:10

Consider this the "Embrace Rust" tip post. If an app can be rewritten in Rust, then someone's probably done it already.

Here are my top 3 (Besides `exa`, as I covered that [yesterday](https://dev.to/rawkode/tip-5-replacing-ls-with-exa-3o5n))

## Bat

[Bat](https://github.com/sharkdp/bat) is a `cat` rewrite, in Rust. It has colours. Lots of colours.


![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/dumf43j50jpdah6agzk6.png)

## Ripgrep

Ripgrep, as one can imagine, is a `grep` rewrite in Rust. Now, it's not got as many colours (Well, why would it?), but it's **crazy** fast.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/2eqy6zv1awbt6jjnc9ym.png)

## Skim

Finally, one without a rusted name. Skim is a `fzf` alternative. It's good for presenting lists of content in a filterable fashion. Lets take a look at `kill -9` followed by <kbd>Tab</kbd>

{% asciinema 292521 %}

---

Thanks for tuning in,
Until next time 🤘
If I remove an image from my article, does Dev.to remove it from the servers?
Tags: meta, community, devto
Published: 2020-01-08 22:16:08

---
title: If I remove an image from my article, does Dev.to remove it from the servers?
published: true
description: 
tags: #meta #community #devto
---


When I upload an image to my post and then remove it, the image seems to still be on Dev.to AWS servers.

1. Does Dev.to remove it at some point?
2. If yes, how does it do?
3. If no, what is the cost of keeping all the uploaded images on the servers?
Node+JS Interactive 2019 talks
Tags: node, javascript, conference, nodejsinteractive
Published: 2020-01-08 21:56:11

---
title: Node+JS Interactive 2019 talks
published: true
description: Talks from the Node+JS Interactive 2019 conference are now available on Youtube
tags: node, javascript, conference, NodeJSInteractive
cover_image: https://thepracticaldev.s3.amazonaws.com/i/fg4m9ohlqu86dljaj060.jpg
---

All talks from last Node+JS Interactive 2019 conference in Montreal are now available on Youtube! You can check the full playlist here:

https://www.youtube.com/playlist?list=PLfMzBWSH11xZPfWcC0DqFqKo_reMP58mw
Find files between two dates
Tags: linux, commandline, tricks
Published: 2020-01-08 21:20:58

##Find files between two dates

I’d like to share a simple way I’ve learned to find how many files have been created between two dates, using Linux command line. The method involves find command.

##Problem

Working on a project that involved the creation of a lot of [KOS](https://www.dicomobjects.com/tags/KOS) objects (nothing difficult, just another [DICOM](https://www.dicomlibrary.com/dicom/) object), I needed a quick and easy way to find out how many files my class method created.

##Solution

I knew that find command could help, so I started digging into its manual and at the end I found the right option:
```bash	
 -newerXY reference
Succeeds if timestamp X of the file being considered is newer than timestamp Y of the file reference. The letters X and Y can be any of the following letters:

              a   The access time of the file reference
              B   The birth time of the file reference
              c   The inode status change time of reference
              m   The modification time of the file reference
              t   reference is interpreted directly as a time
```
after many trials I ended up with newermt which is newer with sub-options X=m for modification date and Y=t for literal time.

At this point my “command” was taking shape:

```bash	
find -type f -name "*.dcm" -newermt 2016-04-08 ! -newermt 2016-04-09
```

Last thing I needed to know, was the number of files that have been created in the desired date interval and this was the easiest part of the command:

```bash
wc -l
```

the command used prints the newline count.

Finally:

```bash	
find -type f -name "*.dcm" -newermt 2016-04-08 ! -newermt 2016-04-09 | wc
``` 
Enjoy!
Creating a Counter App using Android Jetpack Compose
Tags: kotlin, android
Published: 2020-01-08 20:43:03

**The JetPack Compose syntax changed so the code samples are not up to date**

# Intro

Before we create the app, I must first introduce you to Jetpack Compose. Google's new UI component Framework for Android development. Jetpack Compose uses the same UI rendering as Flutter, where it doesn't use the native Android UI elements but draw's it own UI elements on the screen. The way you create UI components is also very similar to React with Hooks.    

With any new component based library or framework, the first thing we MUST (At this point I think that it is required) do is build a counter app. In this app I will go over some basic functionality (including `+state`) and overview of Jetpack Compose. At the moment I couldn't find any documentation on how to use `+state` so I thought I would write up a tutorial for anyone looking to learn more about JetPack Compose. 

# Setup
 
As of today (1/8/20), in order to use Jetpack Compose you will need to install the Canary build of Android Studio. In order to set up your project you will have to follow the [steps provided by the Android Team](https://developer.android.com/jetpack/compose/setup) (this link is pointed to the compose setup page).

# Code

#### Counter

{% gist https://gist.github.com/joeJazdzewski/b7362027456901f682ced256d65ed731 file=Counter.kt %}

As you can see that `fun Counter` is a function just like React Hooks function components but in this case our function has the `@Composable` decorator. `val count = +state{0}` is similar to the react hooks' useState `const [count, setCount] = useState(0)` except there is no `setCount` that is being produced from `+state`. The state manipulation is simple with `count.value++` and `count.value--`. Once either button is clicked we will be changing the value of the count and the UI will update. 

#### MainActivity

{% gist https://gist.github.com/joeJazdzewski/b7362027456901f682ced256d65ed731 file=MainActivity.kt %}

The MainActivity is really simple, we set the content of MainActivity to our `App` component which  calls our `Counter` component and that is it. Short simple and straight to the point. There is more to JetPack Compose but I thought that this would be a good start for basic functionality

[For more information on JetPack Compose](https://developer.android.com/jetpack/compose)
How to be a junior developer and survive?
Tags: javascript, coding, teamwork, twitter
Published: 2020-01-08 20:07:05

It’s been a little bit more than a year since I’ve become a junior developer and I’ve made a funny list of tips I learnt during this journey. 

**1.** *Patience.* I know you are in the moment you want to learn everything and more, but you need to be organized and make choices. What should I learn first and why? 

**2.** *Ask to the seniors.* The best way to learn is meeting with those developers who are more experienced. Ask whenever you have some doubts, it’s perfectly fine to be wrong and to make mistakes, you will learn from those mistakes so don’t be ashamed for that. 

**3.** *Respect.* There would be moments when you will have to prove yourself to be a better person. In the best case you will have a great guidance from your Team and a great Project Manager, but also there would be cases where you would have to deal with some tough personalities. This is the time to find out the best version of you. Think about it in this way: what if you could have done better? Be critical of your work, even though you see that the rest is not.

**4.** *Compete only with yourself.* You will meet a lot of developers, and probably they would be more experienced than you. Don’t try to be better to catch them up, try to be better for your own experience, otherwise you will feel frustrated because people learn in different ways and times.
 
**5.** *Don’t give up.* I won’t lie. You will be frustrated more times than you can imagined but the best thing is you will always have another opportunity to do it better. 

**6.** *Be humble.* It’s great to be confident, but also it’s better if you understand that you are a human being who can make mistakes. Learn from them and accept when they happen. Make sure to let this know to your team. 

**7.** *Be a good team partner.* You will spend a lot of time with this people so it would be much better if you have a great time with them at the same time. Talk to them, connect whenever you need, offer help whenever you can.

**8.** *Communicate.* Communication is the base of everything, if you can’t communicate what you need your team won’t know what you need or how to help you. This is something that you will have to learn day by day .


**DECLAIMER:**
This is not the constitution. Everyone could have their own personal list. It's a way to share my experience in order to inspire others to do so. 
Finally, the cover image is my cat, be careful if you look at it really closely it can take your soul, ha ha. 

*Happy coding! :)*
What's new in TruClient 2020?
Tags: truclient, loadrunner, vugen, performance
Published: 2020-01-08 20:05:16

![What’s new in TruClient 2020?](https://media.giphy.com/media/W4tne0cNj8w8wGcTqT/giphy.gif)

# Introducing TruClient 2020
TruClient is a protocol in LoadRunner (or VuGen) to measure the end-to-end response time and more. If you are testing Single Page Applications (apps that are built on modern web technologies like React, Ember, Angular etc), traditional approach in measuring performance is not apt.

TruClient protocol is free under community edition where you can run up to 50 Vusers in Controller.

# What’s new in TruClient 2020?

* Browser Support - Chromium 76 and TruClient Browser 65.0.3
* Search Bar - new search bar - faster than ever
* Steps Box - new Step box - sticky
* Performance Metrics - DOMContentLoaded, DOM Interactive, and Page Load events.
* APIs and Windows 10 - new API to connect to VTS (HTTPS) and enhanced support for Windows 10

To read in detail, please visit [my blog](https://qainsights.com/whats-new-in-truclient-2020/).
Method name to explain context
Tags: discuss, ruby, rails
Published: 2020-01-08 20:04:38

We have a graphql mutation to send a user a reset password email. We return a generic success result if the user supplies an unknown email address. This is to prevent a malicious user from gaining knowledge about which emails are registered to our app:

```ruby
def resolve
  if user.nil?
    {success: true}
  else
    result = CreateResetPasswordToken.new(user).call
    {success: result.success?}
  end
end

private

def user
  @user ||= User.find_by(email: input.email)
end
```

I think this is a pretty common approach. But the actual contents of the method could be confusing if you don't understand the context. I could picture a new developer(or myself in 6 months) coming along and thinking: "That can't be right. We are returning success when the user is not found. I bet it's a typo."

So that got me thinking about how to communicate the context in the code. One possibility is to write a test case that describes that it should be true when the user is not found. That at least provides a clue that it isn't a mistake. But then I wondered what it would look like if we used a method name to communicate what is happening.

```ruby
def resolve
  if user.nil?
    success_to_conceal_which_email_addresses_exist
  else
    result = CreateResetPasswordToken.new(user).call
    {success: result.success?}
  end
end

private

def success_to_conceal_which_email_addresses_exist
  {success: true}
end
```

What do you think?
Welcome Thread - v55
Tags: welcome
Published: 2020-01-08 19:55:31

---
title: Welcome Thread - v55
published: true
description: Welcome to DEV! A thread of hellos and intros.
tags: welcome
---

![lego man hello](https://media.giphy.com/media/VeBeB9rR524RW/giphy.gif)

### Welcome to DEV!

1. Leave a comment below to introduce yourself! You can talk about what brought you here, what you're learning, or just a fun fact about yourself.

2. Reply to someone's comment, either with a question or just a hello. 👋 

**Great to have you in the community!**
Daily Challenge #156 - Dave's Gamble
Tags: challenge
Published: 2020-01-08 19:51:07

---
title: Daily Challenge #156 - Dave's Gamble
published: true
description: Write a program that can take any number of horses as its only argument and returns the total number of different combinations of competitors winning gold silver and bronze.
tags: challenge
---
My mate Dave LOVES gambling. He goes to the horse races every Saturday and bets money on which horses will finish FIRST, SECOND and THIRD place.

I'm a good friend, so I said I'd help him figure out how many different ways the gold, silver, and bronze could be handed out to the competitors so he can calculate his odds of winning.

Problem is, Dave never knows how many horses will be entering the race until he gets to the track. I guess I'll have to design a function to help me!

Write a program that can take any number of horses as its only argument and returns the total number of different combinations of competitors winning gold silver and bronze.

*For example*:

`horses(15)  ->  2730`

There are effectively 2730 different combinations of 1st, 2nd and 3rd finishers.

The function should return undefined if the object entered isn't an integer.

If the number of horses is lower than 3, return the input value.

*Other examples*:

`horses(4)  ->  24`
`horses(1)  ->  1`


***
_This [challenge](https://www.codewars.com/kata/563b8a23b554206f49000059) comes from tu6619 on CodeWars. Thank you to [CodeWars](<https://codewars.com/>), who has licensed redistribution of this challenge under the [2-Clause BSD License](<https://opensource.org/licenses/BSD-2-Clause>)!_

_Want to propose a challenge idea for a future post?  Email **yo+challenge@dev.to** with your suggestions!_