List of technical memos for myself

  • I’ll be updating this when I feel like it.
  • Contains my personal opinions and impressions.


command to check disk size

du -sh

bash options required for cron execution.

The environment variables of the cron runtime and the login shell are different. If you printenv to a cron job, you will see that they are different. Therefore, configure bash to read the environment variables of the login shell when it is executed.

#! /bin/bash -l

You can also use the login option

#! /bin/bash --login


diff between branches

git difftool branchA branchB

diff between commits (filenames only)

git diff --stat shaA shaB

Differences between commits (you can see the differences for all files using the method you set in .gitconfig)

git difftool -y shaA shaB

Differences between commits (for each file)

git difftool -y shaA shaB -- <FILE NAME>


Asynchronous processing

Treat asynchronous functions like synchronous functions

var async_test = function() {
  return new Promise((resolve, reject) => {
    setTimeout(() => {
    }, 3000)

  .then(() => {
  .then(() => { console.log("4") })

node path

  • Load the module you did npm i -g => you need to set the NODE path
  • Treat asynchronous functions as if they were synchronous
export NODE_PATH=`npm root -g`

spread operator

  • Spread arrays like an array
var a = [1,2,3].
var b = [4,5,6].
var c = [. .a, .... . b]

// [ 1, 2, 3, 4, 5, 6 ]

map, filter, reduce

var array = [1,2,3,4,5,6,7,8].

console.log( => a * a)) // [ 1, 4, 9, 16, 25, 36, 49, 64].
console.log(array.filter((a) => a % 2 == 0)) // [ 2, 4, 6, 8 ]
console.log(array.reduce((a, b) => a + b)) // 36


Check the contents of the certificate

openssl x509 -text -noout -in <FILE NAME>

Check the contents of your private key.

openssl rsa -text -noout -in <FILE NAME>

Check the contents of the CSR.

openssl req -text -noout -in <FILE NAME>

Inspect the certificate from the client.

openssl s_client -connect


cloudfront => Notes on allowing https communication with EC2 (wordpress).

The cautions are as follows

  • client => CloudFront => EC2(wordpress)
  • client => CloudFront should be 443 and the certificate should be in CFT
  • Connect to CloudFront => EC2 with 80
  • The EC2 where wordpress is installed is ubuntu

[Problem] No problem with http, but when I connect with https, the layout is broken.

[Cause] When I look at the source-viewr of my browser, the protocol to get css and js is http, not https.

[Solution] Add the following item to wp-config.php

  $_SERVER['HTTPS'] = 'on';
  $_SERVER['HTTPS'] ='on';


Use ls to rename files in bulk.

  • This will only allow you to append.
ls | grep XXXX | xargs -I{} cp {} {}.bk

rename to bulk update

  • Normal conversion
rename xxxx yyyy *.md
  • Convert in sed format
rename 's/xxxx/yyyy/g' *.md

Recursive search for file names with XXX in them.

  • Use grep + rl
grep XXX -rl .
  • l : Search for file names
  • r : recursive search

Do a recursive search for filenames with XXX in them and replace all with YYY

  • Use grep + rl + pipe + sed
grep XXX -rl . | xargs sed -i.bk -e 's/XXX/YYYY/g'

Do a recursive search for filenames with XXX in them and replace all with YYY

  • Replace filenames
find . / -type f | sed 'p;s/aaa/bbb/' | xargs -n2 mv
  • The p; in sed is an option to output the result of the substitution to standard output.
  • Two sets of file names are output, one before and one after, as follows
. . /clib/uconst/uconst_aws.js
. . /clib/uuuuuuuu/uuuuuu_aws.js
. . /clib/uconst/utime.js
. . /clib/uuuuuu/utime.js
  • The n2 option of xargs is an option that takes two sets of arguments. The following set of arguments is passed to mv. The result is mv to the replaced filename.
. /clib/uconst/uconst_aws.js
. . /clib/uuuuuuuu/uuuuuu_aws.js

Make sed case-insensitive.

  • Add the -i option
sed -i.bk -e "s/ABC/abc/ig"
  • This doesn’t work on macs (the -i option is disabled).
sed -i '' -i.bk -e "s/ABC/abc/g"

Remove only leading zeros of zero-fill

echo 001309 | sed 's/0*\([0-9]*[0-9]$\)/\1/g' # 1309


List of commands

  • Disconnect (detach) at the stage where you are in tmux
<Prefix-Key> + d
  • Attach to session
tmux a -t <Session>
  • Delete a session
tmux kill-session -t <Session>


Use ls to rename files in bulk.

  • This only allows for appending.
ls | grep XXXX | xargs -I{} cp {} {}.bk


Command list

  • Delete up to x (not including x)
  • Remove up to x (including x)

Case Conversion

  • Convert word-by-word to uppercase.
``` ### case-insensitive

- Convert word-for-word to lowercase
  • Per-word case-insensitive conversion
<visual mode> + U or u


  • Markdown can’t open a link in a separate tab, which might be possible using JS or something, but it compromises the simplicity of Markdown. In that case, you have to write html a tag.