parallelize.sh: run commands in parallel with bash

Recently I'm doing some heavy research work. One part of my work involves invoking a simulation script with different inputs and parameters and then an analysis script to analyze the simulation output.

At first, this is an easy bash loop:

(
  echo 3 11
  echo 3 11
  echo 5 19
  echo 5 19
) | while read -r -a L; do
  X=${L[0]}
  Y=${L[1]}
  python2 simulation.py --x=$X --y=$Y < input.tsv > $X-$Y.simulation.log
  gawk -f analysis.awk $X-$Y.simulation.log > $X-$Y.analysis.tsv
done

The loop works fine, but it takes too long time when the input gets larger, because scripts are running sequentially. Since we have a big server with 32 CPU cores, can I run the scripts in parallel?

So I wrote this nifty little script, parallelize.sh:

Share Dropbox between VirtualBox Host and Guest

My laptop comes with Windows, like most other laptops in the market. But as a computer science student, I need to use Linux from time to time. The laptop manufacturer advised me not to install Linux directly on this laptop. Although this would not void my warranty, they would not provide technical support or supply device drivers if I install Linux. Therefore, I turned into VirtualBox, a hypervisor that allows me to run Linux in a virtual machine, alongside the Windows installation.

I'm also a heavy user of Dropbox, a file hosting service that can synchronize my documents among all my device. I have Dropbox clients installed everywhere, including the Windows of this laptop, and the Linux virtual machine. When I edit a file, the Dropbox client uploads this file to the cloud, and then the Dropbox clients on all other devices download the file from the cloud.

One day, there's a congestion on my apartment's WiFi hotspot, and I notice that the Dropbox synchronization between Windows and the Linux virtual machine is having significant delay: every update travels a long way to the cloud, and then comes back. I also realize that, in my setup, the entire Dropbox contents are duplicated twice: it has one copy in Windows, and another copy in Linux virtual machine. Although having multiple copies is usually a good thing because you have more redundancy, having multiple copies on the same hard drive is not useful. Can I eliminate the synchronization delay and the redundant copy?

VirtualBox Shared Folder

VirtualBox has a nifty feature, shared folders, which allows files of the host system to be accessed within a guest system. In my setup, I could use this feature to access the Dropbox on Windows within the Linux virtual machine.

计算机网络安全访问控制系统的实现

网络拓扑

网络拓扑图

  • 外网网段 202.120.36.0/24

    防火墙eth0接口 202.120.36.180

    DNS服务器 202.120.2.101

  • 内网网段 192.168.33.0/24

    防火墙eth1接口 192.168.33.254

    主机A 192.168.33.40

    主机A公网地址 202.120.36.100

    主机B 192.168.33.41

    主机B公网地址 202.120.36.101

  • DMZ区网段 192.168.1.0/24

    防火墙eth2接口 192.168.1.1

    Web服务器 192.168.1.2

    邮件服务器 192.168.1.40

网络拓扑的脚本定义

Internal="192.168.33.0/24"
DNSServer="202.120.2.101"
WWWServer="202.120.2.102"
GlobalA="202.120.36.100"
HostA="192.168.33.40"
GlobalB="202.120.36.101"
HostB="192.168.33.41"
MailServer="192.168.1.40"
FireWall="202.120.36.180"
HttpsServer="216.239.63.83"
FtpServer="202.38.97.230"
TelnetServer="202.120.3.1"