teleren/devto huggingface dataset:
What was your win this week?
Tags: discuss, weeklyretro
Published: 2020-10-02 16:12:56

---
title: What was your win this week?
published: true
description: Got to all your meetings on time? Started a new project? Fixed a tricky bug?
tags: discuss, weeklyretro
cover_image: https://cl.ly/188e843c2985/download/Image%202019-02-15%20at%202.36.37%20PM.png
---

👋👋👋👋

Looking back on your week — what was something you're proud of?

All wins count — big or small 🎉

Examples of 'wins' include:

- Getting a promotion!
- Starting a new project
- Fixing a tricky bug
- Cleaning your house...or whatever else that may spark joy 😄


**Happy Friday!**

![Friday "Deal With It" Dog](https://media.giphy.com/media/kGdBpTRRUNOWY24qSR/giphy.gif)
Fish-style abbreviations in Zsh
Tags: zsh, abbreviations, fish
Published: 2020-10-02 16:10:01

A few years ago, I tried using The [Friendly Interactive SHell](https://fishshell.com/) as my default shell.

It has a lot of nice things, like syntax highlighting on the command line, reverse-history-search by pressing the up/down arrows, and a few more things, but it kept rubbing me the wrong way that it is not POSIX compatible (like [bash](https://www.gnu.org/software/bash/) or [zsh](https://www.zsh.org/)), so I ended up going back to zsh.

I did, however, bring a few features with me because they are awesome, and abbreviations is one of those features. They are sort of like aliases but better, at least in my opinion.

## Abbreviations vs aliases

In all shells there is something called aliases.
Aliases work like this, you define some alias, like `alias gst="git status"`. After this, if I type `gst` into my terminal and hit enter, the terminal will run the `git status` command and display the output as expected.

In fish, I can also define an abbreviation like this:

```
abbr -a -g gst git status
```

It works mostly the same way as an alias but with one very important exception: if I type `gst` in my terminal and hit space, the terminal _will expand the abbreviation_. If I hit enter instead of space, it will expand the abbreviation and run the command. 

This means that it's easier to see what commands have been run by looking at the history and seeing a bunch of lines with `git status` instead of just `gst`, and it also means that I can copy commands that I ran directly from my terminal, send them to a collegue, and they can just paste and run them directly if they want to. They don't need to know anything about what aliases I happen to have in my shell config.

## How to get this in Zsh?

I simply add these functions in my `~/.zshrc` and then I can start listing abbreviations:

```
# declare a list of expandable aliases to fill up later
typeset -a ealiases
ealiases=()

# write a function for adding an alias to the list mentioned above
function abbrev-alias() {
    alias $1
    ealiases+=(${1%%\=*})
}

# expand any aliases in the current line buffer
function expand-ealias() {
    if [[ $LBUFFER =~ "\<(${(j:|:)ealiases})\$" ]]; then
        zle _expand_alias
        zle expand-word
    fi
    zle magic-space
}
zle -N expand-ealias

# Bind the space key to the expand-alias function above, so that space will expand any expandable aliases
bindkey ' '        expand-ealias
bindkey '^ '       magic-space     # control-space to bypass completion
bindkey -M isearch " "      magic-space     # normal space during searches

# A function for expanding any aliases before accepting the line as is and executing the entered command
expand-alias-and-accept-line() {
    expand-ealias
    zle .backward-delete-char
    zle .accept-line
}
zle -N accept-line expand-alias-and-accept-line
```

Then I can start adding abbreviations like so:

```
abbrev-alias g="git"
abbrev-alias gst="git status"
abbrev-alias gcb="git checkout --branch"
abbrev-alias ll="ls -l"
```
How to review your changes with git piece by piece before committing
Tags: git
Published: 2020-10-02 16:03:56

---
title: How to review your changes with git piece by piece before committing
published: true
date: 2020-10-02 16:02:12 UTC
tags: git
canonical_url: https://simonplend.com/how-to-review-your-changes-with-git-piece-by-piece/
---

Have you ever run `git diff` in your terminal to see the code changes you plan to `git add` and commit, but found that seeing all of them in one big diff is overwhelming?

Try out `git add -p` (the ‘patch’ option) – it will display your code changes in small chunks, and for each one it will ask you whether you want to add it to be committed (git calls this "staging"). Give it a try when you next have some changes ready to commit!

![Screenshot of a terminal showing the git add patch option in action.](https://simonplend.com/wp-content/uploads/2020/10/git-add-patch.png)

_Bonus tip: After running `git add -p` you can type `?` and hit enter to see the help for this option._
Next Education Session (live webinar) starts at 10 am PT
Tags: podcast, coding, storytelling, webina
Published: 2020-10-02 16:01:46

After graduating from Berkeley, Jennifer Pham worked for her mother at her printing shop. After Jennifer's mom lost $10k in deposits to develop a website, she turned to her daughter out of desperation. Despite a language barrier with her mother, minimal coding experience, and serious imposter syndrome, Jennifer launched an e-commerce site that generated $10K per month just two years later, inspiring her to pursue a career in software development.

To Register: https://lu.ma/jennifer-pham-1002
Ask Octopus - Can I change the Worker Pool by environment?
Tags: octopus, tutorial, devops, api
Published: 2020-10-02 16:01:21

---
title: Ask Octopus - Can I change the Worker Pool by environment?
published: true
description: You have a script step that needs to run on different worker pools depending on the environment. What do you do? Find out in this Ask Octopus!
tags: octopus,tutorial,devops,api
series: Ask Octopus
---

You have a script step that needs to run on different worker pools depending on the environment. What do you do? Find out in this Ask Octopus!

{% youtube pO-Rlzn4I0o %}

Do you have a question about how to use Octopus? Email advice@octopus.com and someone from our team will get you an answer. You might even see it in a future episode.

Join our community slack at https://octopus.com/slack
A small act can make a huge impact on someone's life
Published: 2020-10-02 16:00:43

When I woke up this morning, I couldn't image how amazing today would be. 

An old friend contacted and asked me to helped him solve a problem. He asked me to extract a list of strings that match a pattern out of the given string. It was kind of easy problem to me. I just used a regex pattern and Javascript `match()` function to do it.

After I sent him the solution, he thanked me. I was very happy. I didn't know a simple thing to me may help someone. I am still happy know.

I also asked him whether I could the code for my tutorial. He was very generous to say I could.

I realized that something that is simple and easy to us could be useful to someone. We can be helpful to our family, friends, neighbors or strangers. We just need to be open to share what we know.
I built an app 🏋 to send emails years in the future 🎉 or conditionally 💀 
Tags: showdev, python, webdev
Published: 2020-10-02 16:00:08


![https://PipPip.email](https://dev-to-uploads.s3.amazonaws.com/i/xxqt48wwj6qac3fhuque.png)

Hello Dev.to community!

After a few months getting to grips with Django, I've made [pippip.email](https://pippip.email) - a web app that lets you create emails and set a send date years in the future.
#🔥 📨 💌 😊

## What can it do?
You can create messages and set a send date. When the date occurs, the email is sent and you get a confirmation email.

## Is that all it can do?
Well kinda, at the moment. Next feature is the "**dead man's switch**" - which doesn't require you to be dead, or male. 👀

Write a message and set the switch, then every 6 months we'll send you a check-in email with a link asking you to confirm you don't want the emails sent. 

If you don't click the link, (or the links in the follow up email), we'll understand that you want your message to be sent! 

#🙌

Perfect for when you're concerned you might "disappear" and would like to send some final goodbye's, or let someone know something important.

## How is this going to make my life better?
I can think of a few scenarios:
- At a weeding, the happy couple could invite their guest to write them messages that they'll receive on their wedding anniversaries.
- Write your mum a special email for her birthday, when you feel like writing it and not when you _need_ to send it urgently
- Write a message to your partner that they'll receive on your 5th anniversary. Do the same next year too and then they'll have a wonderful present.
- At graduation, a group of friends get together and write letters to each other guessing what their lives will be like in 3 years time.
- Write yourself an email that you'll receive next year. Give yourself some good advice and encouragement. 

#💪 🎉

Please check it out and let me know what you think! 
####[pippip.email](https://pippip.email)
How do you present a PR?
Tags: pullrequest, pull, request, merge
Published: 2020-10-02 15:57:52

So your changes works as expected, it seems that the user story it's really close to the end. Tests are passing, UI looks stunning. It's time to publish a PR for these changes...

Describing a PR in terms of code-changes and user flow can be tricky. What I found in my experience is that,
- a good description works better that a short list of changes.
- commenting key-decisions before someone will raise a question works better that arranging meetings to discuss.
- presenting a GIF of the entire user flow shows that it's working (at least in your setup!) and describe the expected behavior.

Of course this is not needed for tiny PRs.
And you, what's your approach about that?

<small><span>Photo by <a href="https://unsplash.com/@charlesdeluvio?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Charles Deluvio</a> on <a href="https://unsplash.com/s/photos/meeting?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></span></small>
VSCODE SNIPPETS
Tags: cpp, vscode, c
Published: 2020-10-02 15:57:16

Hi guys, it's been a while. I been out from dev.to, due to my studies and other stuff. While coding in C++ I make some snippets for C++ for vscode.
I have added some of the common snippets with variable and other will be added day by day.
Have a look 
https://github.com/pvcodes/vscode-cpp-snippets
Hacktoberfest Completion Thread
Tags: hacktoberfest, discuss
Published: 2020-10-02 15:46:24

---
title: Hacktoberfest Completion Thread
published: true
description: A thread to celebrate your accomplishment for having submitted 4 PRs during Hacktoberfest 2020!
tags: hacktoberfest, discuss 
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/2ph1gpihx5yvew74givp.png
---

If you've completed Hacktoberfest 2020, this is your place to celebrate!!!

We'd all love to hear about your experience, see some of your PRs (hint: use the GitHub liquid tag!), and anything else related to Hacktoberfest that you'd like to share/show off. 

You're also welcome to [create a new post](/new/hacktoberfest) using the [#hacktoberfest](/t/hacktoberfest) tag right here on DEV.

### ✨ CONGRATS! ✨

![dancing pumpkin man](https://media.giphy.com/media/l3vRfhFD8hJCiP0uQ/giphy.gif)
My attempt to build a worldwide zip code data set
Published: 2020-10-02 15:40:35

I always thought getting worldwide postal codes by myself was an easy task because postal codes seem to be nothing more than a simple shortcode that is publicly available. I quickly realized this was not the case, because:

- There is no single source of truth
- Most sources were incomplete 
- Data was very often presented in a very unstructured way

After doing some general research, I soon understood, that the reason for the problems above had their origin in the history of postal codes. Each country has a different format, area granularity, and [way of structuring postal codes as a whole](https://en.wikipedia.org/wiki/Postal_code#Presentation).

I first tried to scrape Wikipedia with the following code. For this post, I will use the example of [Austria](https://en.wikipedia.org/wiki/List_of_postal_codes_in_Austria).

For this, I a small python script.
Before running it make sure to install all dependencies:

- `pip3 install lxml`
- `pip3 install requests`,
- `pip3 install bs4`

```python

import requests
from bs4 import BeautifulSoup

url = 'https://en.wikipedia.org/wiki/List_of_postal_codes_in_Austria'

# fire GET request
response = requests.get(url)

# parse content
content = BeautifulSoup(response.text, 'lxml')

# get postal codes

postcodes = [
	postcode.text for postcode in content.find_all('li')
	if ' - ' in postcode.text
]

# filter edge cases

postcodes = [
	postcode.split()[0] for postcode in postcodes 
	if len(postcode.split()) == 3 or
	len(postcode.split()) == 4
]

# write output to file
with open('at_postcodes.txt', 'a') as f:
	for postcode in postcodes:
		f.write(postcode + '\n')

```
The obtained data set and the related approach might be enough for some use cases, but since I wanted to get global postal code data, I was not satisfied.

I live in Austria and realized very quickly that the data that I have just scraped is not complete (some postal codes are missing). Considering the time it took my to build the parser and the fact that I would have to adapt it for every single data source (adaptions are even needed across Wikipedia since every article is written differently), I decided to give up.

This was the moment I gave up and started to look for ready-to-use solutions:

- [Zipcodebase.com](https://zipcodebase.com)
- [greatdata.com](https://greatdata.com/)
- [unitedstateszipcodes.org](https://www.unitedstateszipcodes.org/zip-code-database/) (US Only)
- [getpostcodes.com](https://www.geopostcodes.com/)



I hope this article will save you some time, in case you are trying to achieve the same.
Learning Python at work: When your job aligns with your hobbies
Tags: beginners, python, writing, replit
Published: 2020-10-02 15:24:22

I have worked with Python in some IoT projects that I have played with before and have been interested in learning more ever since. 

One of my latest tasks at work was to go through and edit a book filled with Python tutorials.

The book is designed to introduce you to a great online IDE called Repl.it by guiding you through all kinds of Python projects like plotting, web apps, chatbots, and machine learning programs to name a few. And my job was to do every single tutorial.

How cool is it that I get to play with Python projects and call it my job?

Starting off with getting used to the Repl.it interface and leaning how the basics of building apps on the platform works, I was amazed at how quick and easy it was to get started. Previously, it has always taken me at least a few hours to only set up the environment. With Repl.it, you simply start coding immediately, its like the arrival of the electronic calculator only for code.

Apart from how quick and easy it has become to write and run a program, working through the projects and realizing what can be achieved with just a few lines of code has changed my perspective completely, but that’s a topic for another time.

The first few tutorials show you how to use the interface and all its features. Then you continue to a few basic Python apps that you might have seen before, ie. print('Hello World'). Yes, the book would not be complete without the famous 'Hello World' project but the tutorials quickly become more advanced. You then do some data-science with plots and graphs and even pull your code from GitHub.

By the middle of the book, I ran into a PyGame project. This was a really fun one, juggling balls to see how long you can keep them all in the air. The code was also pretty fun to work with as it was all new to me, in fact, the whole second half of the book was a first. Creating GUI's, building web applications with Django and Flask, CRM applications with databases, web scraping, machine learning, and algorithms, all things I have never seen before.

I learn through doing and find it hard sometimes to grasp concepts just by reading about it without practical experience. These tutorials however explain each line of code very well and make it easy to follow along. The tutorials are all designed to lay down foundations of more complex projects and enable you to expand on them and make them your own.  

Working through this book has broadened my knowledge of programming greatly, but most importantly it has given me a new perspective and advanced my coding journey to where I can now start building my own apps.

If you have started learning Python and are looking for some cool projects to build, I would highly recommend [this](https://www.codewithrepl.it/) free book. It will get you to build your own advanced apps in no time.
The easiest way to make a valid Hacktoberfest Contribution (without spamming)
Tags: hacktoberfest, contributorswanted, github
Published: 2020-10-02 15:04:17

OK, before I get thrown to the wolves, let's get something clear here. As a mildly engaged open-source maintainer that dealt with spam and borderline spam PRs for the past few Hacktoberfests, I don't mind when one of my repositories gets spam pull requests or my favourite "I ran a linter" PRs. That's why bulk actions were invented.

I do understand why most maintainers are not that happy with the idea. But I also get the T-Shirt obsession. Hell, [the only reason I got into Open Source was for a T-Shirt](https://dev.to/lakatos88/the-story-of-a-t-shirt-or-how-i-got-involved-in-open-source-2b2g). And after 2020 I can see why people don't have the energy to bother too much with side projects and evening hacking.

So if you want an easy and still legit way of getting that T-Shirt, and you're not comfortable with opening PRs against your own repositories for it, I've got a solution for you.

{% github AlexLakatos/computer-puns %}

It's a JSON based repo, and you can get away with a 4 line PR, with a horrible, cringe-worthy computer pun(that's British for a one-line joke). And the maintainer, yours truly, will actually be happy if there are hundreds of open PRs. The more, the better I'd say. Hey, you can even make all 4 Hacktoberfest PRs against that repo, and that's your T-Shirt right there.

Later edit: [In light of the new opt-in measures for Hacktoberfest](https://twitter.com/hacktoberfest/status/1312221208667185153), the repo was already tagged with the `hacktoberfest` topic.
How to recover a project or files deleted when running git commands
Published: 2020-10-02 14:56:47

This week as I was working on a project, I made a terrible mistake running some random Git commands that I copied from the internet and ended up deleted the whole project. 

### How did we end up here?
Ok, the story is, I was trying to back up my project to my remote repository using git commands. I initialized my remote repository with a `.gitignore` file and I don't usually do this. When trying to push the project after committing my changes I got the following error:

```git
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
``` 

### What deleted my project?
Just like any other software developers when your house is on fire you think of one place, [Google](https://google.com/). I typed some stuff and ended up on [Stack Overflow](https://stackoverflow.com/). I was so happy when I found a question relating to my struggle (you know the feeling right?). The worst thing I did was picking the wrong answer. I copied and pasted the following command on my Git cmd:

```git
$ git fetch --all && git reset --hard origin/master && git pull
```
After hitting enter my project was gone.

### How I recovered my project?
I followed the following steps:

* Checking when the tip of my branches was updated
```git
$ git reflog
```

This gave me the following information:
```git
94e51c5 (HEAD -> master, origin/master) HEAD@{0}: reset: moving to HEAD@{1}
94e51c5 (HEAD -> master, origin/master) HEAD@{1}: reset: moving to HEAD@{2}
94e51c5 (HEAD -> master, origin/master) HEAD@{2}: reset: moving to HEAD@{1}
94e51c5 (HEAD -> master, origin/master) HEAD@{3}: reset: moving to HEAD@{0}
94e51c5 (HEAD -> master, origin/master) HEAD@{4}: reset: moving to 94e51c5
94e51c5 (HEAD -> master, origin/master) HEAD@{5}: reset: moving to HEAD
94e51c5 (HEAD -> master, origin/master) HEAD@{6}: reset: moving to origin/master
52d867f HEAD@{7}: commit: added a new link
80e3e2a HEAD@{8}: commit (initial): initial commit
```

* I wanted to go back to the first and what I did was:
```git
git reset HEAD@{8}
```
`HEAD@{8}` was for my initial commit (last line on the results above)

This listed all the files that I had added and committed with a `D` on my CMD, showing that they were deleted.

* To recover them I ran the command below:
```git
$ git restore .
```

> My project was back
Oh my God, WTF is Stack
Tags: computerscience
Published: 2020-10-02 14:54:43

I have a short definition I'm writing. 

Is this right?? Close??? Am I getting warmer???

"The stack is a temporary data structure used to temporarily store and retrieve data; and the heap is a temporary storage space that holds objects, etc, that we use in our program, it is dynamic and can change. The stack can also refer to the area allocated in memory where the stack data is stored."


Comments and corrections most welcome!