teleren/devto huggingface dataset:
How to Easily Navigate Directories in the Terminal
Tags: linux
Published: 2022-06-07 00:16:56

You know about the `PATH` environment variable. Did you know about `CDPATH`? If you've been typing long `cd` commands like me, this post is for you. 

I came across this gem this morning, while reading Daniel Barrett's new book [Efficient Linux at the Command Line](https://learning.oreilly.com/library/view/efficient-linux-at/9781098113391/). It instructs the `cd` command to search for the directory you specify in locations other than your current directory. 

A `cd` search path works like your command search path `$PATH`. However, instead of finding commands, it finds the subdirectories. You can configure it with the shell variable `CDPATH`, and it has the same format as the `PATH` variable: a list of directories separated by colons.

<!--more-->

Set this variable in your `~/.zshconfig` or `~/.bashrc` file to include the directories you visit most frequently. 

```bash
export CDPATH=$HOME:$HOME/software:$HOME/software/ruby:$HOME/software/rails:$HOME/software/youtube
```

Now, whenever you want to `cd` into a directory, the shell will look through all the above places in addition to the current directory. 

What's more, the search is lightning fast. It looks only in parent directories that you specify and nothing else. 

For example, let's say you have a `$HOME/software/blog` directory and you've configured the `CDPATH` to include the `$HOME/software` directory. 

Now, if you type `cd blog` from anywhere in the filesystem, the `cd` command will take you to the `$HOME/software/blog` directory, unless it finds another `blog` directory in another pre-configured path. So the order of `CDPATH` matters. If two directories in `$CDPATH` have a subdirectory named `blog`, the earlier parent wins.

In the above example, `cd` will check the existence of the following directories in order, until it finds one or it fails.

1.  in the current directory
2. `$HOME/software/blog`
3. `$HOME/software/ruby/blog`
4. `$HOME/software/rails/blog`
5. `$HOME/software/youtube/blog`

To summarize,

> Set `CDPATH` with your most important or frequently used parent directories, and you can directly `cd` into them or their subdirectories no matter where you are in the file system. You don't have to type the full path anymore. 

Trust me, this is pretty freaking cool. It has changed the way I use the shell.
Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts
Tags: leetcode, dsa, theabbie
Published: 2022-06-07 00:00:44

You are given a rectangular cake of size `h x w` and two arrays of integers `horizontalCuts` and `verticalCuts` where:

*   `horizontalCuts[i]` is the distance from the top of the rectangular cake to the `ith` horizontal cut and similarly, and
*   `verticalCuts[j]` is the distance from the left of the rectangular cake to the `jth` vertical cut.

Return _the maximum area of a piece of cake after you cut at each horizontal and vertical position provided in the arrays_ `horizontalCuts` _and_ `verticalCuts`. Since the answer can be a large number, return this **modulo** `109 + 7`.

**Example 1:**

![](https://assets.leetcode.com/uploads/2020/05/14/leetcode_max_area_2.png)

**Input:** h = 5, w = 4, horizontalCuts = \[1,2,4\], verticalCuts = \[1,3\]
**Output:** 4 
**Explanation:** The figure above represents the given rectangular cake. Red lines are the horizontal and vertical cuts. After you cut the cake, the green piece of cake has the maximum area.

**Example 2:**

![](https://assets.leetcode.com/uploads/2020/05/14/leetcode_max_area_3.png)

**Input:** h = 5, w = 4, horizontalCuts = \[3,1\], verticalCuts = \[1\]
**Output:** 6
**Explanation:** The figure above represents the given rectangular cake. Red lines are the horizontal and vertical cuts. After you cut the cake, the green and yellow pieces of cake have the maximum area.

**Example 3:**

**Input:** h = 5, w = 4, horizontalCuts = \[3\], verticalCuts = \[3\]
**Output:** 9

**Constraints:**

*   `2 <= h, w <= 109`
*   `1 <= horizontalCuts.length <= min(h - 1, 105)`
*   `1 <= verticalCuts.length <= min(w - 1, 105)`
*   `1 <= horizontalCuts[i] < h`
*   `1 <= verticalCuts[i] < w`
*   All the elements in `horizontalCuts` are distinct.
*   All the elements in `verticalCuts` are distinct.

**SOLUTION:**

    class Solution:
        def maxArea(self, h: int, w: int, horizontalCuts: List[int], verticalCuts: List[int]) -> int:
            horizontalCuts = [0] + sorted(horizontalCuts) + [h]
            verticalCuts = [0] + sorted(verticalCuts) + [w]
            m = len(horizontalCuts)
            n = len(verticalCuts)
            a = max(horizontalCuts[i+1] - horizontalCuts[i] for i in range(m-1))
            b = max(verticalCuts[i+1] - verticalCuts[i] for i in range(n-1))
            return (a * b) % (10 ** 9 + 7)
New Rant: On Microservice Architecture
Tags: microservices, opinion
Published: 2022-07-17 20:34:36

---
title: New Rant: On Microservice Architecture
published: true
date: 2022-06-07 00:00:00 UTC
tags: 
  - microservices
  - opinion
canonical_url: https://wildermuth.com/2022/06/07/rant-8-on-microservice-architecture/
cover_image: "https://wilderminds.blob.core.windows.net/img/2022/06/07/cover.jpg"
---

I just got back from four conferences in Europe…and boy are my arms tired. One of the common  
themes of a lot of talks seemed to be the magic of microservices. I decided to give my 2 cents on the subject in this new rant:

> [Watch](https://www.youtube.com/watch?Z8oJIfE30PQ)

> [View All Rants](https://shawnl.ink/rants)
> [Subscribe to my YouTube Channel](https://shawnl.ink/yt)

[![Creative Commons License](http://i.creativecommons.org/l/by-nc-nd/3.0/88x31.png)](http://creativecommons.org/licenses/by-nc-nd/3.0/)

 This work by [Shawn Wildermuth](http://wildermuth.com) is licensed under a [Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License](http://creativecommons.org/licenses/by-nc-nd/3.0/).  
 Based on a work at [wildermuth.com](http://wildermuth.com).

* * *

If you liked this article, see Shawn's courses on [Pluralsight](http://shawnw.me/pscourses).
Day 567 : Keep on
Tags: hiphop, code, coding, lifelongdev
Published: 2022-06-06 23:43:21

_liner notes_:
- Saturday : This week's show was broadcasted live from a hotel room in Atlanta, Ga. I was able to bring in my co-host so I tested my travel setup to the max. Everything worked so I was happy. Had a good show. The recording of this week's show is at https://kNOwBETTERHIPHOP.com

![Radio show episode image of a painting of Beet Unique's dog Herc as Royalty in a suit with the words June 4th 2022 Vibez](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1on5z95lnwodbh3vivrn.jpg)

- Sunday : Was travel day from Atlanta to Orlando. Pretty long day! Made it though.

- Professional : Today I focused on wrapping up filling out the event and expense reports from my recent trips. Also spoke with my manager and planned out some tasks to get done this sprint.

- Personal : Whew, feels good to be back at home, though I still want to hit the road. haha.


![Looking up at colorfully striped mountains of Old Paria, UT, USA under a purple sky at sunset](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g3nnx3m798tj3p84lo7p.jpg)

Going to rest up some more. I was on the road for awhile. haha And I loved it! Looking forward to getting back to traveling after this break. Till then, I'll keep on working on side projects. I'd like to get something working and ready for users while I'm at home maybe even a new version of OUR show's site. Oh yeah, check out my trip to Athens, Greece, Atlanta, Georgia and more at https://dwane.in 

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube _Kkhs4XAa14 %}
Factorial Trailing Zeroes
Tags: leetcode, dsa, theabbie
Published: 2022-06-06 23:30:34

Given an integer `n`, return _the number of trailing zeroes in_ `n!`.

Note that `n! = n * (n - 1) * (n - 2) * ... * 3 * 2 * 1`.

**Example 1:**

**Input:** n = 3
**Output:** 0
**Explanation:** 3! = 6, no trailing zero.

**Example 2:**

**Input:** n = 5
**Output:** 1
**Explanation:** 5! = 120, one trailing zero.

**Example 3:**

**Input:** n = 0
**Output:** 0

**Constraints:**

*   `0 <= n <= 104`

**Follow up:** Could you write a solution that works in logarithmic time complexity?

**SOLUTION:**

    class Solution:
        def trailingZeroes(self, n: int) -> int:
            ctr = [0, 0]
            for i in range(1, n + 1):
                curr = i
                while curr % 2 == 0:
                    ctr[0] += 1
                    curr = curr // 2
                while curr % 5 == 0:
                    ctr[1] += 1
                    curr = curr // 5
            return min(ctr)
How to create additional SSH Keys
Tags: howto, webdev, bitbucket, ssh
Published: 2022-06-06 23:12:40

For your projects, if you are working with different bitbucket accounts you might face a scenario where Bitbucket complains that you have already used your SSH key before, in that case you need to create additional SSH key on your system. For example, if you have two Bitbucket accounts, you need to generate a new SSH key, meaning you'll have two keys in all.

Following are the steps:

#### Generate your new SSH key

Use the following command:

```
ssh-keygen -f ~/.ssh/<username>
```

You can replace the `<username>` with the username of the Bitbucket account for which you're creating the SSH key.

#### Add SSH key to your account

Use the following command:

```
ssh-add ~/.ssh/<username>
```

This will add your new SSH key to your account. Make sure you're adding it to the right account.

Now, you can use this new public SSH key to your Bitbucket account.

**References:**
* https://confluence.atlassian.com/bitbucket/configure-multiple-ssh-identities-for-gitbash-mac-osx-linux-271943168.html
* https://community.atlassian.com/t5/Sourcetree-questions/Permission-denied-publickey/qaq-p/594966
Basic Calculator II
Tags: leetcode, dsa, theabbie
Published: 2022-06-06 23:00:48

Given a string `s` which represents an expression, _evaluate this expression and return its value_. 

The integer division should truncate toward zero.

You may assume that the given expression is always valid. All intermediate results will be in the range of `[-231, 231 - 1]`.

**Note:** You are not allowed to use any built-in function which evaluates strings as mathematical expressions, such as `eval()`.

**Example 1:**

**Input:** s = "3+2\*2"
**Output:** 7

**Example 2:**

**Input:** s = " 3/2 "
**Output:** 1

**Example 3:**

**Input:** s = " 3+5 / 2 "
**Output:** 5

**Constraints:**

*   `1 <= s.length <= 3 * 105`
*   `s` consists of integers and operators `('+', '-', '*', '/')` separated by some number of spaces.
*   `s` represents **a valid expression**.
*   All the integers in the expression are non-negative integers in the range `[0, 231 - 1]`.
*   The answer is **guaranteed** to fit in a **32-bit integer**.

**SOLUTION:**

    class Solution:
        def eval(self, a, op, b):
            if op == '+':
                return a + b
            elif op == '-':
                return a - b
            elif op == '/':
                return int(a / b)
            elif op == '*':
                return a * b
        
        def calculate(self, s: str) -> int:
            s += " "
            precedence = {
                '*': 1,
                '/': 1,
                '+': 0,
                '-': 0
            }
            numstack = []
            opstack = []
            chunk = ""
            for c in s:
                if c == " " or c in precedence:
                    if len(chunk) > 0:
                        numstack.append(int(chunk))
                        chunk = ""
                    if c in precedence:
                        while len(opstack) > 0 and precedence[opstack[-1]] >= precedence[c]:
                            currop = opstack.pop()
                            b = numstack.pop()
                            a = numstack.pop()
                            res = self.eval(a, currop, b)
                            numstack.append(res)
                        opstack.append(c)
                else:
                    chunk += c
            while len(opstack) > 0:
                currop = opstack.pop()
                b = numstack.pop()
                a = numstack.pop()
                res = self.eval(a, currop, b)
                numstack.append(res)
            return numstack[0]
Day 58: Hello Prisma!
Published: 2022-06-06 22:58:33

Hi!
Today was a busy one as I continued with the GraphQl practice project from howtographql.com and later today I got introduced to prisma which is an ORM that integrate well with GraphQl and I found it not so hard to understand. I was just fighting with partial updated and there were giving me lemons so I had to sleep and will get back to it tomorrow. But I'm like 80% into the tutorial and I think I may be done with it by tomorrow and get started to the other project.
Notice that we are only two days to hit 60 days count whew! what a an amazing journey this had been already. but the target is day 500 and beyond hahah! see you tomorrow

signing off...
Day 59: Open source?
Published: 2022-06-06 22:57:38

Hi!
The idea about starting contributing to open source project had been bugging me for the past few days. with the benefits of working on great technologies working and learning from smart experienced people and giving back to the community and more, I think It will help me in the long run. I'm preparing for doing it as well as finding some of the projects to contribute too I think I will start after I finish the Graphql project I'm working on.
Speaking about projects Today I got started with the project after days going through the tutorial on howtographql.com and I was able to create the project structure and done some basic configurations so tomorrow I will focus more on models , queries and mutations. I will also need to look into Authentications as I have to work on a user management system so It may be a busy day, we will see how it goes

Signing off...
Some must know python modules for competitive programming
Tags: python
Published: 2022-06-06 22:50:49

Python modules — competitive programming
Taking input:

Generally you have an input in CodeChef like this:

1 2 3 4 5 6 7

To get them as a list of numbers simply

_list = map(int, raw_input().split())

Always use the raw_input() function irrespective of the type of input and then convert it using the map function. map functions are one of the most beautiful in python. Worth knowing.
swapping :

a, b = b, a
Slicing operations:

    X[:N] — all elements below index N.
    X[N:] — all elements above index N.
    X[a:b] — all elements between a, b.
    And remember python lists are circular
    X[-k] gives k’th element from the last. Quite useful to use in slicing also
    X[-k:] — gives last k elements.
    X[:-k] — gives first n-k elements where n is the length of the list.
    There are many more: Neat Features in Python: Slicing and Sliding (Stepping) and Slicing, Dicing and Splicing

While iterating always use xrange() and never range().
This is a common mistake most beginners do. range() gives a list which is a kind of overkill. xrange() is a generator, produces elements one by one and only once. Though if you are using Python3 then it is safe to use range.
sort() function:
Collections module:

Very often you need to remove duplicates. While in languages like java you have to use HashMap and all that shit, in python it’s simply:

_list = list(set(_list)).

Difference between extend() and append() in lists.
merge a=[1, 2, 3] and b=[4, 5, 6] should be
a.extend(b)
which gives

[1, 2, 3, 4, 5, 6]

a.append(b)
gives

[1, 2, 3, [4, 5, 6]]
String concatenations:

strings = ['I', 'am', 'the', 'laziest', 'person', 'in', 'the', 'world' ]
To concatenate the above strings we would be tempted to do:

It gives the right answer but it’s the worst way to do it and has a huge time overhead. The correct way is to use join() function.

Stop using reduce functions in python if you are. They are not well supported and will be deprecated soon. The fate of reduce() in Python 3000 from the inventor of python himself. Start using lambda extensively. See this post Python Lambda — why? — Stack Overflow.

And list goes on and on.
check out this book Writing Idiomatic Python Book
I am sure you can get a pdf somewhere.

Finally, practice !!. HackerRank is best for beginners and especially if you are a python lover, you’ll find it really comfortable.

The above snippet is an answer I wrote on Quora and received a bit of appreciation. I hope it helps here too!
All Ancestors of a Node in a Directed Acyclic Graph
Tags: leetcode, dsa, theabbie
Published: 2022-06-06 22:30:38

You are given a positive integer `n` representing the number of nodes of a **Directed Acyclic Graph** (DAG). The nodes are numbered from `0` to `n - 1` (**inclusive**).

You are also given a 2D integer array `edges`, where `edges[i] = [fromi, toi]` denotes that there is a **unidirectional** edge from `fromi` to `toi` in the graph.

Return _a list_ `answer`_, where_ `answer[i]` _is the **list of ancestors** of the_ `ith` _node, sorted in **ascending order**_.

A node `u` is an **ancestor** of another node `v` if `u` can reach `v` via a set of edges.

**Example 1:**

![](https://assets.leetcode.com/uploads/2019/12/12/e1.png)

**Input:** n = 8, edgeList = \[\[0,3\],\[0,4\],\[1,3\],\[2,4\],\[2,7\],\[3,5\],\[3,6\],\[3,7\],\[4,6\]\]
**Output:** \[\[\],\[\],\[\],\[0,1\],\[0,2\],\[0,1,3\],\[0,1,2,3,4\],\[0,1,2,3\]\]
**Explanation:**
The above diagram represents the input graph.
- Nodes 0, 1, and 2 do not have any ancestors.
- Node 3 has two ancestors 0 and 1.
- Node 4 has two ancestors 0 and 2.
- Node 5 has three ancestors 0, 1, and 3.
- Node 6 has five ancestors 0, 1, 2, 3, and 4.
- Node 7 has four ancestors 0, 1, 2, and 3.

**Example 2:**

![](https://assets.leetcode.com/uploads/2019/12/12/e2.png)

**Input:** n = 5, edgeList = \[\[0,1\],\[0,2\],\[0,3\],\[0,4\],\[1,2\],\[1,3\],\[1,4\],\[2,3\],\[2,4\],\[3,4\]\]
**Output:** \[\[\],\[0\],\[0,1\],\[0,1,2\],\[0,1,2,3\]\]
**Explanation:**
The above diagram represents the input graph.
- Node 0 does not have any ancestor.
- Node 1 has one ancestor 0.
- Node 2 has two ancestors 0 and 1.
- Node 3 has three ancestors 0, 1, and 2.
- Node 4 has four ancestors 0, 1, 2, and 3.

**Constraints:**

*   `1 <= n <= 1000`
*   `0 <= edges.length <= min(2000, n * (n - 1) / 2)`
*   `edges[i].length == 2`
*   `0 <= fromi, toi <= n - 1`
*   `fromi != toi`
*   There are no duplicate edges.
*   The graph is **directed** and **acyclic**.

**SOLUTION:**

    class Solution:
        def getAncestors(self, n: int, edges: List[List[int]]) -> List[List[int]]:
            graph = {}
            for a, b in edges:
                graph[b] = graph.get(b, []) + [a]
            op = [[] for i in range(n)]
            for a in graph:
                visited = set()
                paths = [a]
                while len(paths) > 0:
                    curr = paths.pop()
                    for b in graph.get(curr, []):
                        if b not in visited:
                            visited.add(b)
                            paths.append(b)
                op[a] = sorted(visited)
            return op
Hero Images and Stylizing Your Portfolio Website
Tags: webdev, design, devjournal, css
Published: 2022-06-06 22:23:09

When it comes to Front-End Web Development, how the code functions, and the overall user experience are the top priorities. However, there's nothing wrong with wanting to add unique elements purely for aesthetic, or stylistic value. This can be especially useful if you are looking to spice up your portfolio. 

As a graphic designer turned (aspiring!) web developer, I have a few resources that are free to use that could help your portfolio stand out to potential employers and clients. 

**1. Pexels.com**
This free to use photo library has amazing visual content provided by freelance photographers through their social media accounts. All you have to do for this site is sign up with a viable email address and begin downloading your desired content! 

[Pexels](https://www.pexels.com)

**2. Google Fonts**
Google fonts is a free to use collection of fonts, and even suggests possible font pairings the you have a font selected. Its easy to use and allows for downloads of all the relevant information you need to include in your next dev project. 

[Google Fonts](https://fonts.google.com)

**3. Envato Elements**
This site offers thousands of resources for devs and designers including fonts, mockups, color themes, and design inspiration. The one downside to this site is that you only receive a one-week trial before it requires a paid subscription. However, I always take advantage of free trials when I can!

[Envato Elements](https://elements.envato.com)

**4. Figma**
Figma is so much more than just a prototyping tool. I have utilized Figma as a guide when beginning a new project to help me better understand the coding requirements and formatting of the site's pages. When a project is completed I like to compare the prototype to the finished product and then create a mockup utilizing resources from the Figma community. The Figma community has created so many useful resources for devs and designers alike, including a new responsive prototyping tool, and mobile phone and laptop mockups to showcase your finished product in a professional manner. 

[Figma Device Mockups](https://www.figma.com/community/plugin/817043359134136295/Mockup)

I have used all of these resources to create product mockups and short animations utilizing my prototype designs from Adobe XD, Figma, and After Effects. For the web developer looking to explore their creativity and liven their projects, these resources are a must. I hope this information is helpful, feel free to add any tips and other free resources below!

_Artwork by Jenna Moffitt_
Assigning and Declaring Values and Variables
Tags: javascript
Published: 2022-06-06 22:21:00

As a current student learning how to code via JavaScript with little to no experience in the coding world even the simplest things can be thought of to be complicated. I found so far that I sometimes like to make things harder than it seems to be. For example, using `let` vs. `const.` 

Some background information before we continue. `Let` and `Const` was introduced in 2015 when the ECMAScript 6 came out with the updates. ECMAScript or ES was created by developers to be a centralized organization to allow changes or additions in languages like JavaScript. The idea behind this organization is to add updates in an organized manner. Allowing one group to control what is updated to be used with the new language keeps the languages organized and efficient.

Before the introduction of `let` and `const`, there was `var`. The keyword `var` is one that is used in older browsers as it was part of the ECMAScript1 update. Since the ES6 update, `let` and `const` are the preferred uses when declaring a variable. And to go further on those lines, my instructor have strongly advised me to declare variables primarily using the keyword `const`. By declaring variables using `const`, it prevents you from accidentally re-declaring it later on in your code. And when you are working on a big project, will save you many headaches. 

I did the pre-work that was assigned to me before starting my current program. I felt like I had this down, but when it came down to doing my first assignment with it in the actual program, I found it more difficult than it really needed to be. After researching and reading up on `let` vs. `const,` I finally realized that a value assigned to `let` is something that can be modified and that a value assigned to `const` is something you cannot.

Someone had mentioned to me to think of `let` as "reading and writing." It is something that you can follow, but also make changes to as necessary. Now think of `const` as "reading." It is something that cannot be erased nor changed once a value has been assigned to it. 

Somehow this analogy is now stuck in my brain every time I come to a point where I need to use `let` or `const.` I will silently question myself whether or not I need "read and write" this value or just "read" it.