teleren/devto huggingface dataset:
Fish abbreviations–what are they and how to configure them?
Tags: fish
Published: 2022-12-19 14:51:12

---
title: Fish abbreviations–what are they and how to configure them?
published: true
date: 2022-12-16 04:27:00 UTC
tags: fish
canonical_url: https://www.layer22.com/fish-abbreviations
---

Fish [abbreviations](https://fishshell.com/docs/current/cmds/abbr.html) are a fantastic way to configure what is commonly known as aliases for your day-to-day use.

The difference between an alias and an abbreviation is that it expands to the entire command whenever the abbreviation gets triggered. Traditionally, aliases are shown as they are typed in the shell’s history.

The expansion is an excellent benefit of using abbreviations. One can always see the actual command behind the shorthand version. This is both useful for remembering the actual command and significant when sharing commands with others (such as in screenshots of the terminal), as they do not have to decode the aliases.

## Let’s configure some abbreviations

We will edit the `~/.config/fish/conf.d/abbreviations.fish` file. Any file in the `~/.config/fish/conf.d` directory will be [automatically loaded](https://fishshell.com/docs/current/#configuration) in a standard `fish` setup. A separate file for abbreviations makes it easier to find the right place to configure them.

Below is the content of my file:

```
abbr be "bundle exec"

abbr ghb "gh browse" # Open the current repository on GitHub
abbr ghc "hub compare" # Open the diff of the branch on GitHub

abbr bu "brew upgrade"

```

As you can see, the syntax is similar to the [alias](https://fishshell.com/docs/current/cmds/alias.html). We use the `abbr` command, followed by the abbreviation we’d like to use. Finally, the actual command it should expand to.

To use the configured abbreviation, we need to type it, and either press <kbd>Enter</kbd> to expand and execute, or <kbd>Space</kbd> to only expand it, allowing us to add any arguments to the command.

Here’s a demo:

[![asciicast](https://asciinema.org/a/wOt70n7TKym3ijKtFhwUUTSvd.svg)](https://asciinema.org/a/wOt70n7TKym3ijKtFhwUUTSvd)

Abbreviations add another touch of clarity to your own workflow. Switching from using aliases is trivial. To me, they are superior and a clear improvement.

## Bonus points

I’ve found [`fish-git-abbr`](https://github.com/lewisacidic/fish-git-abbr) plugin to be a fantastic collection of predefined abbreviations for `git` usage. It’s got everything you might need when working with `git` and save some keystrokes. I have also learned some new `git` arguments!
Failure - An Opportunity to Learn and Grow for Software Developers
Tags: failure, software, softwaredevelopers, opportunity
Published: 2022-12-16 04:24:39

---
title: Failure - An Opportunity to Learn and Grow for Software Developers
published: true
description: Failure is an inevitable part of the software development process, and it can be frustrating and demoralizing when it occurs. 
tags: Failure, Software, SoftwareDevelopers, Opportunity
# cover_image:
# Use a ratio of 100:42 for best results.
# published_at: 2022-12-16 03:34 +0000
---
![Failure - An Opportunity to Learn and Grow for Software Developers](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xemghzzsybucv1ub940h.jpeg)
Failure is a natural part of any career, and software development is no exception. A software developer may fail to meet a deadline, produce code that has too many bugs, or simply not deliver a project that meets the client's expectations. While these failures can be frustrating and demoralizing, they can also be opportunities for growth and learning.


## **Common Reasons for the Failure of Software Developers**

### 1. Insufficient Planning

One of the most common reasons for failure for software developers is the lack of proper planning and organization. And we know that developing software is a complex process that requires careful planning and coordination. If a developer fails to plan and organize their work properly, they are likely to run into problems down the line. This can lead to missed deadlines, low-quality code, and disappointed clients.

### 2. Lack of Technical Skills

Another reason for failure in software development is a lack of technical skills. While software developers are expected to have a certain level of technical expertise, it is important for them to learn and improve their skills continuously. If developers fail to keep up with the latest technologies and best practices, they struggle very hard to deliver high-quality software.

### 3. External Factors Beyond the Control of Software Developers

In some cases, a software developer may fail because of external factors beyond their control. For example, a sudden change in a client's requirements or a critical bug in a third-party library can throw a wrench into even the most carefully planned project. In such a scenario, it is important for the developer to communicate with their team and stakeholders to find a solution.

## Take Failure as a Lesson

No matter the reason for failure, it is important for software developers to take responsibility for their failures and learn from them. This can involve conducting a post-mortem analysis to identify the root causes of the failure, making changes to the development process to prevent similar problems in the future, and seeking feedback and guidance from mentors and colleagues.

Ultimately, failure is a normal part of the software development process, and it should not discourage a developer from continuing to pursue their career. By learning from their mistakes and continuously improving, software developers can turn failure into an opportunity for growth and success.
Create server using Node JS Native Javascript
Tags: webdev, beginners, node, javascript
Published: 2022-12-16 04:03:26

Hello, in this post I want to share with you how to create a simple server on your local host.

**Background**
In this case, I'm on learning Javascript backend, there are 2 ways to native and use the framework Ekspress JS, I want to give a tutorial for those who all read this article

**Task**
create a server locally with the Javascript language

**Getting Started**

the first step is you need to make an index.js file and call a module/library Https, the code is just like this `const http = require('http')`. this method "require" is calling the HTTP method, the "http is a built-in library in Node JS, so you can only call it on your code. 

then to create a server, the code can be like below 

```
const http = require('http')

const listener = http.createServer((req, res) => {
    console.log('req.headers.autorization', req.headers.authorization)
    if (req.url === '/user'){
        res.writeHead(200, {'Content-Type': 'application/json'})
        res.end(JSON.stringify({ name : 'John Doe'}))
    }   else {
        res.writeHead(200)
        res.end('Hello World')
    }
        
})

listener.listen(8000, 'localhost', () => {
    console.log('Server is listening on port 8000')
})
```
the method `http.createServer` have the callback parameter req and res, as we know req for a request and res for a response. if we want to make a routing in native node JS we can use `if (req.url === '/user')`. it is just an example for /user. if we run it will show `name: 'John Doe'` and for "else" or other it will show `'Hello World'`

And we can run in terminal command bash with `node index.js`. And then notice will prompt on the terminal "Server is listening on port 8000". We can see on our browser on locallost:8000. We have already succeeded to build a server with native node JS, the preview is below.

![preview localhost:8000 on browser](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y5bw7ny8pk45bfxqbctv.png)

![preview localhost:8000/user on browser](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wwf13v6e9sfcxebypzzf.png)

okay thanks for your read, see you in the next post :)

Github :https://github.com/Hendra-Kusuma
Email : hendrakusuma.vegas@gmail.com
3 Learnings from Advent of Code 2022
Tags: beginners, adventofcode
Published: 2022-12-16 03:41:15

I came to know about [Advent of Code](https://adventofcode.com/) from this [YouTube video](https://www.youtube.com/watch?v=xIj13W0T7Ws), and I have been enjoying it! My goal is just to be able to collect all 50 stars. Here are some of my learnings from it (I am not a competitive programmer).

### 1. Not giving up

As the difficulty of the problem varies, sometimes it's easy to get stuck. It is tempting to look for solutions on Reddit, but it is more satisfying solving the problem on your own. I would take a break and go do something else if I get stuck, and often times different ideas pop out as I re-approach the problem. My debugging skills definitely improved by not giving up!

![Never GIve up](https://media.giphy.com/media/OWWZ0jb4U289iYh5Il/giphy.gif)


### 2. Learning from others

At the end of the day, after solving the questions, I would look at how others have solved it. And often times, I am amazed by the different approaches! When I looked back at my naive solution, it looks comical. Day by day, I have been learning a ton.

I am looking at solution either from Reddit thread or [GitHub topics](https://github.com/topics/advent-of-code-2022).



### 3. Have fun!

I enjoyed solving problems for the Elves. Of course, the memes on [Reddit](https://www.reddit.com/r/adventofcode/) always provide a good laugh. 

![elf](https://media.giphy.com/media/FerjqPHY2OGDPJPwEk/giphy.gif)
Rest Assured Tutorial For Beginners | LIVE Project(Getting Started) | API Testing (GET & POST)
Tags: beginners, webdev, programming, tutorial
Published: 2022-12-16 03:36:46

In this video of Rest Assured for Beginners, We are going to Automate the GET and POST REQUEST in rest assured.

Source Code : https://bit.ly/356AWhT
 
{% embed https://youtu.be/PKtyz-UTMSE %}

✅API Testing - 
https://www.learnapitesting.com


What is Rest Assured?
REST Assured is a Java DSL for simplifying testing of REST based services built on top of HTTP Builder. It supports POST, GET, PUT, DELETE, OPTIONS, PATCH and HEAD requests and can be used to validate and verify the response of these requests.

Both GET and POST method is used to transfer data from client to server in HTTP protocol but Main difference between POST and GET method is that GET carries request parameter appended in URL string while POST carries request parameter in message body which makes it more secure way of transferring data from client to server.



-----------------------------------------------------
👪 Join our Community - http://bit.ly/learntesting2019

✅ Automation Tester Community - https://thetestingacademy.com

🐦Follow us on Twitter  - https://twitter.com/itstechmode

📖 Like us on Facebook - https://www.facebook.com/scrolltest

🎤 Listen to our Podcast - https://anchor.fm/thetestingacademy

------------------------------------------------------

#automationtesting #manualtesting #testautomation #thetestingacademy #scrolltest #restassured #resapi #apitesting #api

🚀 Tools and services I recommend:
Some of the courses that I recommend to become better Automation Tester 🙌🙌

✅Selenium Training and Certification -
https://scrolltest.com/go/edureka


✅Learn Jenkins for QA -
https://bit.ly/learnjenkins-p1


✅Programming Java -
https://bit.ly/learnjava2020-p1


✅Test Automation - 
https://bit.ly/learnautomation2020


✅API Testing - 
https://www.learnapitesting.com


✅Cypress Tutorial with LIVE Projects -
http://cypresstutorial.com
What is PalDomains?
Tags: discuss
Published: 2022-12-16 02:53:19

PalDomains offers its customers the chance to establish and monetize their blogs, portfolios, products, etc. in addition to resolving an ongoing problem. A distinctive alternative to purchasing domains from providers like Namecheap, Porkbun, and others is provided by PalDomains programs.

PalDomains will be a totally free service, but we will also have paid-for features like PalSubs. PalSubs is a service that enables us to generate income that may be used to pay for the maintenance of our product as well as the hiring of developers, managers, etc (i.e domain purchases, hosting costs, etc.).

Another service PalDomains will provide is PalAds, which will enable users to "Earn Coins" while viewing ADs. Trust me, this has nothing to do with cryptocurrencies! Users will be able to purchase interesting badges, site advertising, and—most importantly—more subdomains with PalCoins!

Our solution will offer an easy-to-use interface that will make it possible for parents, teachers, students, developers, artists, and more to create the first website of their dreams. You can ask our CEO, Clifford Robinson, any questions about our product via DEV (@Proochles).
LeetCode's Running Sum of 1d Array - Highly Efficient Java Solution (Beats 100% In Runtime And 97% in Memory Usage)
Tags: java, leetcode, computerscience, algorithms
Published: 2022-12-16 02:18:05

## Intuition

My first thought on how to solve this problem is to iterate through the array and add the current element to the previous element. This will give us a running sum of the elements in the array.

## Approach

The function first declares a loop that will iterate over the elements of the array starting from the second element (index 1). For each iteration, the value of the current element is updated to be the sum of the previous element and itself.

After the loop finishes, the modified array is returned.

Here's an example of how the function would work:

```txt
Input: [1, 2, 3, 4]
Output: [1, 3, 6, 10]
```

The first element of the output array is the same as the first element of the input array, since it is the sum of the elements up to itself (in this case, just itself). The second element of the output array is the sum of the first and second elements of the input array, and so on.

## Complexity

- Time complexity: O(n)
  - The time complexity of this solution is O(n), as we are iterating through the array once and performing a constant number of operations on each element.

- Space complexity: O(1)
  - The space complexity of this solution is O(1), as we are not using any additional data structures or variables to store the running sum.

## Code

```java
class Solution {
    public int[] runningSum(int[] nums) {
        for (int i = 1; i < nums.length; i++) {
            nums[i] = nums[i - 1] + nums[i];
        }
        return nums;
    }
}
```

For more details: <https://leetcode.com/problems/running-sum-of-1d-array/solutions/2916215/highly-efficient-java-solution-beats-100-in-runtime-and-94-in-memory-usage/>
How to enable dark mode on Dev.to ?
Tags: tutorial, nightmo
Published: 2022-12-16 01:48:33

Hi there, if your eyes also hurt with the light mode , continuous starring at the screen.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zggc1kjf3m1dmlb9e2ps.gif)
Or you are like me a dev who is a fan of dark mode. Then this blog is for you.

The earlier blogs on this are outdated sorry very ...
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8jvfrp6nh9ob0393sc83.gif)
 
So, I decided to craft a new updated one for you. Heres , how ! 

So go to your dev.to > profile section > Edit profile  

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4p5rp3zjjlw7m9s9fpdx.png)

Click on Customization > Dark mode and you are done .
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qow7ehzh8ee1brwasbod.gif)

Refresh after saving and you shall see the dark mode on.

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

Please leave a like, if this helped and follow for more. 
Signing off ,  
kamal 🏄‍♂️
Batch to add / remove environment variables by Vercel CLI
Tags: vercel, cli
Published: 2022-12-16 01:39:42

Not sure why [Vercel CLI](https://vercel.com/docs/cli) 28.9.0 has no way to import whole `.env` file or all environment variables in one project or environment. Write a simple bash script to achieve it:

(Tested on macOS zsh)

## Check current environment variables and backup

```zsh
# List up all current environment variables
vercel env ls

# Backup
vercel env pull .env.production.bak --environment production
vercel env pull .env.development.bak --environment development
vercel env pull .env.preview.bak --environment preview
```

## Add environment variables

```zsh
cat .env.production | sed 's/=/ /' | xargs -n 2 bash -c 'echo -n $1 | vercel env add $0 production'
cat .env.staging | sed 's/=/ /' | xargs -n 2 bash -c 'echo -n $1 | vercel env add $0 development'
cat .env.staging | sed 's/=/ /' | xargs -n 2 bash -c 'echo -n $1 | vercel env add $0 preview'
```

## Remove all Vercel environment variables

```zsh
vercel env ls | sed 's/=/ /' | awk 'NR>2 {print $1, $3}' | xargs -n 2 bash -c 'vercel env rm $0 ${1,,} -y'
```
Why is blockchain even needed ?
Tags: blockchain, webdev
Published: 2022-12-16 01:34:21

**Blockchain** the hot topic is nothing much than a chain a blocks essentially the blocks are computers(nodes) who all agree upon a common state called the consensus. 

Main idea behind blockchain is the idea of decentralisation. No one controls the data but everyone agrees to the state. 

It has many use cases like the cryptocurrency , NFTs , Token.

All the trust issues are solved with the coming of blockchain. 
Why ?

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ad6ycndfd0cz5izlgzbu.gif)


Because the contracts written in blockchains are immutable i.e. they cannot be changed . Hence, zero manipulations.😃

They give users their data unlike traditional web2 apps like Fb or twitter where your data relies on some external servers.
Blockchain codes are censorship resistant and transparently verifiable. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n3sd19z0of7eznrsphlw.gif)


The heart of all blockchains -> smart contract is code that will always run the way it is programmed in the future.

Blockchain technology has the potential to revolutionize many different industries and has already demonstrated its value in a number of use cases beyond NFTs. Some examples include:

* Supply chain management: Blockchain can be used to track the movement of goods through the supply chain, helping to improve transparency and efficiency.

* Financial services: Blockchain can be used to securely and transparently record financial transactions, reducing the risk of fraud and errors.

* Identity verification: Blockchain can be used to securely store and verify personal identification information, helping to reduce identity fraud.

* Healthcare: Blockchain can be used to securely store and share medical records, improving the accuracy and efficiency of healthcare delivery.

It's important to recognize that blockchain is a versatile and powerful technology with the potential to transform many different industries. While NFTs have gained a lot of attention recently, they are just one example of the many ways in which blockchain can be used.

With this, I end this blog. See you in the next one 👋.
singleton in javascript
Published: 2022-12-16 01:29:37

# singleton in javascript

```javascript
class Singleton
{
    constructor()
	{
		if (!Singleton.instance)
		{
			Singleton.instance = this;
		}
		return Singleton.instance;
	}

	getInstance()
	{
		return this.instance;
	}
}
```

# test
```javascript
const testA = new Singleton();
const testB = new Singleton();

console.log(testA === testB); // true
```

# singleton example (db connection)
```javascript
const URL = "db_url";
const createConnection = url => ({"url" : url});
class DB
{
	constructor(url)
	{
		if (!DB.instance)
		{
			DB.instance = createConnection(url);
		}
		return DB.instance;
	}

	connect()
	{
		return this.instance;
	}
}
```

# profits of singleton
save cost of creating instance.

# disadvantage of singleton
high coupling 
(can be resolved DI(dependency injection))
1
Published: 2022-12-16 01:23:10

---
title: 1
published: true
description: You are currently using the basic markdown editor that uses Jekyll front matter. You can also use the rich+markdown editor you can find in UX settings.
tags: 
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2022-12-16 01:22 +0000
---

You are currently using the basic markdown editor that uses Jekyll front matter. You can also use the rich+markdown editor you can find in UX settings.
react useMemo() hook - webdev simplified
Published: 2022-12-16 01:16:52

## Benefits of useMemo() :-

- when you want to make slow Function we wrap it in this useMemo() hook so that doesn't recompute every single time you render your component and it only computes when you actually need the value from that function since the inputs actually changed 
- referencial equality - whenever you want to make sure the reference of an object or an array is exactly same as it was the last time you rendered if none of the internal workings changed you're gonna want to use useMemo() here to make sure that you only update the reference of that object whenever the actual contents of the object changed instead of updating every single time you render. 


**App.js Code :-**

``` react
import { useState, useEffect, useMemo } from 'react';


export default function App() {
  const [number, setNumber] = useState(0);
  const [dark, setDark] = useState(true);

  function slowFunction(num) {
    console.log("in function");
    for (let i = 0; i <= 1000000000; i++) { };
    return num * 2;
  };

  // const doubleNumber = slowFunction(number);
  const doubleNumber = useMemo(() => {
    return slowFunction(number);
  }, [number]);

  const themeStyles = useMemo(() => {
    return {
      backgroundColor: dark ? 'black' : 'white',
      color: dark ? 'white' : 'black'
    }
  }, [dark]);

  useEffect(() => {
    console.log("theme changed");
  }, [themeStyles]);

  return (
    <>
      <input type="number" value={number} onChange={e => setNumber(parseInt(e.target.value))} />

      <button onClick={() => setDark(prevDark => !prevDark)}> Change Theme </button>

      <div style={themeStyles}> {doubleNumber} </div>
    </>
  )
}
```


Thank You.
You can follow us on:
[Youtube ](https://www.youtube.com/c/ULTIMATEPROGRAMMING)
[Instagram](https://www.instagram.com/full_stack_web_developer1/)