# The Event

Sourced from Saturday Morning Breakfast Cereal.

Author: Alex Raichev
Date: 2018-08-19
Tags: comic

# Deploying a Flask Application on Webfaction

A few months ago i had to deploy for the first time a Flask application on a Webfaction server. After studying this Webfaciton Community thread on the topic, issuing a Webfaction support ticket for help ---Webfaction customer service is excellent--- and trying and failing several times, i figured it out. Here's what i did.

APPNAME
├── APPNAME
│   ├── main.py
│   ...
│   └── wsgi.py
...
├── Pipfile
├── Pipfile.lock


that you are tracking it with Git, that you run it locally in a Python virtual environment, e.g. using Pipenv, and that it works. Now, let's deploy it to Webfaction.

1. Log in to your Webfaction control panel and create a new mod_wsgi/Python application. Also create a corresponding domain and website for the app. I assume you know how to do that.

3. SSH into your Webfaction server and run these commands:

> mkdir home/USERNAME/webapps/APPNAME/APPNAME


You don't need the lib directory in the last line, because you will be using a virtual environment.

4. Set up Git, Git hooks, and push your local repository to Webfaction. See the Webfaction instructions here and here.

5. Create your virtual environment ---let's call it VENVNAME here--- and install your app requirements. I think the easiest way to do this is to install Pip to install Pipenv to manage your virtual environments and packages.

6. If your local repo has a .env environment file containing (Git-ignored) secrets, then create a corresponding .env file in your Webfaction repo.

7. If you haven't done so already, create the file home/USERNAME/webapps/APPNAME/APPNAME/wsgi.py containing the single line from main import server as application.

This assumes that your Flask code lies in the module main.py and that the Flask app you create in that module is call server. If that's not the case, then change the above snippet as needed.

8. Edit the file home/USERNAME/webapps/APPNAME/apache2/conf/httpd.conf to the following, where PORT is the port number that Webfaction assigned to your application (which you can view in your Webfaction control panel for the app):

ServerRoot "/home/USERNAME/webapps/APPNAME/apache2"

LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined

Listen PORT
KeepAlive Off
SetEnvIf X-Forwarded-SSL on HTTPS=1
ServerLimit 1
StartServers 1
MaxRequestWorkers 5

WSGIProcessGroup APPNAME
WSGIRestrictEmbedded On
WSGILazyInitialization On


These instructions will probably go obsolete in a few months, as all things web related do. Still, they'll help me while they last and maybe help you too.

Author: Alex Raichev
Date: 2018-05-17
Tags: instructions, tech

# Kūtere

Kūtere - (Māori, verb) to flow together, rush into one place. Made by my friend Kate.

Author: Alex Raichev
Date: 2018-02-19
Tags: video, poi

# Take a Street and Build a Community

Author: Alex Raichev
Date: 2018-01-04
Tags: video, resilience

# Poor Charlie's Almanack

I recently read Poor Charlie's Almanack, a collection of the wit and wisdom of investor Charles Munger. The book's content is summarized tolerably well in Munger's Wikipedia biography and the following free resources.

## Munger's investment checklist

1. Measure risk. All investment evaluations should begin by measuring risk, especially reputational.

• Incorporate an appropriate margin of safety
• Avoid dealing with people of questionable character
• Insist upon proper compensation for risk assumed
• Always beware of inflation and interest rate exposures
• Avoid big mistakes and shun permanent capital loss
2. Be independent. Only in fairy tales are emperors told they're naked.

• Objectivity and rationality require independence of thought
• Remember that just because other people agree or disagree with you doesn't make you right or wrong. The only thing that matters is the correctness of your analysis and judgment.
• Mimicking the herd invites regression to the mean (merely average performance)
3. Prepare ahead. The only way to win is to work, work, work, and hope to have a few insights.

• Develop into a lifelong self-learner through voracious reading. Cultivate curiosity and strive to become a little wiser every day.
• More important than the will to win is the will to prepare
• Develop fluency in mental models from the major academic disciplines
• If you want to get smart, the question you have to keep asking is "Why, why, why?"
4. Have intellectual humility. Acknowledging what you don't know is the dawning of wisdom.

• Stay within a well-defined circle of competence
• Identify and reconcile disconfirming evidence
• Resist the craving for false precision, false certainties, etc.
• Above all, never fool yourself, and remember that you are the easiest person to fool
5. Analyze rigorously. Use effective checklists to minimize errors and omissions.

• Determine value apart from price, progress apart from activity, and wealth apart from size
• It is better to remember the obvious than to grasp the esoteric
• Be a business analyst, not a market, macroeconomic, or security analyst
• Consider totality of risk and effect. Look always at potential second order and higher level impacts.
• Think forwards and backwards. Invert, always invert.
6. Allocate assets wisely. Proper allocation of capital is an investor's number one job.

• Remember that highest and best use is always measured by the next best use (opportunity cost)
• Good ideas are rare. When the odds are greatly in your favor, bet (allocate) heavily
• Don't fall in love with an investment. Be situation-dependent and opportunity-driven.
7. Have patience. Resist the natural human bias to act.

• "Compound interest is the eighth wonder of the world" (Einstein). Never interrupt it unnecessarily.
• Avoid unnecessary transactional taxes and frictional costs. Never take action for its own sake.
• Be alert for the arrival of luck
• Enjoy the process along with the proceeds, because the process is where you live
8. Be decisive. When proper circumstances present themselves, act with decisiveness and conviction.

• Be fearful when others are greedy, and greedy when others are fearful
• Opportunity doesn't come often, so seize it when it comes
• Opportunity meeting the prepared mind. That's the game
9. Be ready for change. Live with change and accept unremovable complexity.

• Recognize and adapt to the true nature of the world around you. Don't expect it to adapt to you
• Continually challenge and willingly amend your best-loved ideas
• Recognize reality even when you don't like it, especially when you don't like it
10. Stay focused. Keep it simple and remember what you set out to do.

• Remember that reputation and integrity are your most valuable assets and can be lost in a heartbeat
• Guard against the effects of hubris and boredom
• Don't overlook the obvious by drowning in minutiae
• Be careful to exclude unneeded information or slop. "A small leak can sink a great ship" (Benjamin Franklin)
• Face your big troubles. Don't sweep them under the rug.

## Munger talk: A lesson on elementary, worldly wisdom as it relates to investment management and business

In this talk Munger introduces his latticework of mental models for worldly wisdom and recommends that you build your own. He describes several of his models, including compound interest and the basics of algebra, combinatorics, probability, statistics, accounting, microeconomics, and psychology. He doesn't enumerate all his models in this talk or in the rest of the almanack or on the internet, as far as i know. But you can get more ideas from Farnam Street's list of mental models, which is inspired by Munger.

Update 2018-01-26: Here is another collection of mental models assembled by Slava Akhmechet.

## Munger talk: The psychology of human misjudgment

In this talk Munger lists 25 human psychological tendencies (cognitive biases), some of their problems, and some of their antidotes. Hint: Add these tendencies to your latticework of mental models and use them in checklist mode to avoid disasters in judgement.

Below is an audio recording from an earlier version of the talk (circa 1995), in case you want to hear Munger's voice.

Author: Alex Raichev
Date: 2017-12-28

# Stand out of Our Light

James Williams discusses the attention economy, arguing that digital technologies are gradually diminishing our ability to engage with the issues we care about most.

Williams elaborates on this theme in the following talk, analogizing that social media is a denial-of-service attack on our minds.

To combat the negative influence of digital technologies, Williams co-founded the non-profit organization Time Well Spent.

Thanks to Ran Prieur for highlighting Williams's work and riffing on it in his 2017-11-27 and 2017-11-29 posts.

Author: Alex Raichev
Date: 2017-12-03
Tags: video

# Patriotism Explained

Author: Alex Raichev
Date: 2017-09-03
Tags: comic

# Movie Tunes

I watched two Wes Anderson films a few weeks back and especially enjoyed these tunes from them:

• s'Rothe Zäuerli by Öse Schuppel featured in The Grand Budapest Hotel.
• Cuckoo from Friday Afternoons by Benjamin Britten performed here by the Toronto Children's Chorus and featured in Moonrise Kingdom.
Author: Alex Raichev
Date: 2017-08-06
Tags: music

# Nothing to Do with the Known

Author: Alex Raichev
Date: 2017-04-25
Tags: video, nonduality

# Lessons Learned from a Bicycle Accident

Last week i wiped out on my usual bicycle ride home from work. Nothing hospital-serious, but i did sustain three nasty abrasions (gory photo) on my arm and leg, red badges of negligence as i will explain.

During my recovery i learned several important lessons that i pass on here as advice in hopes that it may help you and my future self.

1. If you want to take tight turns on a bicycle, check that the tires have enough air, e.g. have pressures within the suggested ranges printed on the sidewalls. Through carelessness i let my front tire deflate so much that it collapsed on a tight turn, pulling the bike out from under me and throwing me to the ground. Additionally, if you want to corner at high speeds, you should look through the turn, brake before entering, lean the bike in a separate phase, and exit with speed and confidence.

2. If you have an abrasion, burn, or laceration, practice moist wound care to speed up healing, reduce pain, and reduce scarring compared to other wound care practices. More details from a hospital unit in Japan that practices the method.

3. Moist wound care can be cheap and natural, according to various traditional practices, case studies, and clinical trials i read about on the internet.

• To clean the wound, you can use clean water with a pinch of salt. Avoid strong antiseptics, such as iodine or hydrogen peroxide, because they are toxic to all cells, including the ones needed for healing.
• To help prevent infection and keep the wound moist, you can apply virgin coconut oil to the wound topically several times a day, or maybe some other traditional ointments, such as turmeric paste, aloe vera, or honey. I found many historical and anectdotal reports and a little clinical research suggesting that these ointments help. For the first 48 hours of treatment, i applied UMF 15+ manuka honey to my wound, but after near continuous intense burning and little sleep, i stopped. The pain disappeared immediately and never returned. A few days later and for the rest of my treatment i used coconut oil. In the future i will avoid strongly antibacterial honeys.
• To further keep the wound moist and protect it from dirt and scratches, you can use banana leaves or potato skins held fast to the wound with cloth bandages and secured by a clip. Be sure to sterilize the leaves or skins by boiling them for at least 20 minutes or steaming them in a pressure cooker for at least 15 minutes. You can also sterilize the cloth wrap by the same methods and then dry it out in the oven or sun; video instructions here. While you are hunting for banana leaves or potato skins, you can wrap the wound with plastic cling film, which is sterile and non-adherent. I would not use plastic wrap as a long-term solution, though, lest the plastic leech some toxic chemicals into the wound. I used banana leaves foraged from trees in my neighborhood and vouch for their merciful non-adherence. Here is some research on banana leaf dressing.
4. Take internal medicine while healing. Zinc (from food or supplements) for boosting the immune system, vitamin C (from food or supplements) to help your body make new skin, and anti-inflamatories, such as fresh turmeric and ginger infusion, in case your immune response gets out of hand.

5. Look out for signs of infection: extreme wound swelling, extreme pain, swollen lymph nodes, fever. The treatment above will help your immune system battle infection, but if it appears to be losing after the first few days of care, then you might need to enlist the help of strong antibiotics. In that case, seek trained medical assistance.

Author: Alex Raichev
Date: 2017-02-26