Author: Bian Xi

Create Multi Related Posts in WordPress

Create Multi Related Posts in WordPress

Create a Post with Posts List

# <Post Title> - Posts List

<Post contain>

## References

[<SubPost_Title1>](<SubPost_URL1>)
[<SubPost_Title2>](<SubPost_URL2>)
[<SubPost_Title3>](<SubPost_URL3>)
[<SubPost_Title4>](<SubPost_URL4>)

SubPost

Add following script after each subpost summary.

Note: The 8888 is the subpost id, 9999 is the index post (Posts List) id. This will create a button on current page (8888) to display Posts List

# <Post Title>

<Post contain>

<div><button id='related_posts_8888'>Display Learning Posts</button>

<script type="text/javascript">
(function($) {
    $(document).ready(function() {
        $("#related_posts_8888").click(function(event) {
            el = $(document.getElementById( $(this).attr('id') ).parentElement);
            $.get("?p=9999", function(data, status) {
                el.html(/h2>References<\/h2>([\s\S]*?)<\/div>/.exec(data)[1]);
            });
        });
    });
}) (jQuery);
</script>
</div>

Preset Tmux Windows

Preset Tmux Windows

To preset Tmux windows, following script can be used. It also issues ssh command to host which has same name as window name.

#!/bin/bash

WINDOWS="window_name1 window_name2 window_name3"

for each in $WINDOWS
do
  if ! tmux has-session -t 0:$each; then
    tmux new-window -n $each ssh $each
  fi
done

tmux attach

References

Restore tmux session after reboot
Check If Window With a Specific Name Exists. If It Does Attach to it; Otherwise Create it and Run Command?

VirtualBox Command Line Interface

VirtualBox Command Line

List all VMs

vboxmanage list vms

List all running VMs

vboxmanage list runningvms

Show a VM info

vboxmanage showvminfo <name or UUID>.

Start a VM

vboxmanage startvm <name or UUID>.

Control a VM

vboxmanage controlvm <subcommand>

Subcommand: pause, resume, reset, poweroff, and savestate

Unregister a VM

vboxmanage unregister <name or UUID>

Remove a VM

vboxmanage unregister --delete <name or UUID>

Modify a VM

vboxmanage modifyvm <name or UUID> --name <new name>
vboxmanage modifyvm <name or UUID> --description <new description>.
vboxmanage modifyvm <name or UUID> --memory <RAM in MB>.
vboxmanage modifyvm <name or UUID> --cpus <number>.

Change VM state

vboxmanage controlvm <name or UUID> setlinkstate<num> [off|on]
vboxmanage modifyvm <name or UUID> --nicpromisc<num> allow-all
vboxmanage controlvm nic<num> <network type>

Note: The <num> is referring to eth<num> interface. The Network type can be hostonly, etc.

References

An Introduction to the VirtualBox CLI

Install Vagrant on CentOS in Proxmox

Install Vagrant on CentOS

Steps

Check version

The latest version of Vagrant can be found in https://releases.hashicorp.com/vagrant.

Install

yum install https://releases.hashicorp.com/vagrant/2.2.19/vagrant_2.2.19_x86_64.rpm

Verify

vargant --version

Init CentOS 7 with Vagrant

sudo mkdir ~/vagrant-centos-7
cd ~/vagrant-centos-7
vagrant box add centos/7

Create Vagrantfile

Vagrant.configure("2") do |config|
  config.vm.box = "centos/7"
end

Start Vagrant

vagrant up

SSH

vagrant ssh

Halt Vagrant

vagrant halt

Destroy Vagrant

vagrant destroy

Troubleshooting

If the following error appeared, change the CPU type of CentOS VM in Proxmox to host.

Stderr: VBoxManage: error: VT-x is not available (VERR_VMX_NO_VMX)

References

How to Install Vagrant on CentOS 7
centos/8 Vagrant box

Manage VMware Fusion via `vmrun`

Manage VMware Fusion via vmrun

Start VMware Fusion

$ open -a "VMware Fusion"

List running VM

vmrun list

Start a VM

vmrun start <vm_name>.vmx

Troubleshooting

Hanging at VM starting up

This could be caused by some warning message appears on the screen.

References

Examples of vmrun Commands
How to Open Applications Using Terminal on Mac