DEV Community

Cover image for October 22nd, 2021: What did you learn this week?
Nick Taylor
Nick Taylor

Posted on

October 22nd, 2021: What did you learn this week?

It's that time of the week again. So wonderful devs, what did you learn this week? It could be programming tips, career advice etc.

![Information flowing through your brain](https://media.giphy.com/media/qKltgF7Aw515K/giphy.gif)

Feel free to comment with what you learnt and/or reference your TIL post to give it some more exposure.

#todayilearned

Summarize a concept that is new to you.

Top comments (29)

Collapse
 
vonheikemen profile image
Heiker • Edited

I used xargs this week.

It looks like the open command can't take data from the standard input, so I ended up using something like this.

some_command | xargs -r -I{} open {}
Enter fullscreen mode Exit fullscreen mode

For those who don't know, xargs (with the right arguments) can act like the map method on javascript arrays. So you can imagine the above doing something like this:

some_command().map(arg => open(arg))
Enter fullscreen mode Exit fullscreen mode
Collapse
 
grendel profile image
grendel

xargs can come in handy in a pinch, but it's usually unnecessary and the way it generates arguments can cause some complications. I can't think of a case where xargs would be more appropriate than Command Substitution or a while read loop, e.g.:

open "$(some_commands)" #thus you fully control word-splitting
Enter fullscreen mode Exit fullscreen mode

or

some_commands | \
  while IFS= read -r line; do #unsetting IFS here prevents word-splitting
    some_other_commands "$line"
    even_some_more_commands "$line"
    #vars declared in here are not valid afterwards,
    #since they are declared inside the pipeline subshell
    #and its environment does not hoist
    #This includes $line
  done

#alternatively, using process substitution:
while IFS= read -r line; do
  some_other_commands "$line"
  #variables set here remain valid afterwards
  #since this while-loop is not in a subshell
  #thus the last $line will remain set afterwards
done < <(some_commands)
Enter fullscreen mode Exit fullscreen mode

With process substitution and the mapfile builtin, you can even populate an array and iterate over that:

mapfile -t arr < <(some_commands)
#synonym: readarray -t arr < <(some_commands)

for elem in "${arr[@]}"; do
  some_stuff_with "$elem"
done
# or:
for ((i=0; i<${#arr[@]}; i++)); do
  some_stuff_with "${arr[$i]}"
done
Enter fullscreen mode Exit fullscreen mode
Collapse
 
jeremyf profile image
Jeremy Friesen

xargs is some great shell magic. And your JS translation helps me better think about it.

Collapse
 
nickytonline profile image
Nick Taylor

Nice!

Nice

Collapse
 
grendel profile image
grendel

When I have pushed to my remote from another machine, and made commits but forgot to pull first, I learned that to avoid an ugly and unnecessary merge commit, git pull --rebase is probably safer than trying to get around it with various combinations of git stash and git reset, because it yeeted one of my passwords away by accident :v

I also learned how (not) to set up nginx as a reverse-proxy to docker containers and how to use Jekyll

Collapse
 
nickytonline profile image
Nick Taylor

Croc mascot nodding

Collapse
 
coderamrin profile image
Amrin

crap i didn't learn anything new this week.

Collapse
 
nickytonline profile image
Nick Taylor

No worries friend!

Loki holding KFC

Collapse
 
coderamrin profile image
Amrin

Thanks Nick ;)

Collapse
 
ben profile image
Ben Halpern

😮

Collapse
 
lisacee profile image
Lisa Cee

This week I learned about Frontity, a React framework for WordPress. WordPress still serves as the backend and database, but you can make components for the frontend with React. While Frontity isn't going to work for my planned project (I couldn't figure out how to add TailwindCSS into the mix), it's a tool that I'm glad I have played with.

Collapse
 
nickytonline profile image
Nick Taylor

TIL!

Today I learned

Collapse
 
ben profile image
Ben Halpern • Edited

I dug into signed exchanges a bit today. I was vaguely familiar before, but it clicked.

Collapse
 
nickytonline profile image
Nick Taylor

Shia LeBoeuf in character saying Magic!

Collapse
 
amcintosh profile image
Andrew McIntosh

(Re)learning some PHP for a side project. It's been a few years and I never really knew PHP well in the first place. Getting reused to the syntax and learning about PHP 8 changes.

Collapse
 
nickytonline profile image
Nick Taylor

BB-8 giving a thumbs up

Collapse
 
mushonnip profile image
Abu Mushonnip

Well I just got insight and interested to learn new technology, that is ASP.NET Core 6 rc.2 which will be stable release in November.
This is my first time learn .NET stuff, Do you have any learning resources, suggestion or advice about it? (this is also my first time learn C#)
My past experience in web development is just Laravel and Django

Collapse
 
kirkcodes profile image
Kirk Shillingford

Learned about HSL for color in css. Seems way more intutive than RGB or hex codes and I'm going to incorporate it into my front end design more.

Collapse
 
nickytonline profile image
Nick Taylor

Yeah!

A T-Rex saying Yeah!

Collapse
 
steveblue profile image
Stephen Belovarich

I learned there is a computer out there I can still be excited about. M1 Max MBP 🏎

Collapse
 
nickytonline profile image
Nick Taylor

A crab dancing

Collapse
 
fyodorio profile image
Fyodor

SvelteKit and Strapi. They're really cool. Gonna start a pet project to get deeper.

Collapse
 
nickytonline profile image
Nick Taylor

Pam from The Office saying Nice!

Collapse
 
mtfoley profile image
Matthew Foley

In progress learning about conventional commits! github.com/open-sauced/open-sauced...

Collapse
 
nickytonline profile image
Nick Taylor

Chow Yun-fat giving a thumbs up

Nice! You might also be interested in Conventional Comments! I gave a lightning talk about them last year as part of my Virtual Coffee group's lightning talk series.

I'm on at this point.

Collapse
 
godswillumukoro profile image
Godswill Umukoro

Thanks for asking, here's something interesting I learned this week
dev.to/godswillumukoro/css-is-awes...

Collapse
 
nickytonline profile image
Nick Taylor

It's True - Dwight Shrute

Collapse
 
grenguar profile image
Igor Soroka

I learned how to provision the whole CI/CD pipeline with AWS CDK in less than 40 lines of Typescript code :)

Collapse
 
nickytonline profile image
Nick Taylor

Bobby Moynahan character from SNL saying awesome!