Datapipe Weekly #18

Hello friend! This is a newsletter for builders.

What do you like to build?

I hope the ideas in this week’s newsletter can help you get it done.

In this weeks newsletter

  • 💻 Tip: Zipfiles and Tarballs “All I need to know”

  • 📜 Quote of the week

Tip: Zipfiles and Tarballs “All I need to know”

Here some basics on compression in the command line. That is to say, everything that I need to know about it.

I usually rely on the zip utility to compress directories. Say I have a source code in a folder src that I want to compress:

>>> cd src
>>> tree .
├── App.js
├── alex.jpg
├── andrew.jpg
├── bubbles.svg
├── charts
│   └── relative_coin_supply_pct_estimates.html
├── components
│   ├── About
│   │   ├── AboutTextBlock.js
│   │   └── EmailCTA.js
│   ├── Blog
│   │   ├── EmailSignup.js
│   │   └── MediumOutlink.js

Using zip, I would do this:

>>> zip -r src
  adding: src/ (stored 0%)
  adding: src/.DS_Store (deflated 93%)
  adding: src/andrew.jpg (deflated 1%)
  adding: src/charts/ (stored 0%)
  adding: src/charts/.DS_Store (deflated 96%)
  adding: src/charts/relative_coin_supply_pct_estimates.html (deflated 85%)
  adding: src/index.js (deflated 45%)
  adding: src/alex.jpg (deflated 16%)
  adding: src/components/ (stored 0%)
  adding: src/components/Home/ (stored 0%)
  adding: src/components/Home/ProfileCards.js (deflated 72%)
  adding: src/components/Home/EmailSignup.js (deflated 47%)
  adding: src/components/Home/MainOutLinks.js (deflated 60%)
  adding: src/components/Bubbles.js (deflated 63%)

Here’s what I get out:

-rw-r--r--     1 alex  staff   139K  2 Feb 12:54

One upside of zip is we can now add files to the archive. For example, can add a file yarn.lock by doing this:

>>> zip yarn.lock 
  adding: yarn.lock (deflated 73%)

The other week I was working on a server that didn’t have zip installed, and I remembered the tar utility, which works similar to zip and is installed standard on most linux systems.

Whereas zip applies compression on a per-file basis, the tar approach compresses on a multi-file basis. This is because you will first bundle all the files together into a tarball, and then apply gzip compression to that group of files as a whole.

The process looks like this:

>>> tar -zcvf src.tar.gz src
a src
a src/.DS_Store
a src/andrew.jpg
a src/charts
a src/index.js
a src/alex.jpg
a src/components
a src/bubbles.svg
a src/containers
a src/logo.svg
a src/App.js
a src/containers/DataViz
a src/containers/About.js
a src/containers/404.js
a src/containers/Post.js
a src/containers/Home.js
a src/containers/Blog.js

And the result is every so lightly smaller (as we would expect)

-rw-r--r--     1 alex  staff   139K  2 Feb 12:59
-rw-r--r--     1 alex  staff   133K  2 Feb 13:04 src.tar.gz

Uncompressing and unbundling the tarball then looks like this:

tar -zxvf src.tar.gz

I’m not going to sit here and tell you that I’ve memorized the flags, but maybe some day.. if I keep tarring and stop zipping. It helps to know what they mean:

z = use gzip compression
c = create tarball from files in a directory (like the -r arg in zip)
x = extract files from tarball
v = verbose
f = use file for I/O

Quote of the week

“The ability to monitor ones owns and others feelings and emotions, to discriminate among them and to use this information to guide ones thinking and action”
- Peter Salovey and John D. Mayer

This is the definition of emotional intelligence.

Many people exercise their bodies. They want to be physically strong.

Many people study hard topics. They want to be clever and solve problems.

How many people practice emotional intelligence? How many people understand they they don’t “get angry” but just “experience anger”. How many people learn to control that emotion?


Thank you for reading Datapipe 👋

Subscribe the Datapipe weekly newsletter ⬇️