Table of contents



I use tech devices a lot, maybe too much, but I don’t dive in too technically. The few times I have to get things done with more technical tools, I need some reference.

Hotkeys #

Hotkeys

CLI #

Useful terminal commands

change screenshot format

defaults write com.apple.screencapture type jpg
killall SystemUIServer

build a Jekyll website and deploy it

#!/bin/bash

JEKYLL_ENV=production bundle exec jekyll build
rsync -avr --rsh='ssh' --delete-after --delete-excluded _site/ username@IP.Add.re.ss:~/notes/_site

note: -avr could be -avz instead

Compress a file or a folder

zip -r -X archive-name.zip folder-to-compress

sd #

sd is a wonderful command-line tool to find and replace sub-strings in files. Its original version is sed, which comes by default in shell.

Replace foo with bar in all files inside pwd:

sd "foo" "bar" ./*


HTML proofer #

HTML proofer is a Ruby script to check HTML quality of a local folder. It can both be used as a library and as a command line tool.

basic check of a Jekyll website

bundle exec htmlproofer --assume-extension --allow_hash_href --check_favicon --check_opengraph --check_html --check_img_http --http_status_ignore 429 --url_ignore '#!' --checks_to_ignore '#!' --report_eof_tags --report_invalid_tags --report_mismatched_tags --report_missing_names --report_script_embeds /Users/xplosionmind/tommi.space/\_site # --report_missing_doctype

See HTML Proofer > Configuration for the complete parameters list.


Resources #




Pandoc #

Useful links:


Convert a Word file into a Markdown file, following the CommonMark standard

pandoc input.docx -f docx -t commonmark -o ~/Desktop/output.md

Convert multiple Word files in a folder in a standalone Markdown file

pandoc *.docx -f docx -t commonmark -s -o ~/Desktop/output.md
Replace commonmark with markdown_mmd to have more features




ExifTool #

Scripts for the awesome ExifTool. I use them as part of my Photo importing workflow

For all of the following commands, pwd must correspond to the folder containing the pictures to be scanned.

Show metadata #

exiftool -s -G
-s is used to show the names in ExifTool commands format. e.g.: instead of "Create Date" you see "CreateDate"
-G is used to show the metadata Group to which the metadata tag belongs.


File renaming #

Rename files based on their date and time data.

Images shot at the same moment (photo bursts, for example) are being sorted with increasing single-digit indexes.
Since there are many parameters which might contain conflicting times, there are several different tags which can be analyzed. I sorted them such that the first ones are the ones which are more likely to be found but probably not exact, while the last ones are very precise tags, but less likely to be found in an image metadata.
exiftool '-FileName<FileModifyDate' -d %Y.%m.%d\ -\ %H.%M.%S%%c.%%le -r ./*
exiftool '-FileName<DateTimeCreated' -d %Y.%m.%d\ -\ %H.%M.%S%%c.%%le -r ./*
exiftool '-FileName<CreateDate' -d %Y.%m.%d\ -\ %H.%M.%S%%c.%%le -r ./*
exiftool '-FileName<DateTimeOriginal' -d %Y.%m.%d\ -\ %H.%M.%S%%c.%%le -r ./*
exiftool '-FileName<GPSDateTime' -d %Y.%m.%d\ -\ %H.%M.%S%%c.%%le -r ./*
-r makes the analysis recursive: subfolders are scanned, too.


Directories #

Organize files in directories based on each image’s dimensions (resolution)

NOTE: newly created directories are created in pwd
"-Directory<imagesize" ./*


Move files to folders based on year and month

exiftool '-Directory<FileModifyDate' -d ./%Y/%Y.%m -r ./*
exiftool '-Directory<DateTimeCreated' -d ./%Y/%Y.%m -r ./*
exiftool '-Directory<CreateDate' -d ./%Y/%Y.%m -r ./*
exiftool '-Directory<DateTimeOriginal' -d ./%Y/%Y.%m -r ./*
exiftool '-Directory<GPSDateTime' -d ./%Y/%Y.%m -r ./*
add -o after exiftool to copy each image instead of moving it.


Resources #

Commands above are a personal adaptation of the ones I found from the following sources:




git #



Nextcloud #

Manually install applications #

move to the Nextcloud apps folder

cd /var/www/nextcloud/apps

download the application package from Nextcloud apps website

wget https://github.com/nextcloud/documentserver_community/releases/download/v0.1.5/documentserver_community.tar.gz # url to the package

extract it (by substituting package_name with the name of the app package)

tar -xvzf package_name.tar.gz

remove compressed package

rm -rf package_name.tar.gz

change permissions for the app’s directory

chown -R www-data:www-data /var/www/nextcloud/apps/app_name
chmod -R 755 /var/www/nextcloud/apps/app-name


Maintenance mode #

enable maintenance mode

sudo -u www-data php /var/www/cloud.tommi.space/public_html/occ maintenance:mode --on

disable maintenance mode

sudo -u www-data php /var/www/cloud.tommi.space/public_html/occ maintenance:mode --off




Docker #

Notes #

  • Every docker container has an IP assigned by default
  • by default, docker doesn’t assign a terminal to a container when it’s run
  • Docker has a built-in DNS serves that allows containers to resolve each other
    • DNS server runs at 127.0.0.11


to list all running containers

docker ps

to list running and non-running containers

docker ps -a

to list all the details about a container

docker inspect some-container

to see all the logs of a container running in a background

docker logs some-container


Run #

docker run some-image
  • add -d to
  • add -it to run an image in an interactive way
    • add -i to check for input
    • add -t to prompt on terminal
  • -p 80:5000 port-where-user-access:port-of-docker-container
  • to store data in an external directory docker run -v /opt/daradir:/var/lib/some-app some-app
  • -e ENVIRONMENT_VARIABLE=VARIABLE some-app to change an environment variable


Networks #

To find which network you’re in, use the inspect command


bridge:

private and internal network


none:

no attachment to any network

docker run some-app --network=none


host:

to access from the web

docker run some-app --network=host



Storage #

Docker files are in /var/lib/docker


Questions #

  • how can I know the Docker Host IP address?

suggest edit

Share

Comments