COVID-19 Simulation

The Importance of Social Isolation

Coronavirus has got me shook. I’ve been staying up late for the past several days reading about the coronavirus. I’m trying to think of ways I can use my not-a-real-dr skills to help spread awareness.

Twitter is a great place to stay updated, and I found knowledge that only made it to mainstream media after 2-3 days – which by then is sometimes “old” news, and the reality then is much worse. For instance, as of this writing on March 14, 2020, we have about 10,000 to 20,000 cases in the United States. But the mainstream media is reporting the 2-3k numbers that are officially reported (perhaps they will try to correct for the underreported numbers soon).

This morning, I woke up to a really interesting tweet.

It inspired me to do something similar. I’m not an expert, but I wanted to see the general effects of social distancing.

Suppose there is a population of 100 people (represented in blue), and they all wear face masks. The CDC has suggested face masks are not effective but we can optimistically assume that it’s “harder” to get infected. For instance, we won’t be able to touch our mouths or nose (but still our eyes and ears). This is what it could look like, where the red color means a person is infected.

We can see that eventually, everyone gets infected. Assume the bottom x-axis represents some measure of time.

Now imagine if everyone interacted with each other with reckless abandon. Two people hug, shake hands, and immediately rub their eyes. We might see something like the following:

Here, the number of infected people increase much faster, and everyone still gets infected. Compared to the face mask version, everyone in reckless abandon is infected by the time things really start to ramp up for people wearing face masks.

Now let’s look at the effects of social isolation. Suppose that only 30% of a population practiced social distancing or social isolation, and were vigilant to always wash their hands. We don’t even have to quarantine people who are sick – just keep 30% of people working from home or socially isolated. This is what it could look like:

Unlike before, we see that some of the blue people still remain at the end – and it takes a longer time for most of the population to get infected.

Now let’s assume that a majority, say 60%, of the population practices social isolation or social distancing. Over the same amount of time as the previous simulations, not only will the entire population never become all red, but there are a lot of blue people around by the end! And this is still assuming that the red people infect others with reckless abandon!

In reality, we hope the results are more towards the last graph. Other things we don’t consider is that the red people will become better with time, and that those who are sick will self-quarantine. If we assume these two factors are true, we will have even more blue people.

So let’s do social distancing as much as we can, and we will not only flatten the curve, but we can smash it!

Special thanks to Ali Almossawi for showing me how to convert a sequence of image files to gif.

Connecting Storm and Kafka

Previously, we set up Kafka and we’ve also set up Storm.

Now, let’s connect the two!

By now, we’ve assumed that you are able to get the ExclamationTopology running from our previous guide. In this guide, we are going to use Kafka as our Spout to the ExclamationTopology.

I usually check out the binary version of Storm to run Storm itself, but I like to develop on the source version of Storm. To that end, let’s grab the source version of Storm and extract it:

$ wget http://apache.mirrors.pair.com/storm/apache-storm-0.9.2-incubating/apache-storm-0.9.2-incubating-src.tar.gz

$ tar -zvxf apache-storm-0.9.2-incubating-src.tar.gz

You can see that a Kafka-connector project has already been written for us, in external/storm-kafka.

To understand how to leverage this project, let’s make Kafka as our Spout for ExclamationTopology.

First, copy the ExclamationTopology to the storm-kafka project, since that’s where all the KafkaSpout classes are (there are other ways of doing this, such as bundling storm-kakfa into a jar, and using these libraries instead).

$ cp apache-storm-0.9.2-incubating-src/examples/storm-starter/src/jvm/storm/starter/ExclamationTopology.java apache-storm-0.9.2-incubating-src/external/storm-kafka/src/jvm/storm/kafka

Now add the following imports into ExclamationTopology:

import storm.kafka.SpoutConfig;
import backtype.storm.spout.SchemeAsMultiScheme;

It should look something like this:

storm-kafka-import

Remember also to change the package at the top of the import statements to storm.kaka (not storm.starter), as seen in the screenshot.

Then use this to setup the Kafka Spout, assuming you have created a “test” topic as shown in our Kafka guide.

String zkConnString = "ec2-54-183-196-65.us-west-1.compute.amazonaws.com";
String topicName = "test";

BrokerHosts hosts = new ZkHosts("localhost:2181");
SpoutConfig spoutConfig = new SpoutConfig(hosts, "test", "/test", "discovery");
spoutConfig.scheme = new SchemeAsMultiScheme(new StringScheme());
KafkaSpout kafkaSpout = new KafkaSpout(spoutConfig);

builder.setSpout("kafka", kafkaSpout);

Here is a screenshot:

storm-kafka-config

Then add the following lines to the pom.xml file currently in that directory. These have to go within the “plugins” bracket:

Also, remove the “scope” field in the org.apache.kafka POM dependency in the pm.xml file under storm-kaka.

Then, compile the package, and submit it to a Storm production cluster.

If you remember from our tutorial on Kafka, you can open up a Producer command line terminal and start typing messages into the Kafka. Go ahead and do this.

On the other side, you should see Storm adding exclamations to everything you type.

Congratulations, you have connected Storm with Kafka!

Using Gist with WordPress on DreamHost

DreamHost makes it incredible easy to fire up a WordPress app on your domain.

DreamHost has “one-click installs,” which include several open-source tools for a website – including WordPress. It’s free if one has the fully-hosted plan.

One just adds the WordPress app. Once the WordPress app is installed, syntax highlighting can be performed through embedding Gists. It seems to be a simple option for introducing syntax highlighting in code.

I’m using oEmbed Gist, which allows you to paste the URL on it’s own line in the WordPress editor:

https://gist.github.com/8589700

…and, voilĂ !

The code is included, syntax highlighting and all!