A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.

How to copy off images from Chrome's cache (on Mac)

How to find Chrome cache on Mac

export YOU=your_username
export PROFILE=Default

mkdir ~/chrome_images
cp /Users/$YOU/Library/Caches/Google/Chrome/$PROFILE/Cache/* ~/chrome_images/
for k in `/bin/ls`; do mv $k $k.jpg; done # rename all files to jpg

open ~/chrome_images

# Now browse the image folder and find the images you want

# More sophisticated renaming example:

if [[ `file $filename | grep JPEG` ]]; then mv $filename{,.jpg} ; fi

YAML tricks to DRY

Use YAML anchor to copy & paste, or deduplicate data using DRY principle for YAML:

credentials::app-name: &app_credentials_anchor # <-- amp="" anchor="" b="" copies="">
     db:
         username: foo
         password: bar

credentials::app-name-worker: *app_credentials_anchor # <-- alias="" b="" pastes="">

Docker basics

# Download an image and spin up a container, run it, connect to it

docker pull [name pf image] # download an image

docker run -d -p 80:80 --name pintail-whoami pintailai/pintail-whoami:0.0.1 # download + run

docker run --rm -v /path/on/machine:/app/out image-name:stable params to app

# List running containers

docker ps # show running containers

docker ps | cut -c-$(tput cols) # show running containers without wrapping to the next line

docker ps -q # show just the IDs of the running containers

docker ps -q | head -1 # show ID of most recently started container (how to sort)

# Run a shell on a container

docker run -i -t [Container ID] /bin/bash

# Connect to a shell on an already-runnning docker container.
# (Shell: Use /bin/bash for ubuntu or /bin/ash for alpine)

docker exec -it [Container ID] [shell]

docker exec -it `docker ps -q | head -1` /bin/bash # run shell on the most recently started container

# Copy a file off

docker cp <container>:<src-path> <local-dest-path>

# Delete all stopped containers and images

docker system prune -a

# List all images

docker image ls

Install perl really fast

Fastest way to install perl:

perlbrew install -j 5 --notest perl-5.16.3

Only takes about 2 mins.

Thanks perlbrew.