Today I Learned
Tidbits of (hopefully) useful information on technologies and tools related to software development.

August 02, 2021 - Vim

First, select the text you want to copy using visual or visual line mode. Afterwards, type the following:

"*y
  • " to select a register
  • * is a register that references the system clipboard
  • y to yank your selection into the specified register

February 09, 2021 - macOS

You can use cmd + shift + 3 to take a screenshot.

Afterwards, you can click the thumbnail that pops up in the corner of the screen to edit or save it. You can also wait for the thumbnail to go away after few seconds and the screenshot will be saved to your desktop.

Other Useful Shortcuts

  • cmd + shift + 4 allows you to select a portion of your screen to capture
    • Hold the space bar to drag the selection window!
  • cmd + shift + 5 gives you full control over what portion of the screen to capture or even record

November 29, 2020 - Vim

You can use the built-in sort utility!

To perform a sort, first select the lines you want to sort using visual mode. Afterwards, press :, type sort, and then press enter.

Note that the default sort is based on unicode characters so the results may be unexpected (it accepts an optional regex argument to help with that!)

There are some neat options like u for removing duplicate lines, n for numeric sort, and sort! for sorting in reverse.


Access-Control-Allow-Headers

Response header to a preflight request (OPTIONS) that indicates which headers can be used when making the actual request.

# Example request
curl -vX OPTIONS \
  -H "Origin: https://yourdomain.com" \
  -H "Access-Control-Request-Method: POST" \
  -H "Access-Control-Request-Headers: X-Some-Header" \
  https://www.someapi.com/

# Example response
# ...
< access-control-allow-origin: https://yourdomain.com
< access-control-allow-methods: OPTIONS,POST
< access-control-allow-headers: X-Some-Header
# ...

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Headers

Access-Control-Expose-Headers

Response header to an actual request that indicates which other response headers the client (ex: a browser) is allowed to access.

# Example request
curl -v -H "Origin: https://yourdomain.com" \
  https://www.someapi.com/

# Example response
# ...
< access-control-allow-origin: https://yourdomain.com
< access-control-expose-headers: X-Some-Header
# ...

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Expose-Headers

November 09, 2020 - Fonts

Got a system font you want to convert into a web font?

cat font.ttf | npx ttf2woff2 >> font.woff2

Need to support older browsers?

npx ttf2woff font.ttf font.woff

Seeing command not found: npx?

You probably need to install Node.js.

Learnings sourced by everyone who has taught me, either directly or indirectly. Thanks!

Visit my main site for more, and sometimes longer, content.